This commit is contained in:
mac12m99
2021-05-13 20:13:13 +02:00
parent 5dfd4a09c2
commit 3f72cebd96
3 changed files with 7 additions and 9 deletions

View File

@@ -20,7 +20,7 @@ def get_cookie():
def get_data(item):
support.dbg()
# support.dbg()
url = httptools.downloadpage(item.url, headers=headers, follow_redirects=True, only_headers=True).url
data = support.match(url, headers=headers, follow_redirects=True).data
if 'AWCookieVerify' in data:

View File

@@ -14,7 +14,7 @@ except:
from . import filetools
from platformcode import config
from collections import defaultdict
from lib.sqlitedict import SqliteDict, SqliteMultithread
from lib.sqlitedict import SqliteDict
class nested_dict_sqlite(defaultdict):
@@ -25,12 +25,10 @@ class nested_dict_sqlite(defaultdict):
return value
def close(self):
sqliteTH.close()
# for key in self.keys():
# self[key].close()
for key in self.keys():
self[key].close()
self.clear()
db_name = filetools.join(config.get_data_path(), "db.sqlite")
sqliteTH = SqliteMultithread(db_name, autocommit=True, journal_mode="DELETE", timeout=5)
db = nested_dict_sqlite(lambda table: SqliteDict(db_name, table, 'c', True, conn=sqliteTH))
db = nested_dict_sqlite(lambda table: SqliteDict(db_name, table, 'c', True))

View File

@@ -109,7 +109,7 @@ class SqliteDict(DictClass):
VALID_FLAGS = ['c', 'r', 'w', 'n']
def __init__(self, filename=None, tablename='unnamed', flag='c',
autocommit=False, journal_mode="DELETE", encode=encode, decode=decode, timeout=5, conn=None):
autocommit=False, journal_mode="DELETE", encode=encode, decode=decode, timeout=5):
"""
Initialize a thread-safe sqlite-backed dictionary. The dictionary will
be a table `tablename` in database file `filename`. A single file (=database)
@@ -174,7 +174,7 @@ class SqliteDict(DictClass):
self.timeout = timeout
logger.info("opening Sqlite table %r in %r" % (tablename, filename))
self.conn = self._new_conn() if not conn else conn
self.conn = self._new_conn()
if self.flag == 'r':
if self.tablename not in SqliteDict.get_tablenames(self.filename):
msg = 'Refusing to create a new table "%s" in read-only DB mode' % tablename