fix db stuff (#164)

* Reload objects upon initial setup

* Fix database discovery

ignore db-journal
This commit is contained in:
angelblue05 2019-01-20 01:21:37 -06:00 committed by GitHub
parent 2a4e42fba0
commit 2bbd5bf3a9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 29 additions and 27 deletions

View file

@ -99,7 +99,8 @@ class Database(object):
modified = {'file': None, 'time': 0}
for file in reversed(files):
if file.startswith(database) and not file.endswith('-wal') and not file.endswith('-shm'):
if (file.startswith(database) and not file.endswith('-wal') and
not file.endswith('-shm') and not file.endswith('db-journal')):
st = xbmcvfs.Stat(databases + file.decode('utf-8'))
modified_int = st.st_mtime()

View file

@ -200,7 +200,7 @@ class Service(xbmc.Monitor):
return False
get_objects(zipfile, label + '.zip')
reload(objects) # to apply latest changes
self.reload_objects()
dialog("notification", heading="{emby}", message=_(33156), icon="{emby}")
LOG.info("--[ new objects/%s ]", objects.version)
@ -477,6 +477,30 @@ class Service(xbmc.Monitor):
if not self.settings['kodi_companion']:
dialog("ok", heading="{emby}", line1=_(33138))
def reload_objects(self):
''' Reload objects which depends on the patch module.
This allows to see the changes in code without restarting the python interpreter.
'''
import full_sync
reload_modules = ['objects.movies', 'objects.musicvideos', 'objects.tvshows',
'objects.music', 'objects.obj', 'objects.actions', 'objects.kodi.kodi',
'objects.kodi.movies', 'objects.kodi.musicvideos', 'objects.kodi.tvshows',
'objects.kodi.music', 'objects.kodi.artwork', 'objects.kodi.queries',
'objects.kodi.queries_music', 'objects.kodi.queries_texture']
for mod in reload_modules:
del sys.modules[mod]
reload(objects.kodi)
reload(objects)
reload(library)
reload(full_sync)
reload(monitor)
LOG.warn("---[ objects reloaded ]")
def shutdown(self):
LOG.warn("---<[ EXITING ]")

View file

@ -65,6 +65,8 @@ class ServiceManager(threading.Thread):
if not 'ExitService' in error and service is not None:
service.shutdown()
elif 'RestartService' in error:
service.reload_objects()
self.exception = error
@ -82,31 +84,6 @@ if __name__ == "__main__":
session.join() # Block until the thread exits.
if 'RestartService' in session.exception:
''' Reload objects which depends on the patch module.
'''
LOG.warn("--[ RESTART ]")
import objects
import library
import full_sync
import monitor
reload_modules = ['objects.movies', 'objects.musicvideos', 'objects.tvshows',
'objects.music', 'objects.obj', 'objects.actions', 'objects.kodi.kodi',
'objects.kodi.movies', 'objects.kodi.musicvideos', 'objects.kodi.tvshows',
'objects.kodi.music', 'objects.kodi.artwork', 'objects.kodi.queries',
'objects.kodi.queries_music', 'objects.kodi.queries_texture']
for mod in reload_modules:
del sys.modules[mod]
reload(objects.kodi)
reload(objects)
reload(library)
reload(full_sync)
reload(monitor)
continue
except Exception as error: