Restart service upon check for updates

To reload the new objects module.
This commit is contained in:
angelblue05 2018-10-13 03:51:10 -05:00
parent c76f19e42d
commit 1174c685e9
3 changed files with 34 additions and 13 deletions

View file

@ -115,10 +115,14 @@ class Service(xbmc.Monitor):
if update: if update:
self.settings['last_progress'] = datetime.today() self.settings['last_progress'] = datetime.today()
if window('emby.restart.bool'):
window('emby.restart', clear=True)
raise Exception('RestartService')
if self.waitForAbort(1): if self.waitForAbort(1):
break break
window('emby_should_stop.bool', True)
self.shutdown() self.shutdown()
def start_default(self): def start_default(self):
@ -400,8 +404,12 @@ class Service(xbmc.Monitor):
Views().get_views() Views().get_views()
elif method == 'CheckUpdate': elif method == 'CheckUpdate':
if not self.check_update(): if not self.check_update():
dialog("notification", heading="{emby}", message=_(21341), icon="{emby}", sound=False) dialog("notification", heading="{emby}", message=_(21341), icon="{emby}", sound=False)
else:
dialog("notification", heading="{emby}", message=_(33181), icon="{emby}", sound=False)
window('emby.restart.bool', True)
def onSettingsChanged(self): def onSettingsChanged(self):
@ -448,6 +456,7 @@ class Service(xbmc.Monitor):
def shutdown(self): def shutdown(self):
LOG.warn("---<[ EXITING ]") LOG.warn("---<[ EXITING ]")
window('emby_should_stop.bool', True)
properties = [ # TODO: review properties = [ # TODO: review
"emby_state", "emby_serverStatus", "emby_state", "emby_serverStatus",

View file

@ -38,7 +38,7 @@ def window(key, value=None, clear=False, window_id=10000):
if clear: if clear:
LOG.debug("--[ window clear: %s ]", key) LOG.debug("--[ window clear: %s ]", key)
window.clearProperty(key) window.clearProperty(key.replace('.json', "").replace('.bool', ""))
elif value is not None: elif value is not None:
if key.endswith('.json'): if key.endswith('.json'):

View file

@ -45,21 +45,33 @@ if __name__ == "__main__":
LOG.warn("-->[ service ]") LOG.warn("-->[ service ]")
LOG.warn("Delay startup by %s seconds.", DELAY) LOG.warn("Delay startup by %s seconds.", DELAY)
try: while True:
session = Service()
try: try:
if DELAY and xbmc.Monitor().waitForAbort(DELAY): session = Service()
raise Exception("Aborted during startup delay")
session.service() try:
except Exception as error: # TODO, build exceptions if DELAY and xbmc.Monitor().waitForAbort(DELAY):
raise Exception("Aborted during startup delay")
session.service()
break
except Exception as error: # TODO, build exceptions
LOG.exception(error)
session.shutdown()
if 'RestartService' not in error:
LOG.warn("--<<[ service ]")
break
except Exception as error:
''' Issue initializing the service.
'''
LOG.exception(error) LOG.exception(error)
session.shutdown()
except Exception as error: break
''' Issue initializing the service.
'''
LOG.exception(error)
LOG.warn("--<[ service ]") LOG.warn("--<[ service ]")