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:
self.settings['last_progress'] = datetime.today()
if window('emby.restart.bool'):
window('emby.restart', clear=True)
raise Exception('RestartService')
if self.waitForAbort(1):
break
window('emby_should_stop.bool', True)
self.shutdown()
def start_default(self):
@ -400,8 +404,12 @@ class Service(xbmc.Monitor):
Views().get_views()
elif method == 'CheckUpdate':
if not self.check_update():
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):
@ -448,6 +456,7 @@ class Service(xbmc.Monitor):
def shutdown(self):
LOG.warn("---<[ EXITING ]")
window('emby_should_stop.bool', True)
properties = [ # TODO: review
"emby_state", "emby_serverStatus",

View file

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

View file

@ -45,6 +45,8 @@ if __name__ == "__main__":
LOG.warn("-->[ service ]")
LOG.warn("Delay startup by %s seconds.", DELAY)
while True:
try:
session = Service()
@ -53,13 +55,23 @@ if __name__ == "__main__":
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)
break
LOG.warn("--<[ service ]")