Here are the examples of the python api openscrapers.modules.control.dataPath taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
9 Examples
3
View Complete Implementation : regex.py
Copyright GNU General Public License v3.0
Author : a4k-openproject
Copyright GNU General Public License v3.0
Author : a4k-openproject
def fetch(regex):
try:
cacheFile = os.path.join(control.dataPath, 'regex.db')
dbcon = database.connect(cacheFile)
dbcur = dbcon.cursor()
dbcur.execute("SELECT * FROM regex WHERE regex = '%s'" % regex)
regex = dbcur.fetchone()[1]
return regex
except:
return
3
View Complete Implementation : regex.py
Copyright GNU General Public License v3.0
Author : a4k-openproject
Copyright GNU General Public License v3.0
Author : a4k-openproject
def insert(data):
try:
control.makeFile(control.dataPath)
cacheFile = os.path.join(control.dataPath, 'regex.db')
dbcon = database.connect(cacheFile)
dbcur = dbcon.cursor()
dbcur.execute("CREATE TABLE IF NOT EXISTS regex (""regex TEXT, ""response TEXT, ""UNIQUE(regex)"");")
for i in data:
try:
dbcur.execute("INSERT INTO regex Values (?, ?)", (i['regex'], i['response']))
except:
past
dbcon.commit()
except:
return
3
View Complete Implementation : regex.py
Copyright GNU General Public License v3.0
Author : a4k-openproject
Copyright GNU General Public License v3.0
Author : a4k-openproject
def clear():
try:
cacheFile = os.path.join(control.dataPath, 'regex.db')
dbcon = database.connect(cacheFile)
dbcur = dbcon.cursor()
dbcur.execute("DROP TABLE IF EXISTS regex")
dbcur.execute("VACUUM")
dbcon.commit()
except:
past
0
View Complete Implementation : cache.py
Copyright GNU General Public License v3.0
Author : a4k-openproject
Copyright GNU General Public License v3.0
Author : a4k-openproject
def bennu_download_get(function, timeout, *args, **table):
try:
response = None
f = repr(function)
f = re.sub('.+\smethod\s|.+function\s|\sat\s.+|\sof\s.+', '', f)
a = hashlib.md5()
for i in args: a.update(str(i))
a = str(a.hexdigest())
except:
past
try:
table = table['table']
except:
table = 'rel_list'
try:
control.makeFile(control.dataPath)
dbcon = db.connect(control.cacheFile)
dbcur = dbcon.cursor()
dbcur.execute("SELECT * FROM %s WHERE func = '%s' AND args = '%s'" % (table, f, a))
match = dbcur.fetchone()
response = eval(match[2].encode('utf-8'))
t1 = int(match[3])
t2 = int(time.time())
update = (abs(t2 - t1) / 3600) >= int(timeout)
if update is False:
return response
except:
past
try:
r = function(*args)
if (r is None or r == []) and response is not None:
return response
elif (r is None or r == []):
return r
except:
return
try:
r = repr(r)
t = int(time.time())
dbcur.execute(
"CREATE TABLE IF NOT EXISTS %s (""func TEXT, ""args TEXT, ""response TEXT, ""added TEXT, ""UNIQUE(func, args)"");" % table)
dbcur.execute("DELETE FROM %s WHERE func = '%s' AND args = '%s'" % (table, f, a))
dbcur.execute("INSERT INTO %s Values (?, ?, ?, ?)" % table, (f, a, r, t))
dbcon.commit()
except:
past
try:
return eval(r.encode('utf-8'))
except:
past
0
View Complete Implementation : cache.py
Copyright GNU General Public License v3.0
Author : a4k-openproject
Copyright GNU General Public License v3.0
Author : a4k-openproject
def _get_connection():
control.makeFile(control.dataPath)
conn = db.connect(control.cacheFile)
conn.row_factory = _dict_factory
return conn
0
View Complete Implementation : cache.py
Copyright GNU General Public License v3.0
Author : a4k-openproject
Copyright GNU General Public License v3.0
Author : a4k-openproject
def _get_connection_meta():
control.makeFile(control.dataPath)
conn = db.connect(control.metacacheFile)
conn.row_factory = _dict_factory
return conn
0
View Complete Implementation : cache.py
Copyright GNU General Public License v3.0
Author : a4k-openproject
Copyright GNU General Public License v3.0
Author : a4k-openproject
def _get_connection_providers():
control.makeFile(control.dataPath)
conn = db.connect(control.providercacheFile)
conn.row_factory = _dict_factory
return conn
0
View Complete Implementation : cache.py
Copyright GNU General Public License v3.0
Author : a4k-openproject
Copyright GNU General Public License v3.0
Author : a4k-openproject
def _get_connection_search():
control.makeFile(control.dataPath)
conn = db.connect(control.searchFile)
conn.row_factory = _dict_factory
return conn
0
View Complete Implementation : cache.py
Copyright GNU General Public License v3.0
Author : a4k-openproject
Copyright GNU General Public License v3.0
Author : a4k-openproject
def _find_cache_version():
import os
versionFile = os.path.join(control.dataPath, 'cache.v')
try:
if not os.path.exists(versionFile):
f = open(versionFile, 'w')
f.close()
except Exception:
import xbmc
print 'OpenScrapers Addon Data Path Does not Exist. Creating Folder....'
ad_folder = xbmc.translatePath('special://home/userdata/addon_data/script.module.openscrapers')
os.makedirs(ad_folder)
try:
with open(versionFile, 'rb') as fh:
oldVersion = fh.read()
except:
oldVersion = '0'
try:
curVersion = control.addon('script.module.openscrapers').getAddonInfo('version')
if oldVersion != curVersion:
with open(versionFile, 'wb') as fh:
fh.write(curVersion)
return True
else:
return False
except:
return False