diff --git a/resources/site-packages/quasar/daemon.py b/resources/site-packages/quasar/daemon.py index f21f95fe5..a2a5e6880 100644 --- a/resources/site-packages/quasar/daemon.py +++ b/resources/site-packages/quasar/daemon.py @@ -99,20 +99,34 @@ def clear_fd_inherit_flags(): if not windll.kernel32.SetHandleInformation(hd, HANDLE_FLAG_INHERIT, 0): log.error("Error clearing inherit flag, disk file handle %x" % hd) -def start_quasard(**kwargs): - # Make sure all other quasard instances are closed - shutdown() - +def jsonrpc_enabled(notify=False): try: s = socket.socket() s.connect(('127.0.0.1', 9090)) s.close() del s + return True except Exception as e: log.error(repr(e)) - dialog = xbmcgui.Dialog() - dialog.ok("Quasar", getLocalizedString(30199)) - return False + if notify: + dialog = xbmcgui.Dialog() + dialog.ok("Quasar", getLocalizedString(30199)) + return False + +def start_quasard(**kwargs): + # Make sure all other quasard instances are closed + shutdown() + + jsonrpc_failures = 0 + while jsonrpc_enabled() is False: + jsonrpc_failures += 1 + if jsonrpc_failures > 1: + time.sleep(5) + if not jsonrpc_enabled(True): + return False + else: + break + time.sleep(3) quasar_dir, quasar_binary = get_quasar_binary()