forked from LBRYCommunity/lbry-sdk
add bundle identifier to uri handler
This commit is contained in:
parent
2d07223995
commit
b3cf5e8698
2 changed files with 14 additions and 5 deletions
|
@ -1,16 +1,24 @@
|
||||||
import os
|
import os
|
||||||
import json
|
import json
|
||||||
import webbrowser
|
import webbrowser
|
||||||
import sys
|
|
||||||
from time import sleep
|
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import sys
|
||||||
|
|
||||||
|
from time import sleep
|
||||||
from jsonrpc.proxy import JSONRPCProxy
|
from jsonrpc.proxy import JSONRPCProxy
|
||||||
|
|
||||||
API_CONNECTION_STRING = "http://localhost:5279/lbryapi"
|
API_CONNECTION_STRING = "http://localhost:5279/lbryapi"
|
||||||
UI_ADDRESS = "http://localhost:5279"
|
UI_ADDRESS = "http://localhost:5279"
|
||||||
|
|
||||||
|
|
||||||
|
class Timeout(Exception):
|
||||||
|
def __init__(self, value):
|
||||||
|
self.parameter = value
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return repr(self.parameter)
|
||||||
|
|
||||||
|
|
||||||
class LBRYURIHandler(object):
|
class LBRYURIHandler(object):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.started_daemon = False
|
self.started_daemon = False
|
||||||
|
@ -28,18 +36,18 @@ class LBRYURIHandler(object):
|
||||||
elif status:
|
elif status:
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
exit(1)
|
raise Timeout("LBRY daemon is running, but connection timed out")
|
||||||
except:
|
except:
|
||||||
if self.start_timeout < 30:
|
if self.start_timeout < 30:
|
||||||
sleep(1)
|
sleep(1)
|
||||||
self.start_timeout += 1
|
self.start_timeout += 1
|
||||||
self.check_status()
|
self.check_status()
|
||||||
else:
|
else:
|
||||||
exit(1)
|
raise Timeout("Timed out trying to start LBRY daemon")
|
||||||
|
|
||||||
def handle(self, lbry_name):
|
def handle(self, lbry_name):
|
||||||
lbry_process = [d for d in subprocess.Popen(['ps','aux'], stdout=subprocess.PIPE).stdout.readlines()
|
lbry_process = [d for d in subprocess.Popen(['ps','aux'], stdout=subprocess.PIPE).stdout.readlines()
|
||||||
if 'LBRY.app' in d]
|
if 'LBRY.app' in d and 'LBRYURIHandler' not in d]
|
||||||
try:
|
try:
|
||||||
status = json.loads(self.daemon.is_running())['result']
|
status = json.loads(self.daemon.is_running())['result']
|
||||||
except:
|
except:
|
||||||
|
|
|
@ -7,6 +7,7 @@ OPTIONS = {'argv_emulation': True,
|
||||||
'packages': ['jsonrpc'],
|
'packages': ['jsonrpc'],
|
||||||
'plist': {
|
'plist': {
|
||||||
'LSUIElement': True,
|
'LSUIElement': True,
|
||||||
|
'CFBundleIdentifier': 'io.lbry.LBRYURIHandler',
|
||||||
'CFBundleURLTypes': [
|
'CFBundleURLTypes': [
|
||||||
{
|
{
|
||||||
'CFBundleURLTypes': 'LBRYURIHandler',
|
'CFBundleURLTypes': 'LBRYURIHandler',
|
||||||
|
|
Loading…
Reference in a new issue