Alcune migliorie
This commit is contained in:
+6
-4
@@ -14,7 +14,7 @@ except:
|
|||||||
from . import filetools
|
from . import filetools
|
||||||
from platformcode import config
|
from platformcode import config
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
from lib.sqlitedict import SqliteDict
|
from lib.sqlitedict import SqliteDict, SqliteMultithread
|
||||||
|
|
||||||
|
|
||||||
class nested_dict_sqlite(defaultdict):
|
class nested_dict_sqlite(defaultdict):
|
||||||
@@ -25,10 +25,12 @@ class nested_dict_sqlite(defaultdict):
|
|||||||
return value
|
return value
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
for key in self.keys():
|
sqliteTH.close()
|
||||||
self[key].close()
|
# for key in self.keys():
|
||||||
|
# self[key].close()
|
||||||
self.clear()
|
self.clear()
|
||||||
|
|
||||||
|
|
||||||
db_name = filetools.join(config.get_data_path(), "db.sqlite")
|
db_name = filetools.join(config.get_data_path(), "db.sqlite")
|
||||||
db = nested_dict_sqlite(lambda table: SqliteDict(db_name, table, 'c', True))
|
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))
|
||||||
|
|||||||
+3
-3
@@ -109,7 +109,7 @@ class SqliteDict(DictClass):
|
|||||||
VALID_FLAGS = ['c', 'r', 'w', 'n']
|
VALID_FLAGS = ['c', 'r', 'w', 'n']
|
||||||
|
|
||||||
def __init__(self, filename=None, tablename='unnamed', flag='c',
|
def __init__(self, filename=None, tablename='unnamed', flag='c',
|
||||||
autocommit=False, journal_mode="DELETE", encode=encode, decode=decode, timeout=5):
|
autocommit=False, journal_mode="DELETE", encode=encode, decode=decode, timeout=5, conn=None):
|
||||||
"""
|
"""
|
||||||
Initialize a thread-safe sqlite-backed dictionary. The dictionary will
|
Initialize a thread-safe sqlite-backed dictionary. The dictionary will
|
||||||
be a table `tablename` in database file `filename`. A single file (=database)
|
be a table `tablename` in database file `filename`. A single file (=database)
|
||||||
@@ -174,7 +174,7 @@ class SqliteDict(DictClass):
|
|||||||
self.timeout = timeout
|
self.timeout = timeout
|
||||||
|
|
||||||
logger.info("opening Sqlite table %r in %r" % (tablename, filename))
|
logger.info("opening Sqlite table %r in %r" % (tablename, filename))
|
||||||
self.conn = self._new_conn()
|
self.conn = self._new_conn() if not conn else conn
|
||||||
if self.flag == 'r':
|
if self.flag == 'r':
|
||||||
if self.tablename not in SqliteDict.get_tablenames(self.filename):
|
if self.tablename not in SqliteDict.get_tablenames(self.filename):
|
||||||
msg = 'Refusing to create a new table "%s" in read-only DB mode' % tablename
|
msg = 'Refusing to create a new table "%s" in read-only DB mode' % tablename
|
||||||
@@ -593,7 +593,7 @@ class SqliteMultithread(Thread):
|
|||||||
while time.time() - start_time < self.timeout:
|
while time.time() - start_time < self.timeout:
|
||||||
if self._sqlitedict_thread_initialized or self.exception:
|
if self._sqlitedict_thread_initialized or self.exception:
|
||||||
return
|
return
|
||||||
time.sleep(0.1)
|
time.sleep(0.01)
|
||||||
raise TimeoutError("SqliteMultithread failed to flag initialization withing %0.0f seconds." % self.timeout)
|
raise TimeoutError("SqliteMultithread failed to flag initialization withing %0.0f seconds." % self.timeout)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -35,9 +35,6 @@ def start():
|
|||||||
def run(item=None):
|
def run(item=None):
|
||||||
logger.debug()
|
logger.debug()
|
||||||
|
|
||||||
# for saving viewmode for precedent menu
|
|
||||||
platformtools.viewmodeMonitor()
|
|
||||||
|
|
||||||
if not item:
|
if not item:
|
||||||
# Extract item from sys.argv
|
# Extract item from sys.argv
|
||||||
if sys.argv[2]:
|
if sys.argv[2]:
|
||||||
|
|||||||
+7
-10
@@ -89,21 +89,18 @@ def update(path, p_dialog, i, t, serie, overwrite):
|
|||||||
# serie.infoLabels['playcount'] = serie.playcount
|
# serie.infoLabels['playcount'] = serie.playcount
|
||||||
insertados_total += insertados
|
insertados_total += insertados
|
||||||
|
|
||||||
except Exception as ex:
|
except:
|
||||||
|
import traceback
|
||||||
logger.error("Error when saving the chapters of the series")
|
logger.error("Error when saving the chapters of the series")
|
||||||
template = "An exception of type %s occured. Arguments:\n%r"
|
logger.error(traceback.format_exc())
|
||||||
message = template % (type(ex).__name__, ex.args)
|
|
||||||
logger.error(message)
|
|
||||||
|
|
||||||
except Exception as ex:
|
except:
|
||||||
|
import traceback
|
||||||
logger.error("Error in obtaining the episodes of: %s" % serie.show)
|
logger.error("Error in obtaining the episodes of: %s" % serie.show)
|
||||||
template = "An exception of type %s occured. Arguments:\n%r"
|
logger.error(traceback.format_exc())
|
||||||
message = template % (type(ex).__name__, ex.args)
|
|
||||||
logger.error(message)
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
logger.debug("Channel %s not active is not updated" % serie.channel)
|
logger.debug("Channel %s not active is not updated" % serie.channel)
|
||||||
|
|
||||||
# Synchronize the episodes seen from the Kodi video library with that of KoD
|
# Synchronize the episodes seen from the Kodi video library with that of KoD
|
||||||
try:
|
try:
|
||||||
if config.is_xbmc(): # If it's Kodi, we do it
|
if config.is_xbmc(): # If it's Kodi, we do it
|
||||||
@@ -127,7 +124,7 @@ def check_for_update(overwrite=True):
|
|||||||
if config.get_setting("update", "videolibrary") != 0 or overwrite:
|
if config.get_setting("update", "videolibrary") != 0 or overwrite:
|
||||||
config.set_setting("updatelibrary_last_check", hoy.strftime('%Y-%m-%d'), "videolibrary")
|
config.set_setting("updatelibrary_last_check", hoy.strftime('%Y-%m-%d'), "videolibrary")
|
||||||
|
|
||||||
heading = config.get_localized_string(60389)
|
heading = config.get_localized_string(60601)
|
||||||
p_dialog = platformtools.dialog_progress_bg(config.get_localized_string(20000), heading)
|
p_dialog = platformtools.dialog_progress_bg(config.get_localized_string(20000), heading)
|
||||||
p_dialog.update(0, '')
|
p_dialog.update(0, '')
|
||||||
show_list = []
|
show_list = []
|
||||||
|
|||||||
Reference in New Issue
Block a user