Skip to content

Commit

Permalink
retry checking if Kodi's JSON-RPC is enabled, fixes #712
Browse files Browse the repository at this point in the history
  • Loading branch information
scakemyer committed Feb 11, 2017
1 parent ac5191a commit 07687b0
Showing 1 changed file with 21 additions and 7 deletions.
28 changes: 21 additions & 7 deletions resources/site-packages/quasar/daemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down

0 comments on commit 07687b0

Please sign in to comment.