From 7756d12993e1a4df2bd066438e4c91ad3bb752c0 Mon Sep 17 00:00:00 2001 From: Jack Date: Thu, 17 Mar 2016 22:03:56 -0400 Subject: [PATCH 1/2] check if daemon is running before starting console --- lbrynet/lbrynet_console/LBRYConsole.py | 193 +++++++++++++------------ lbrynet/lbrynet_daemon/LBRYDaemon.py | 6 +- 2 files changed, 107 insertions(+), 92 deletions(-) diff --git a/lbrynet/lbrynet_console/LBRYConsole.py b/lbrynet/lbrynet_console/LBRYConsole.py index 7eeda8e7b..9e73a054b 100644 --- a/lbrynet/lbrynet_console/LBRYConsole.py +++ b/lbrynet/lbrynet_console/LBRYConsole.py @@ -5,9 +5,13 @@ import argparse import requests import locale import sys +import webbrowser + +from xmlrpclib import ServerProxy from yapsy.PluginManager import PluginManager from twisted.internet import defer, threads, stdio, task, error from twisted.python.failure import Failure + # from lbrynet.core.client.AutoDownloader import AutoFetcher from lbrynet.lbrynet_console.ConsoleControl import ConsoleControl from lbrynet.lbrynet_console.LBRYSettings import LBRYSettings @@ -508,109 +512,120 @@ class LBRYConsole(): def launch_lbry_console(): + try: + daemon = ServerProxy("http://localhost:7080") + daemon.is_running() - from twisted.internet import reactor + print "lbrynet-daemon is already running" + print "To use lbrynet-console first close the LBRY status bar app, " \ + "or run stop-lbrynet-daemon if you started it via command line" + print "" + print "Launching browser interface" - parser = argparse.ArgumentParser(description="Launch a lbrynet console") - parser.add_argument("--no_listen_peer", - help="Don't listen for incoming data connections.", - action="store_true") - parser.add_argument("--peer_port", - help="The port on which the console will listen for incoming data connections.", - type=int, default=3333) - parser.add_argument("--no_listen_dht", - help="Don't listen for incoming DHT connections.", - action="store_true") - parser.add_argument("--dht_node_port", - help="The port on which the console will listen for DHT connections.", - type=int, default=4444) - parser.add_argument("--wallet_type", - help="Either 'lbrycrd' or 'ptc' or 'lbryum'.", - type=str, default="lbrycrd") - parser.add_argument("--lbrycrd_wallet_dir", - help="The directory in which lbrycrd data will stored. Used if lbrycrdd is " - "launched by this application.") - parser.add_argument("--lbrycrd_wallet_conf", - help="The configuration file for the LBRYcrd wallet. Default: ~/.lbrycrd/lbrycrd.conf", - type=str) - parser.add_argument("--no_dht_bootstrap", - help="Don't try to connect to the DHT", - action="store_true") - parser.add_argument("--dht_bootstrap_host", - help="The hostname of a known DHT node, to be used to bootstrap into the DHT. " - "Must be used with --dht_bootstrap_port", - type=str, default='104.236.42.182') - parser.add_argument("--dht_bootstrap_port", - help="The port of a known DHT node, to be used to bootstrap into the DHT. Must " - "be used with --dht_bootstrap_host", - type=int, default=4000) - parser.add_argument("--disable_upnp", - help="Don't try to use UPnP to enable incoming connections through the firewall", - action="store_true") - parser.add_argument("--data_dir", - help=("The full path to the directory in which lbrynet data and metadata will be stored. " - "Default: ~/.lbrynet on linux, ~/Library/Application Support/lbrynet on OS X"), - type=str) - parser.add_argument("--lbrycrdd_path", - help="The path to lbrycrdd, which will be launched if it isn't running, unless " - "launching lbrycrdd is disabled by --disable_launch_lbrycrdd. By default, " - "the file ~/.lbrycrddpath.conf will be checked, and if no path is found " - "there, it will be ./lbrycrdd") - parser.add_argument("--disable_launch_lbrycrdd", - help="Don't launch lbrycrdd even if it's not running.") + webbrowser.open("lbry://lbry") - args = parser.parse_args() + except: + from twisted.internet import reactor - if args.no_dht_bootstrap: - bootstrap_nodes = [] - else: - bootstrap_nodes = [(args.dht_bootstrap_host, args.dht_bootstrap_port)] + parser = argparse.ArgumentParser(description="Launch a lbrynet console") + parser.add_argument("--no_listen_peer", + help="Don't listen for incoming data connections.", + action="store_true") + parser.add_argument("--peer_port", + help="The port on which the console will listen for incoming data connections.", + type=int, default=3333) + parser.add_argument("--no_listen_dht", + help="Don't listen for incoming DHT connections.", + action="store_true") + parser.add_argument("--dht_node_port", + help="The port on which the console will listen for DHT connections.", + type=int, default=4444) + parser.add_argument("--wallet_type", + help="Either 'lbrycrd' or 'ptc' or 'lbryum'.", + type=str, default="lbrycrd") + parser.add_argument("--lbrycrd_wallet_dir", + help="The directory in which lbrycrd data will stored. Used if lbrycrdd is " + "launched by this application.") + parser.add_argument("--lbrycrd_wallet_conf", + help="The configuration file for the LBRYcrd wallet. Default: ~/.lbrycrd/lbrycrd.conf", + type=str) + parser.add_argument("--no_dht_bootstrap", + help="Don't try to connect to the DHT", + action="store_true") + parser.add_argument("--dht_bootstrap_host", + help="The hostname of a known DHT node, to be used to bootstrap into the DHT. " + "Must be used with --dht_bootstrap_port", + type=str, default='104.236.42.182') + parser.add_argument("--dht_bootstrap_port", + help="The port of a known DHT node, to be used to bootstrap into the DHT. Must " + "be used with --dht_bootstrap_host", + type=int, default=4000) + parser.add_argument("--disable_upnp", + help="Don't try to use UPnP to enable incoming connections through the firewall", + action="store_true") + parser.add_argument("--data_dir", + help=("The full path to the directory in which lbrynet data and metadata will be stored. " + "Default: ~/.lbrynet on linux, ~/Library/Application Support/lbrynet on OS X"), + type=str) + parser.add_argument("--lbrycrdd_path", + help="The path to lbrycrdd, which will be launched if it isn't running, unless " + "launching lbrycrdd is disabled by --disable_launch_lbrycrdd. By default, " + "the file ~/.lbrycrddpath.conf will be checked, and if no path is found " + "there, it will be ./lbrycrdd") + parser.add_argument("--disable_launch_lbrycrdd", + help="Don't launch lbrycrdd even if it's not running.") - if args.no_listen_peer: - peer_port = None - else: - peer_port = args.peer_port + args = parser.parse_args() - if args.no_listen_dht: - dht_node_port = None - else: - dht_node_port = args.dht_node_port - - created_data_dir = False - if not args.data_dir: - if sys.platform == "darwin": - data_dir = os.path.join(os.path.expanduser("~"), "Library/Application Support/lbrynet") + if args.no_dht_bootstrap: + bootstrap_nodes = [] else: - data_dir = os.path.join(os.path.expanduser("~"), ".lbrynet") - else: - data_dir = args.data_dir - if not os.path.exists(data_dir): - os.mkdir(data_dir) - created_data_dir = True + bootstrap_nodes = [(args.dht_bootstrap_host, args.dht_bootstrap_port)] + if args.no_listen_peer: + peer_port = None + else: + peer_port = args.peer_port - log_format = "(%(asctime)s)[%(filename)s:%(lineno)s] %(funcName)s(): %(message)s" - formatter = logging.Formatter(log_format) + if args.no_listen_dht: + dht_node_port = None + else: + dht_node_port = args.dht_node_port - logger = logging.getLogger() - logger.setLevel(logging.DEBUG) - file_handler = logging.FileHandler(os.path.join(data_dir, "console.log")) - file_handler.setFormatter(formatter) - file_handler.addFilter(logging.Filter("lbrynet")) - logger.addHandler(file_handler) + created_data_dir = False + if not args.data_dir: + if sys.platform == "darwin": + data_dir = os.path.join(os.path.expanduser("~"), "Library/Application Support/lbrynet") + else: + data_dir = os.path.join(os.path.expanduser("~"), ".lbrynet") + else: + data_dir = args.data_dir + if not os.path.exists(data_dir): + os.mkdir(data_dir) + created_data_dir = True - console = LBRYConsole(peer_port, dht_node_port, bootstrap_nodes, wallet_type=args.wallet_type, - lbrycrd_conf=args.lbrycrd_wallet_conf, lbrycrd_dir=args.lbrycrd_wallet_dir, - use_upnp=not args.disable_upnp, data_dir=data_dir, - created_data_dir=created_data_dir, lbrycrdd_path=args.lbrycrdd_path, - start_lbrycrdd=not args.disable_launch_lbrycrdd) + log_format = "(%(asctime)s)[%(filename)s:%(lineno)s] %(funcName)s(): %(message)s" + formatter = logging.Formatter(log_format) - d = task.deferLater(reactor, 0, console.start) + logger = logging.getLogger() + logger.setLevel(logging.DEBUG) + file_handler = logging.FileHandler(os.path.join(data_dir, "console.log")) + file_handler.setFormatter(formatter) + file_handler.addFilter(logging.Filter("lbrynet")) + logger.addHandler(file_handler) - d.addErrback(lambda _: reactor.stop()) + console = LBRYConsole(peer_port, dht_node_port, bootstrap_nodes, wallet_type=args.wallet_type, + lbrycrd_conf=args.lbrycrd_wallet_conf, lbrycrd_dir=args.lbrycrd_wallet_dir, + use_upnp=not args.disable_upnp, data_dir=data_dir, + created_data_dir=created_data_dir, lbrycrdd_path=args.lbrycrdd_path, + start_lbrycrdd=not args.disable_launch_lbrycrdd) - reactor.addSystemEventTrigger('before', 'shutdown', console.shut_down) - reactor.run() + d = task.deferLater(reactor, 0, console.start) + + d.addErrback(lambda _: reactor.stop()) + + reactor.addSystemEventTrigger('before', 'shutdown', console.shut_down) + reactor.run() if __name__ == "__main__": launch_lbry_console() \ No newline at end of file diff --git a/lbrynet/lbrynet_daemon/LBRYDaemon.py b/lbrynet/lbrynet_daemon/LBRYDaemon.py index 678282da7..cc0d05138 100644 --- a/lbrynet/lbrynet_daemon/LBRYDaemon.py +++ b/lbrynet/lbrynet_daemon/LBRYDaemon.py @@ -133,9 +133,9 @@ class LBRYDaemon(xmlrpc.XMLRPC): d.addCallback(lambda _: self._setup_lbry_file_opener()) d.addCallback(lambda _: self._setup_query_handlers()) d.addCallback(lambda _: self._setup_server()) - if sys.platform == "darwin": - d.addCallback(lambda _: self._update()) - # d.addCallback(lambda _: self.status_app.run()) + # if sys.platform == "darwin": + # d.addCallback(lambda _: self._update()) + # d.addCallback(lambda _: self.status_app.run()) d.addCallback(lambda _: self._setup_fetcher()) d.addCallback(lambda _: _disp_startup()) d.callback(None) From e3225f712399bd8eaa64f0efcf97295e834ca0b3 Mon Sep 17 00:00:00 2001 From: Jack Date: Thu, 17 Mar 2016 22:50:15 -0400 Subject: [PATCH 2/2] add missing commits --- .gitignore | 6 + app.icns | Bin 0 -> 8362 bytes lbrynet/core/LBRYcrdWallet.py | 54 ++++++-- .../client/CryptStreamDownloader.py | 3 +- lbrynet/dht/encoding.py | 5 +- .../lbrynet_daemon/Apps/LBRYOSXStatusBar.py | 108 ++++++++++++++++ lbrynet/lbrynet_daemon/Apps/LBRYURIHandler.py | 52 ++++++++ lbrynet/lbrynet_daemon/Apps/__init__.py | 0 lbrynet/lbrynet_daemon/LBRYDaemonStopper.py | 19 --- lbrynet/lbrynet_daemon/LBRYOSXStatusBar.py | 15 --- .../LBRYURIHandler/LBRYURIHandler.py | 59 --------- .../LBRYURIHandler.app/Contents/Info.plist | 117 ------------------ .../lbrynet_daemon/LBRYURIHandler/setup.py | 19 --- .../lbrynet_daemon/scripts/restart_daemon.sh | 2 +- .../lbrynet_daemon/scripts/update_lbrynet.sh | 103 ++++++++------- setup.py | 36 +++--- setup_osx.py | 22 ++++ setup_uri_handler.py | 22 ++++ setup_win32.py | 7 +- tests/lbrynet_test_bot.py | 6 +- 20 files changed, 341 insertions(+), 314 deletions(-) create mode 100644 app.icns create mode 100644 lbrynet/lbrynet_daemon/Apps/LBRYOSXStatusBar.py create mode 100644 lbrynet/lbrynet_daemon/Apps/LBRYURIHandler.py create mode 100644 lbrynet/lbrynet_daemon/Apps/__init__.py delete mode 100644 lbrynet/lbrynet_daemon/LBRYDaemonStopper.py delete mode 100644 lbrynet/lbrynet_daemon/LBRYOSXStatusBar.py delete mode 100644 lbrynet/lbrynet_daemon/LBRYURIHandler/LBRYURIHandler.py delete mode 100644 lbrynet/lbrynet_daemon/LBRYURIHandler/dist/LBRYURIHandler.app/Contents/Info.plist delete mode 100644 lbrynet/lbrynet_daemon/LBRYURIHandler/setup.py create mode 100644 setup_osx.py create mode 100644 setup_uri_handler.py diff --git a/.gitignore b/.gitignore index 23ba8568c..819306a87 100644 --- a/.gitignore +++ b/.gitignore @@ -17,3 +17,9 @@ lbrynet.egg-info/PKG-INFO /build /dist + +*.so + +*.pem + +*.decTest diff --git a/app.icns b/app.icns new file mode 100644 index 0000000000000000000000000000000000000000..b4d00d2f26dc4f4221a0d3e93e988a15b0ada3b8 GIT binary patch literal 8362 zcmeHMX^^;-7s*c>T~rX2F#)n#eiv;zM+_U$%yH*`5yhGqf6(m#TYj-CUju3-fJkCv~Q4E zGH6N3P?DHRP(~~8n=Tp=HpFw=%nji{Jef2NJz)ZtVj8|#Bp<`RSs)-4B`S%kCMiU& z%_iC;G%IJ@n}lN7-9ky_3h1zGv{hS5pSw#UW?hjJ!opZpUJ6TCmOyXR5yBPL1`)R{ zjEc3LzMx!5Pzye*(YAaW-^=l7DT;_Kgw6No`9iZX)wc^mu|>fuh$sn+T0Es7iiG~0 z@U0N81YAk3FC$)FBEB-xvC5HdK`OT8yS-BJ+@g#+Qo7FC0t5?=FJrDNT{rLflAMy% zT)E!vku%#YDQyRHU6#h5T-yP)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L*3jTDQOe*t^Xc-)hqt};t0+AIndgtJ*OF&&_YB_L;5zxy^5}u9 z6mCXtJv27(&~&=3gqy@;kojdh_v133=s#Tk*)mctfuBD-CG1=LN_p`0CN#(Y)6IAi zGS4j!$A}j1!QHdJC=dV14tu8EkJ#OQ?8ag|1snU1JT0j`1BVay-%;5~&j0gBdEZ&% zx+Z?ia7JYxLB+BA=L^HJxzCkH-d{T*HmQ|(tQ;br)D`_(r20cAOm#h+al{6=-Wx-M zuO0z8NzFu4e~hD3nK6AQ^5&+aTi1lpF)f}k@Dt2f|KZ5MUZn14Udi3CvG>LD@VoiX el&uJ)evEhyjOWegnv?qRzoJO{%k@8qz<&eeHH)zT literal 0 HcmV?d00001 diff --git a/lbrynet/core/LBRYcrdWallet.py b/lbrynet/core/LBRYcrdWallet.py index be0a5a694..09bc1e7bc 100644 --- a/lbrynet/core/LBRYcrdWallet.py +++ b/lbrynet/core/LBRYcrdWallet.py @@ -294,7 +294,7 @@ class LBRYWallet(object): value = result['value'] try: value_dict = json.loads(value) - except ValueError: + except (ValueError, TypeError): return Failure(InvalidStreamInfoError(name)) known_fields = ['stream_hash', 'name', 'description', 'key_fee', 'key_fee_address', 'thumbnail', 'content_license'] @@ -395,7 +395,7 @@ class LBRYWallet(object): if 'name' in claim and str(claim['name']) == name and 'value' in claim: try: value_dict = json.loads(claim['value']) - except ValueError: + except (ValueError, TypeError): return None if 'stream_hash' in value_dict and str(value_dict['stream_hash']) == sd_hash: if 'is controlling' in claim and claim['is controlling']: @@ -835,6 +835,7 @@ class LBRYumWallet(LBRYWallet): self.wallet = None self.cmd_runner = None self.first_run = False + self.printed_retrieving_headers = False def _start(self): @@ -843,15 +844,20 @@ class LBRYumWallet(LBRYWallet): def setup_network(): self.config = SimpleConfig() self.network = Network(self.config) + alert.info("Starting the wallet...") return defer.succeed(self.network.start()) d = setup_network() def check_started(): if self.network.is_connecting(): + if not self.printed_retrieving_headers and self.network.blockchain.retrieving_headers: + alert.info("Running the wallet for the first time...this may take a moment.") + self.printed_retrieving_headers = True return False start_check.stop() if self.network.is_connected(): + alert.info("Wallet started.") network_start_d.callback(True) else: network_start_d.errback(ValueError("Failed to connect to network.")) @@ -917,7 +923,9 @@ class LBRYumWallet(LBRYWallet): return d def get_block(self, blockhash): - return defer.fail(NotImplementedError()) + cmd = known_commands['getblock'] + func = getattr(self.cmd_runner, cmd.name) + return threads.deferToThread(func, blockhash) def get_most_recent_blocktime(self): header = self.network.get_header(self.network.get_local_height()) @@ -930,7 +938,9 @@ class LBRYumWallet(LBRYWallet): return d def get_name_claims(self): - return defer.fail(NotImplementedError()) + cmd = known_commands['getnameclaims'] + func = getattr(self.cmd_runner, cmd.name) + return threads.deferToThread(func) def check_first_run(self): return defer.succeed(self.first_run) @@ -941,13 +951,38 @@ class LBRYumWallet(LBRYWallet): return threads.deferToThread(func, txid) def _send_name_claim(self, name, val, amount): - return defer.fail(NotImplementedError()) + def send_claim(address): + cmd = known_commands['claimname'] + func = getattr(self.cmd_runner, cmd.name) + return threads.deferToThread(func, address, amount, name, val) + d = self.get_new_address() + d.addCallback(send_claim) + d.addCallback(self._broadcast_transaction) + return d def _get_decoded_tx(self, raw_tx): - return defer.fail(NotImplementedError()) + tx = Transaction(raw_tx) + decoded_tx = {} + decoded_tx['vout'] = [] + for output in tx.outputs(): + out = {} + out['value'] = output[2] + decoded_tx['vout'].append(out) + return decoded_tx def _send_abandon(self, txid, address, amount): - return defer.fail(NotImplementedError()) + cmd = known_commands['abandonclaim'] + func = getattr(self.cmd_runner, cmd.name) + d = threads.deferToThread(func, txid, address, amount) + d.addCallback(self._broadcast_transaction) + return d + + def _broadcast_transaction(self, raw_tx): + cmd = known_commands['broadcast'] + func = getattr(self.cmd_runner, cmd.name) + d = threads.deferToThread(func, raw_tx) + d.addCallback(self._save_wallet) + return d def _do_send_many(self, payments_to_send): log.warning("Doing send many. payments to send: %s", str(payments_to_send)) @@ -970,6 +1005,11 @@ class LBRYumWallet(LBRYWallet): def _get_balance_for_address(self, address): return defer.succeed(Decimal(self.wallet.get_addr_received(address))/COIN) + def get_nametrie(self): + cmd = known_commands['getclaimtrie'] + func = getattr(self.cmd_runner, cmd.name) + return threads.deferToThread(func) + def _save_wallet(self, val): d = threads.deferToThread(self.wallet.storage.write) d.addCallback(lambda _: val) diff --git a/lbrynet/cryptstream/client/CryptStreamDownloader.py b/lbrynet/cryptstream/client/CryptStreamDownloader.py index 19a565f1f..e0091598f 100644 --- a/lbrynet/cryptstream/client/CryptStreamDownloader.py +++ b/lbrynet/cryptstream/client/CryptStreamDownloader.py @@ -96,8 +96,9 @@ class CryptStreamDownloader(object): self.starting = True self.completed = False self.finished_deferred = defer.Deferred() + fd = self.finished_deferred d = self._start() - d.addCallback(lambda _: self.finished_deferred) + d.addCallback(lambda _: fd) return d def stop(self, err=None): diff --git a/lbrynet/dht/encoding.py b/lbrynet/dht/encoding.py index a57747628..e0b42ee4f 100644 --- a/lbrynet/dht/encoding.py +++ b/lbrynet/dht/encoding.py @@ -99,7 +99,10 @@ class Bencode(Encoding): """ if len(data) == 0: raise DecodeError, 'Cannot decode empty string' - return self._decodeRecursive(data)[0] + try: + return self._decodeRecursive(data)[0] + except ValueError as e: + raise DecodeError, e.message @staticmethod def _decodeRecursive(data, startIndex=0): diff --git a/lbrynet/lbrynet_daemon/Apps/LBRYOSXStatusBar.py b/lbrynet/lbrynet_daemon/Apps/LBRYOSXStatusBar.py new file mode 100644 index 000000000..c55fed0d2 --- /dev/null +++ b/lbrynet/lbrynet_daemon/Apps/LBRYOSXStatusBar.py @@ -0,0 +1,108 @@ +import rumps +import xmlrpclib +import os +import webbrowser +import subprocess +import argparse + + +class DaemonStatusBarApp(rumps.App): + def __init__(self): + icon_path = 'app.icns' + if os.path.isfile(icon_path): + rumps.App.__init__(self, name="LBRY", icon=icon_path, quit_button=None, + menu=["Open", "Preferences", "View balance", "Quit"]) + else: + rumps.App.__init__(self, name="LBRY", title="LBRY", quit_button=None, + menu=["Open", "Preferences", "View balance", "Quit"]) + + @rumps.timer(1) + def alert_daemon_start(self): + daemon = xmlrpclib.ServerProxy("http://localhost:7080/") + try: + start_msg = daemon.is_running() + if isinstance(start_msg, str): + rumps.notification(title='LBRY', subtitle='', message=str(start_msg), sound=True) + update_info = daemon.check_for_new_version() + update_msg = "" + for p in update_info: + if not p[0]: + update_msg += p[1] + "\n" + if update_msg: + update_msg += "\n Try running the installer again to fix this" + rumps.notification(title='LBRY', subtitle='', message=update_msg, sound=True) + except: + pass + + @rumps.clicked('Open') + def get_ui(self): + daemon = xmlrpclib.ServerProxy("http://localhost:7080/") + try: + daemon.is_running() + webbrowser.open("lbry://lbry") + except: + try: + rumps.notification(title='LBRY', subtitle='', message="Couldn't connect to lbrynet daemon", sound=True) + except: + rumps.alert(title='LBRY', message="Couldn't connect to lbrynet daemon") + + @rumps.clicked("Preferences") + def prefs(self): + daemon = xmlrpclib.ServerProxy("http://localhost:7080/") + try: + daemon.is_running() + webbrowser.open("lbry://settings") + except: + rumps.notification(title='LBRY', subtitle='', message="Couldn't connect to lbrynet daemon", sound=True) + + @rumps.clicked("View balance") + def disp_balance(self): + daemon = xmlrpclib.ServerProxy("http://localhost:7080/") + try: + balance = daemon.get_balance() + r = round(float(balance), 2) + try: + rumps.notification(title='LBRY', subtitle='', message=str("Your balance is %.2f LBC" % r), sound=False) + except: + rumps.alert(title='LBRY', message=str("Your balance is %.2f LBC" % r)) + + except: + try: + rumps.notification(title='LBRY', subtitle='', message="Couldn't connect to lbrynet daemon", sound=True) + except: + rumps.alert(title='LBRY', message="Couldn't connect to lbrynet daemon") + + @rumps.clicked('Quit') + def clean_quit(self): + daemon = xmlrpclib.ServerProxy("http://localhost:7080/") + try: + daemon.stop() + except: + pass + rumps.quit_application() + + +def main(): + parser = argparse.ArgumentParser(description="Launch lbrynet status bar application") + parser.add_argument("--startdaemon", + help="true or false, default true", + type=str, + default="true") + args = parser.parse_args() + + if str(args.startdaemon).lower() == "true": + daemon = xmlrpclib.ServerProxy('http://localhost:7080') + try: + daemon.is_running() + except: + subprocess.Popen("screen -dmS lbrynet bash -c " + "'PYTHONPATH=$PYTHONPATH:`cat /Users/${USER}/Library/Application\ Support/lbrynet/.python_path`; " + "PATH=$PATH:`cat /Users/${USER}/Library/Application\ Support/lbrynet/.lbry_bin_path`; " + "lbrynet-daemon --update=False'", shell=True) + + status_app = DaemonStatusBarApp() + status_app.run() + + +if __name__ == '__main__': + main() \ No newline at end of file diff --git a/lbrynet/lbrynet_daemon/Apps/LBRYURIHandler.py b/lbrynet/lbrynet_daemon/Apps/LBRYURIHandler.py new file mode 100644 index 000000000..eea94cb94 --- /dev/null +++ b/lbrynet/lbrynet_daemon/Apps/LBRYURIHandler.py @@ -0,0 +1,52 @@ +import os +import json +import webbrowser +import xmlrpclib, sys + +def render_video(path): + r = r'
' + return r + + +def main(args): + if len(args) == 0: + args.append('lbry://wonderfullife') + + daemon = xmlrpclib.ServerProxy('http://localhost:7080/') + + try: + daemon.is_running() + + if len(args) > 1: + exit(1) + + if args[0][7:] == 'lbry': + daemon.render_gui() + + elif args[0][7:] == 'settings': + r = daemon.get_settings() + html = "" + json.dumps(r) + "" + daemon.render_html(html) + + else: + r = daemon.get(args[0][7:]) + path = r['path'] + if path[0] != '/': + path = '/' + path + + filename = os.path.basename(path) + extension = os.path.splitext(filename)[1] + + if extension in ['mp4', 'flv', 'mov']: + html = render_video(path) + daemon.render_html(html) + + else: + webbrowser.open('file://' + str(path)) + + except: + webbrowser.open('http://lbry.io/get') + + +if __name__ == "__main__": + main(sys.argv[1:]) diff --git a/lbrynet/lbrynet_daemon/Apps/__init__.py b/lbrynet/lbrynet_daemon/Apps/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/lbrynet/lbrynet_daemon/LBRYDaemonStopper.py b/lbrynet/lbrynet_daemon/LBRYDaemonStopper.py deleted file mode 100644 index 78d8597dd..000000000 --- a/lbrynet/lbrynet_daemon/LBRYDaemonStopper.py +++ /dev/null @@ -1,19 +0,0 @@ -import xmlrpclib - - -def main(): - daemon = xmlrpclib.ServerProxy("http://localhost:7080/") - try: - b = daemon.get_balance() - is_running = True - except: - is_running = False - - if is_running: - daemon.stop() - print "LBRYnet daemon stopped" - else: - print "LBRYnet daemon wasn't running" - -if __name__ == '__main__': - main() \ No newline at end of file diff --git a/lbrynet/lbrynet_daemon/LBRYOSXStatusBar.py b/lbrynet/lbrynet_daemon/LBRYOSXStatusBar.py deleted file mode 100644 index f5c9c0e32..000000000 --- a/lbrynet/lbrynet_daemon/LBRYOSXStatusBar.py +++ /dev/null @@ -1,15 +0,0 @@ -import rumps -import xmlrpclib -import os - -class DaemonStatusBarApp(rumps.App): - def __init__(self): - super(DaemonStatusBarApp, self).__init__("LBRYnet", icon=os.path.join(os.path.expanduser("~"), "Downloads/lbryio//web/img/fav/apple-touch-icon.png"), quit_button=None) - self.menu = ["Quit"] - - @rumps.clicked('Quit') - def clean_quit(self): - d = xmlrpclib.ServerProxy('http://localhost:7080') - d.stop() - rumps.quit_application() - diff --git a/lbrynet/lbrynet_daemon/LBRYURIHandler/LBRYURIHandler.py b/lbrynet/lbrynet_daemon/LBRYURIHandler/LBRYURIHandler.py deleted file mode 100644 index 62ded697b..000000000 --- a/lbrynet/lbrynet_daemon/LBRYURIHandler/LBRYURIHandler.py +++ /dev/null @@ -1,59 +0,0 @@ -import os -import json -import webbrowser -import xmlrpclib, sys - - -def render_video(path): - r = r'
' - return r - - -def main(args): - if len(args) == 0: - args.append('lbry://wonderfullife') - - daemon = xmlrpclib.ServerProxy('http://localhost:7080/') - - try: - balance = daemon.get_balance() - is_running = True - if len(args) > 1: - print 'Too many args', args - - elif is_running: - if args[0][7:] == 'lbry': - daemon.render_gui() - - elif args[0][7:] == 'settings': - r = daemon.get_settings() - html = "" + json.dumps(r) + "" - r = daemon.render_html(html) - else: - if float(balance) > 0.0: - r = daemon.get(args[0][7:]) - print r - path = r['path'] - if path[0] != '/': - path = '/' + path - - print path - filename = path.split('/')[len(path.split('/')) - 1] - extension = path.split('.')[len(path.split('.')) - 1] - - if extension in ['mp4', 'flv', 'mov']: - html = render_video(path) - daemon.render_html(html) - - else: - webbrowser.open('file://' + str(path)) - - except: - webbrowser.open('http://lbry.io/get') - is_running = False - - - - -if __name__ == "__main__": - main(sys.argv[1:]) diff --git a/lbrynet/lbrynet_daemon/LBRYURIHandler/dist/LBRYURIHandler.app/Contents/Info.plist b/lbrynet/lbrynet_daemon/LBRYURIHandler/dist/LBRYURIHandler.app/Contents/Info.plist deleted file mode 100644 index 4f5993ff1..000000000 --- a/lbrynet/lbrynet_daemon/LBRYURIHandler/dist/LBRYURIHandler.app/Contents/Info.plist +++ /dev/null @@ -1,117 +0,0 @@ - - - - - CFBundleDevelopmentRegion - English - CFBundleDisplayName - LBRYURIHandler - CFBundleDocumentTypes - - - CFBundleTypeOSTypes - - **** - fold - disk - - CFBundleTypeRole - Viewer - - - CFBundleExecutable - LBRYURIHandler - -CFBundleURLTypes - - - CFBundleURLName - LBRYURIHandler - CFBundleURLSchemes - - lbry - - - -NSUIElement - - - CFBundleIconFile - PythonApplet.icns - CFBundleIdentifier - org.pythonmac.unspecified.LBRYURIHandler - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - LBRYURIHandler - CFBundlePackageType - APPL - CFBundleShortVersionString - 0.0.0 - CFBundleSignature - ???? - CFBundleVersion - 0.0.0 - LSHasLocalizedDisplayName - - NSAppleScriptEnabled - - NSHumanReadableCopyright - Copyright not specified - NSMainNibFile - MainMenu - NSPrincipalClass - NSApplication - PyMainFileNames - - __boot__ - - PyOptions - - alias - - argv_emulation - - emulate_shell_environment - - no_chdir - - prefer_ppc - - site_packages - - use_faulthandler - - use_pythonpath - - verbose - - - PyResourcePackages - - - PyRuntimeLocations - - @executable_path/../Frameworks/Python.framework/Versions/2.7/Python - - PythonInfoDict - - PythonExecutable - /Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python - PythonLongVersion - 2.7.10 (v2.7.10:15c95b7d81dc, May 23 2015, 09:33:12) -[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] - PythonShortVersion - 2.7 - py2app - - alias - - template - app - version - 0.9 - - - - diff --git a/lbrynet/lbrynet_daemon/LBRYURIHandler/setup.py b/lbrynet/lbrynet_daemon/LBRYURIHandler/setup.py deleted file mode 100644 index fbb83f5dc..000000000 --- a/lbrynet/lbrynet_daemon/LBRYURIHandler/setup.py +++ /dev/null @@ -1,19 +0,0 @@ -""" -This is a setup.py script generated by py2applet - -Usage: - python setup.py py2app -""" - -from setuptools import setup - -APP = ['LBRYURIHandler.py'] -DATA_FILES = [] -OPTIONS = {'argv_emulation': True} - -setup( - app=APP, - data_files=DATA_FILES, - options={'py2app': OPTIONS}, - setup_requires=['py2app'], -) diff --git a/lbrynet/lbrynet_daemon/scripts/restart_daemon.sh b/lbrynet/lbrynet_daemon/scripts/restart_daemon.sh index 74d4ab102..7353c0a20 100644 --- a/lbrynet/lbrynet_daemon/scripts/restart_daemon.sh +++ b/lbrynet/lbrynet_daemon/scripts/restart_daemon.sh @@ -1,4 +1,4 @@ #!/bin/sh echo "Restarting lbrynet-daemon" -sudo lbrynet-daemon \ No newline at end of file +lbrynet-daemon \ No newline at end of file diff --git a/lbrynet/lbrynet_daemon/scripts/update_lbrynet.sh b/lbrynet/lbrynet_daemon/scripts/update_lbrynet.sh index c35723a75..fbb7d2b17 100755 --- a/lbrynet/lbrynet_daemon/scripts/update_lbrynet.sh +++ b/lbrynet/lbrynet_daemon/scripts/update_lbrynet.sh @@ -59,7 +59,7 @@ else fi if ! python -c "import six; exit(0) if six.__version__ == '1.9.0' else exit(1)" &>/dev/null; then - echo "Installing six 1.9.0 for python" + echo "Installing six 1.9.0 for python..." curl -O https://pypi.python.org/packages/source/s/six/six-1.9.0.tar.gz &>/dev/null tar xf six-1.9.0.tar.gz &>/dev/null cd six-1.9.0 @@ -70,6 +70,51 @@ if ! python -c "import six; exit(0) if six.__version__ == '1.9.0' else exit(1)" fi lbrynet_directory="/Users/${SUDO_USER}/Library/Application Support/lbrynet" +lbryum_current_version=$(git ls-remote https://github.com/lbryio/lbryum.git | grep HEAD | cut -f 1) + +if [ -d "$lbrynet_directory" ]; then + if [ -f "${lbrynet_directory}/lbryum_version.txt" ]; then + if grep -Fxq "$lbryum_current_version" "${lbrynet_directory}/lbryum_version.txt"; then + echo "LBRYum version $lbryum_current_version is up to date" + else + tmp=$(mktemp -d) + cd $tmp + + echo "Downloading LBRYum update..." + + git clone --depth 1 https://github.com/lbryio/lbryum.git &>/dev/null + cd lbryum + + echo "Installing update..." + sudo python setup.py install &>/dev/null + mkdir -p "$lbrynet_directory" + echo $lbryum_current_version > "${lbrynet_directory}/lbryum_version.txt" + + echo "Cleaning up..." + + cd ../../ + rm -rf $tmp + fi + else + tmp=$(mktemp -d) + cd $tmp + + echo "Downloading LBRYum..." + + git clone --depth 1 https://github.com/lbryio/lbryum.git &>/dev/null + cd lbryum + + echo "Installing..." + sudo python setup.py install &>/dev/null + mkdir -p "$lbrynet_directory" + echo $lbryum_current_version > "${lbrynet_directory}/lbryum_version.txt" + + echo "Cleaning up..." + + cd ../../ + rm -rf $tmp + fi +fi lbrynet_current_version=$(git ls-remote https://github.com/lbryio/lbry.git | grep HEAD | cut -f 1) @@ -86,12 +131,12 @@ if [ -d "$lbrynet_directory" ]; then git clone --depth 1 https://github.com/lbryio/lbry.git &>/dev/null cd lbry - echo "Installing update" + echo "Installing update..." sudo python setup.py install &>/dev/null mkdir -p "$lbrynet_directory" echo $lbrynet_current_version > "${lbrynet_directory}/lbrynet_version.txt" - echo "Cleaning up" + echo "Cleaning up..." cd ../../ rm -rf $tmp @@ -100,63 +145,17 @@ if [ -d "$lbrynet_directory" ]; then tmp=$(mktemp -d) cd $tmp - echo "Downloading LBRYnet update" + echo "Downloading LBRYnet..." git clone --depth 1 https://github.com/lbryio/lbry.git &>/dev/null cd lbry - echo "Installing update" + echo "Installing..." sudo python setup.py install &>/dev/null mkdir -p "$lbrynet_directory" echo $lbrynet_current_version > "${lbrynet_directory}/lbrynet_version.txt" - echo "Cleaning up" - - cd ../../ - rm -rf $tmp - fi -fi - -lbryum_current_version=$(git ls-remote https://github.com/lbryio/lbryum.git | grep HEAD | cut -f 1) - -if [ -d "$lbrynet_directory" ]; then - if [ -f "${lbrynet_directory}/lbryum_version.txt" ]; then - if grep -Fxq "$lbryum_current_version" "${lbrynet_directory}/lbryum_version.txt"; then - echo "LBRYum version $lbryum_current_version is up to date" - else - tmp=$(mktemp -d) - cd $tmp - - echo "Downloading LBRYum update" - - git clone --depth 1 https://github.com/lbryio/lbryum.git &>/dev/null - cd lbryum - - echo "Installing update" - sudo python setup.py install &>/dev/null - mkdir -p "$lbrynet_directory" - echo $lbryum_current_version > "${lbrynet_directory}/lbryum_version.txt" - - echo "Cleaning up" - - cd ../../ - rm -rf $tmp - fi - else - tmp=$(mktemp -d) - cd $tmp - - echo "Downloading LBRYum update" - - git clone --depth 1 https://github.com/lbryio/lbryum.git &>/dev/null - cd lbryum - - echo "Installing update" - sudo python setup.py install &>/dev/null - mkdir -p "$lbrynet_directory" - echo $lbryum_current_version > "${lbrynet_directory}/lbryum_version.txt" - - echo "Cleaning up" + echo "Cleaning up..." cd ../../ rm -rf $tmp diff --git a/setup.py b/setup.py index 7c3cfa358..68d476243 100644 --- a/setup.py +++ b/setup.py @@ -2,29 +2,31 @@ import ez_setup ez_setup.use_setuptools() - from setuptools import setup, find_packages +import sys + +console_scripts = ['lbrynet-console = lbrynet.lbrynet_console.LBRYConsole:launch_lbry_console', + 'lbrynet-stdin-uploader = lbrynet.lbrynet_console.LBRYStdinUploader:launch_stdin_uploader', + 'lbrynet-stdout-downloader = lbrynet.lbrynet_console.LBRYStdoutDownloader:launch_stdout_downloader', + 'lbrynet-create-network = lbrynet.create_network:main', + 'lbrynet-launch-node = lbrynet.dht.node:main', + 'lbrynet-launch-rpc-node = lbrynet.rpc_node:main', + 'lbrynet-rpc-node-cli = lbrynet.node_rpc_cli:main', + 'lbrynet-gui = lbrynet.lbrynet_gui.gui:start_gui', + 'lbrynet-lookup-hosts-for-hash = lbrynet.dht_scripts:get_hosts_for_hash_in_dht', + 'lbrynet-announce_hash_to_dht = lbrynet.dht_scripts:announce_hash_to_dht', + 'lbrynet-daemon = lbrynet.lbrynet_daemon.LBRYDaemon:main', + 'stop-lbrynet-daemon = lbrynet.lbrynet_daemon.LBRYDaemon:stop'] + +if sys.platform == 'darwin': + console_scripts.append('lbrynet-daemon-status = lbrynet.lbrynet_daemon.LBRYOSXStatusBar:main') + setup(name='lbrynet', version='0.0.4', packages=find_packages(), install_requires=['six>=1.9.0', 'pycrypto', 'twisted', 'miniupnpc', 'yapsy', 'seccure', 'python-bitcoinrpc==0.1', 'txJSON-RPC', 'requests>=2.4.2', 'unqlite==0.2.0', 'leveldb', 'lbryum'], - entry_points={ - 'console_scripts': [ - 'lbrynet-console = lbrynet.lbrynet_console.LBRYConsole:launch_lbry_console', - 'lbrynet-stdin-uploader = lbrynet.lbrynet_console.LBRYStdinUploader:launch_stdin_uploader', - 'lbrynet-stdout-downloader = lbrynet.lbrynet_console.LBRYStdoutDownloader:launch_stdout_downloader', - 'lbrynet-create-network = lbrynet.create_network:main', - 'lbrynet-launch-node = lbrynet.dht.node:main', - 'lbrynet-launch-rpc-node = lbrynet.rpc_node:main', - 'lbrynet-rpc-node-cli = lbrynet.node_rpc_cli:main', - 'lbrynet-gui = lbrynet.lbrynet_gui.gui:start_gui', - 'lbrynet-lookup-hosts-for-hash = lbrynet.dht_scripts:get_hosts_for_hash_in_dht', - 'lbrynet-announce_hash_to_dht = lbrynet.dht_scripts:announce_hash_to_dht', - 'lbrynet-daemon = lbrynet.lbrynet_daemon.LBRYDaemon:main', - 'stop-lbrynet-daemon = lbrynet.lbrynet_daemon.LBRYDaemonStopper:main', - ] - }, + entry_points={'console_scripts': console_scripts}, data_files=[ ('lbrynet/lbrynet_console/plugins', [ diff --git a/setup_osx.py b/setup_osx.py new file mode 100644 index 000000000..052b51235 --- /dev/null +++ b/setup_osx.py @@ -0,0 +1,22 @@ +import os +from setuptools import setup + +APP = [os.path.join('lbrynet', 'lbrynet_daemon', 'Apps', 'LBRYOSXStatusBar.py')] +DATA_FILES = [] +OPTIONS = { + 'argv_emulation': True, + 'iconfile': 'app.icns', + 'plist': { + 'LSUIElement': True, + }, + 'includes': ['rumps'] +} + + +setup( + name='LBRY', + app=APP, + data_files=DATA_FILES, + options={'py2app': OPTIONS}, + setup_requires=['py2app'], +) \ No newline at end of file diff --git a/setup_uri_handler.py b/setup_uri_handler.py new file mode 100644 index 000000000..37a38826e --- /dev/null +++ b/setup_uri_handler.py @@ -0,0 +1,22 @@ +from setuptools import setup +import os + +APP = [os.path.join('lbrynet', 'lbrynet_daemon', 'Apps', 'LBRYURIHandler.py')] +DATA_FILES = [] +OPTIONS = {'argv_emulation': True, + 'plist': { + 'CFBundleURLTypes': [ + { + 'CFBundleURLTypes': 'LBRYURIHandler', + 'CFBundleURLSchemes': ['lbry'] + } + ] + } + } + +setup( + app=APP, + data_files=DATA_FILES, + options={'py2app': OPTIONS}, + setup_requires=['py2app'], +) \ No newline at end of file diff --git a/setup_win32.py b/setup_win32.py index b414606a7..1fc0f0d58 100644 --- a/setup_win32.py +++ b/setup_win32.py @@ -7,7 +7,7 @@ import os import sys from cx_Freeze import setup, Executable - +import requests.certs def find_data_file(filename): if getattr(sys, 'frozen', False): @@ -48,9 +48,9 @@ bdist_msi_options = { build_exe_options = { 'include_msvcr': True, 'includes': [], - 'packages': ['os', 'twisted', 'miniupnpc', 'unqlite', 'seccure', + 'packages': ['six', 'os', 'twisted', 'miniupnpc', 'unqlite', 'seccure', 'requests', 'bitcoinrpc', 'txjsonrpc', 'win32api', 'Crypto', - 'gmpy', 'yapsy'], + 'gmpy', 'yapsy', 'lbryum', 'google.protobuf'], 'excludes': ['zope.interface._zope_interface_coptimizations'], 'include_files': [os.path.join('lbrynet', 'lbrynet_gui', 'close.gif'), os.path.join('lbrynet', 'lbrynet_gui', 'close1.png'), @@ -63,6 +63,7 @@ build_exe_options = { os.path.join('lbrynet', 'lbrynet_gui', 'show_options.gif'), os.path.join('lbrycrdd.exe'), # Not included in repo os.path.join('lbrycrd-cli.exe'), # Not included in repo + (requests.certs.where(), 'cacert.pem'), ], 'namespace_packages': ['zope']} diff --git a/tests/lbrynet_test_bot.py b/tests/lbrynet_test_bot.py index a76a366d8..46e5d9f0a 100644 --- a/tests/lbrynet_test_bot.py +++ b/tests/lbrynet_test_bot.py @@ -7,9 +7,8 @@ from slackclient import SlackClient def get_conf(): f = open('testbot.conf', 'r') token = f.readline().replace('\n', '') - channel = f.readline().replace('\n', '') f.close() - return token, channel + return token def test_lbrynet(lbry, slack, channel): logfile = open('lbrynet_test_log.txt', 'a') @@ -48,10 +47,11 @@ def test_lbrynet(lbry, slack, channel): lbry.delete_lbry_file('test.jpg') logfile.close() -token, channel = get_conf() +token = get_conf() sc = SlackClient(token) sc.rtm_connect() +channel = [c['id'] for c in json.loads(sc.api_call('channels.list'))['channels'] if c['name'] == 'tech'][0] print 'Connected to slack' daemon = xmlrpclib.ServerProxy("http://localhost:7080")