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 000000000..b4d00d2f2
Binary files /dev/null and b/app.icns differ
diff --git a/lbrynet/core/LBRYcrdWallet.py b/lbrynet/core/LBRYcrdWallet.py
index 8869a319d..46279a2e4 100644
--- a/lbrynet/core/LBRYcrdWallet.py
+++ b/lbrynet/core/LBRYcrdWallet.py
@@ -1006,7 +1006,7 @@ class LBRYumWallet(LBRYWallet):
return defer.succeed(Decimal(self.wallet.get_addr_received(address))/COIN)
def get_nametrie(self):
- cmd = known_commands['getnametrie']
+ cmd = known_commands['getclaimtrie']
func = getattr(self.cmd_runner, cmd.name)
return threads.deferToThread(func)
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/LBRYDaemon.py b/lbrynet/lbrynet_daemon/LBRYDaemon.py
index 678282da7..1e68f0f76 100644
--- a/lbrynet/lbrynet_daemon/LBRYDaemon.py
+++ b/lbrynet/lbrynet_daemon/LBRYDaemon.py
@@ -1,3 +1,24 @@
+import locale
+import os
+import sys
+import json
+import binascii
+import webbrowser
+import xmlrpclib
+import subprocess
+import logging
+import argparse
+import pwd
+import requests
+
+from twisted.web import xmlrpc, server
+from twisted.internet import defer, threads, reactor, error
+from datetime import datetime
+from decimal import Decimal
+from StringIO import StringIO
+from zipfile import ZipFile
+from urllib import urlopen
+
from lbrynet.core.PaymentRateManager import PaymentRateManager
from lbrynet.core.server.BlobAvailabilityHandler import BlobAvailabilityHandlerFactory
from lbrynet.core.server.BlobRequestHandler import BlobRequestHandlerFactory
@@ -8,7 +29,6 @@ from lbrynet.lbryfile.StreamDescriptor import LBRYFileStreamType
from lbrynet.lbryfile.client.LBRYFileDownloader import LBRYFileSaverFactory, LBRYFileOpenerFactory
from lbrynet.lbryfile.client.LBRYFileOptions import add_lbry_file_to_sd_identifier
from lbrynet.lbrynet_daemon.LBRYDownloader import GetStream, FetcherDaemon
-# from lbrynet.lbrynet_daemon.LBRYOSXStatusBar import DaemonStatusBarApp
from lbrynet.lbrynet_daemon.LBRYPublisher import Publisher
from lbrynet.core.utils import generate_id
from lbrynet.lbrynet_console.LBRYSettings import LBRYSettings
@@ -16,21 +36,16 @@ from lbrynet.conf import MIN_BLOB_DATA_PAYMENT_RATE, DEFAULT_MAX_SEARCH_RESULTS,
from lbrynet.core.StreamDescriptor import StreamDescriptorIdentifier, download_sd_blob
from lbrynet.core.Session import LBRYSession
from lbrynet.core.PTCWallet import PTCWallet
-from lbrynet.core.LBRYcrdWallet import LBRYcrdWallet
+from lbrynet.core.LBRYcrdWallet import LBRYcrdWallet, LBRYumWallet
from lbrynet.lbryfilemanager.LBRYFileManager import LBRYFileManager
from lbrynet.lbryfile.LBRYFileMetadataManager import DBLBRYFileMetadataManager, TempLBRYFileMetadataManager
-from twisted.web import xmlrpc, server
-from twisted.internet import defer, threads, reactor, error
-from datetime import datetime
-from decimal import Decimal
-from StringIO import StringIO
-from zipfile import ZipFile
-from urllib import urlopen
-import os, sys, json, binascii, webbrowser, xmlrpclib, subprocess, logging
log = logging.getLogger(__name__)
+# logging.basicConfig(level=logging.DEBUG)
+
+
# TODO add login credentials in a conf file
# issues with delete:
@@ -46,8 +61,8 @@ class LBRYDaemon(xmlrpc.XMLRPC):
LBRYnet daemon
"""
- def setup(self):
- def _set_vars():
+ def setup(self, wallet_type, check_for_updates):
+ def _set_vars(wallet_type, check_for_updates):
self.fetcher = None
self.current_db_revision = 1
self.run_server = True
@@ -57,7 +72,6 @@ class LBRYDaemon(xmlrpc.XMLRPC):
self.db_dir = os.path.join(os.path.expanduser("~"), ".lbrynet")
else:
self.db_dir = os.path.join(os.path.expanduser("~"), "Library/Application Support/lbrynet")
- # self.status_app = DaemonStatusBarApp()
self.blobfile_dir = os.path.join(self.db_dir, "blobfiles")
self.peer_port = 3333
self.dht_node_port = 4444
@@ -93,10 +107,10 @@ class LBRYDaemon(xmlrpc.XMLRPC):
self.lbry_file_metadata_manager = None
self.lbry_file_manager = None
self.settings = LBRYSettings(self.db_dir)
- self.wallet_type = "lbrycrd"
+ self.wallet_type = wallet_type
+ self.check_for_updates = check_for_updates
self.lbrycrd_conf = os.path.join(self.wallet_dir, "lbrycrd.conf")
self.autofetcher_conf = os.path.join(self.wallet_dir, "autofetcher.conf")
- self.files = []
self.created_data_dir = False
if not os.path.exists(self.db_dir):
os.mkdir(self.db_dir)
@@ -106,6 +120,8 @@ class LBRYDaemon(xmlrpc.XMLRPC):
self.max_key_fee = DEFAULT_MAX_KEY_FEE
self.max_search_results = DEFAULT_MAX_SEARCH_RESULTS
self.restart_message = ""
+ self.startup_message = ""
+ self.announced_startup = False
self.search_timeout = 3.0
self.query_handlers = {}
@@ -117,11 +133,14 @@ class LBRYDaemon(xmlrpc.XMLRPC):
else:
print "Started LBRYnet daemon"
print "The daemon can be shut down by running 'stop-lbrynet-daemon' in a terminal"
+ log.info('[' + str(datetime.now()) + '] Started lbrynet-daemon')
return defer.succeed(None)
+ log.info('[' + str(datetime.now()) + '] Starting lbrynet-daemon')
+
d = defer.Deferred()
- d.addCallback(lambda _: _set_vars())
+ d.addCallback(lambda _: _set_vars(wallet_type, check_for_updates))
d.addCallback(lambda _: threads.deferToThread(self._setup_data_directory))
d.addCallback(lambda _: self._check_db_migration())
d.addCallback(lambda _: self._get_settings())
@@ -133,9 +152,8 @@ 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())
+ # d.addCallback(lambda _: self._update() if self.check_for_updates == "True" and sys.platform == "darwin"
+ # else defer.succeed(None))
d.addCallback(lambda _: self._setup_fetcher())
d.addCallback(lambda _: _disp_startup())
d.callback(None)
@@ -213,10 +231,9 @@ class LBRYDaemon(xmlrpc.XMLRPC):
d = _check_for_updater()
d.addCallback(lambda _: _update_lbrynet())
- d.addCallback(lambda _: _update_lbrycrdd())
- d.addCallback(lambda _: _update_lbryum())
+ d.addCallback(lambda _: _update_lbrycrdd() if self.wallet_type == 'lbrycrd' else _update_lbryum())
d.addCallback(lambda _: os.system("open /Applications/LBRY\ Updater.app &>/dev/null") if self.restart_message
- else defer.succeed(None))
+ else defer.succeed(None))
d.addCallbacks(lambda _: self._restart() if self.restart_message else defer.succeed(None))
return defer.succeed(None)
@@ -310,8 +327,6 @@ class LBRYDaemon(xmlrpc.XMLRPC):
d = self._stop_server()
if self.session is not None:
d.addCallback(lambda _: self.session.shut_down())
- # if self.status_app:
- # d.addCallback(lambda _: self.status_app.stop())
return d
def _update_settings(self):
@@ -397,6 +412,8 @@ class LBRYDaemon(xmlrpc.XMLRPC):
def get_wallet():
if self.wallet_type == "lbrycrd":
+ print "Using lbrycrd wallet"
+ log.info("Using lbrycrd wallet")
lbrycrdd_path = None
if self.start_lbrycrdd is True:
lbrycrdd_path = self.lbrycrdd_path
@@ -404,8 +421,17 @@ class LBRYDaemon(xmlrpc.XMLRPC):
lbrycrdd_path = self.default_lbrycrdd_path
d = defer.succeed(LBRYcrdWallet(self.db_dir, wallet_dir=self.wallet_dir, wallet_conf=self.lbrycrd_conf,
lbrycrdd_path=lbrycrdd_path))
- else:
+ elif self.wallet_type == "lbryum":
+ print "Using lbryum wallet"
+ log.info("Using lbryum wallet")
+ d = defer.succeed(LBRYumWallet(self.db_dir))
+ elif self.wallet_type == "ptc":
+ print "Using PTC wallet"
+ log.info("Using PTC wallet")
d = defer.succeed(PTCWallet(self.db_dir))
+ else:
+ d = defer.fail()
+
d.addCallback(lambda wallet: {"wallet": wallet})
return d
@@ -429,8 +455,45 @@ class LBRYDaemon(xmlrpc.XMLRPC):
dl.addCallback(combine_results)
dl.addCallback(create_session)
dl.addCallback(lambda _: self.session.setup())
+ dl.addCallback(lambda _: self._check_first_run())
+ dl.addCallback(self._show_first_run_result)
return dl
+ def _check_first_run(self):
+ d = self.session.wallet.check_first_run()
+ d.addCallback(lambda is_first_run: self._do_first_run() if is_first_run else 0.0)
+ return d
+
+ def _do_first_run(self):
+ d = self.session.wallet.get_new_address()
+
+ def send_request(url, data):
+ r = requests.post(url, json=data)
+ if r.status_code == 200:
+ return r.json()['credits_sent']
+ return 0.0
+
+ def log_error(err):
+ log.warning("unable to request free credits. %s", err.getErrorMessage())
+ return 0.0
+
+ def request_credits(address):
+ url = "http://credreq.lbry.io/requestcredits"
+ data = {"address": address}
+ d = threads.deferToThread(send_request, url, data)
+ d.addErrback(log_error)
+ return d
+
+ d.addCallback(request_credits)
+ return d
+
+ def _show_first_run_result(self, credits_received):
+ if credits_received != 0.0:
+ points_string = locale.format_string("%.2f LBC", (round(credits_received, 2),), grouping=True)
+ self.startup_message = "Thank you for testing the alpha version of LBRY! You have been given %s for free because we love you. Please give them a few minutes to show up while you catch up with our blockchain." % points_string
+ else:
+ self.startup_message = "Connected to LBRYnet"
+
def _get_lbrycrdd_path(self):
def get_lbrycrdd_path_conf_file():
lbrycrdd_path_conf_path = os.path.join(os.path.expanduser("~"), ".lbrycrddpath.conf")
@@ -530,9 +593,11 @@ class LBRYDaemon(xmlrpc.XMLRPC):
path = os.path.join(self.blobfile_dir, stream_hash)
if os.path.isfile(path):
print "[" + str(datetime.now()) + "] Search for lbry_file, returning: " + stream_hash
+ log.info("[" + str(datetime.now()) + "] Search for lbry_file, returning: " + stream_hash)
return defer.succeed(_get_lbry_file(path))
else:
print "[" + str(datetime.now()) + "] Search for lbry_file didn't return anything"
+ log.info("[" + str(datetime.now()) + "] Search for lbry_file didn't return anything")
return defer.succeed(False)
d = self._resolve_name(name)
@@ -578,8 +643,10 @@ class LBRYDaemon(xmlrpc.XMLRPC):
def _check_est(d, name):
if type(d.result) is float:
print '[' + str(datetime.now()) + '] Cost est for lbry://' + name + ': ' + str(d.result) + 'LBC'
+ log.info('[' + str(datetime.now()) + '] Cost est for lbry://' + name + ': ' + str(d.result) + 'LBC')
else:
print '[' + str(datetime.now()) + '] Timeout estimating cost for lbry://' + name + ', using key fee'
+ log.info('[' + str(datetime.now()) + '] Timeout estimating cost for lbry://' + name + ', using key fee')
d.cancel()
return defer.succeed(None)
@@ -601,7 +668,14 @@ class LBRYDaemon(xmlrpc.XMLRPC):
return d
def xmlrpc_is_running(self):
- return True
+ if self.startup_message != "" and self.announced_startup == False:
+ print "Startup message:", self.startup_message
+ self.announced_startup = True
+ return self.startup_message
+ elif self.announced_startup:
+ return True
+ else:
+ return False
def xmlrpc_get_settings(self):
"""
@@ -636,6 +710,7 @@ class LBRYDaemon(xmlrpc.XMLRPC):
self.fetcher.start()
print '[' + str(datetime.now()) + '] Start autofetcher'
+ log.info('[' + str(datetime.now()) + '] Start autofetcher')
return 'Started autofetching'
def xmlrpc_stop_fetcher(self):
@@ -645,6 +720,7 @@ class LBRYDaemon(xmlrpc.XMLRPC):
self.fetcher.stop()
print '[' + str(datetime.now()) + '] Stop autofetcher'
+ log.info('[' + str(datetime.now()) + '] Stop autofetcher')
return 'Stopped autofetching'
def xmlrpc_fetcher_status(self):
@@ -669,6 +745,7 @@ class LBRYDaemon(xmlrpc.XMLRPC):
"""
def _disp_shutdown():
+ log.info('Shutting down lbrynet daemon')
print 'Shutting down lbrynet daemon'
d = self._shutdown()
@@ -711,7 +788,6 @@ class LBRYDaemon(xmlrpc.XMLRPC):
"""
def _disp(info):
- log.debug('[' + str(datetime.now()) + ']' + ' Resolved info: ' + str(info['stream_hash']))
print '[' + str(datetime.now()) + ']' + ' Resolved info: ' + str(info['stream_hash'])
return info
@@ -782,6 +858,7 @@ class LBRYDaemon(xmlrpc.XMLRPC):
d = defer.Deferred()
d.addCallback(lambda _: _make_file(html, path))
+ d.addCallback(lambda _: os.chown(path, pwd.getpwuid(os.getuid()).pw_uid, pwd.getpwuid(os.getuid()).pw_gid))
d.addCallback(lambda _: webbrowser.open('file://' + path))
d.addErrback(_disp_err)
d.callback(None)
@@ -813,13 +890,6 @@ class LBRYDaemon(xmlrpc.XMLRPC):
@return:
"""
- #def _return_d(x):
- # d = defer.Deferred()
- # d.addCallback(lambda _: x)
- # d.callback(None)
-
- # return d
-
def _clean(n):
t = []
for i in n:
@@ -861,9 +931,13 @@ class LBRYDaemon(xmlrpc.XMLRPC):
def _disp(results):
print '[' + str(datetime.now()) + '] Found ' + str(len(results)) + ' results'
+ log.info('[' + str(datetime.now()) + '] Search results: ')
+ for r in results:
+ log.info(str(r))
return results
print '[' + str(datetime.now()) + '] Search nametrie: ' + search
+ log.info('[' + str(datetime.now()) + '] Search nametrie: ' + search)
d = self.session.wallet.get_nametrie()
d.addCallback(lambda trie: [claim for claim in trie if claim['name'].startswith(search) and 'txid' in claim])
@@ -944,6 +1018,9 @@ class LBRYDaemon(xmlrpc.XMLRPC):
else:
content_license = None
+ log.info('[' + str(datetime.now()) + '] Publish: ', name, file_path, bid, title, description, thumbnail,
+ key_fee, key_fee_address, content_license)
+
p = Publisher(self.session, self.lbry_file_manager, self.session.wallet)
d = p.start(name, file_path, bid, title, description, thumbnail, key_fee, key_fee_address, content_license)
@@ -981,6 +1058,15 @@ class LBRYDaemon(xmlrpc.XMLRPC):
return d
+ def xmlrpc_get_new_address(self):
+ def _disp(address):
+ print "[" + str(datetime.now()) + "] Got new wallet address: " + address
+ return address
+
+ d = self.session.wallet.get_new_address()
+ d.addCallback(_disp)
+ return d
+
# def xmlrpc_update_name(self, metadata):
# def _disp(x):
# print x
@@ -1010,49 +1096,94 @@ class LBRYDaemon(xmlrpc.XMLRPC):
return self.fetcher.verbose
def xmlrpc_check_for_new_version(self):
- message = ""
+ def _check_for_updates(package):
+ git_version = subprocess.check_output("git ls-remote " + package['git'] + " | grep HEAD | cut -f 1", shell=True)
+ up_to_date = False
+ if os.path.isfile(package['version_file']):
+ f = open(package['version_file'], 'r')
+ current_version = f.read()
+ f.close()
- git_version = subprocess.check_output("git ls-remote https://github.com/lbryio/lbry.git | grep HEAD | cut -f 1", shell=True)
- if os.path.isfile(os.path.join(self.db_dir, "lbrynet_version.txt")):
- f = open(os.path.join(self.db_dir, "lbrynet_version.txt"), 'r')
- current_version = f.read()
- f.close()
-
- if git_version == current_version:
- message += "LBRYnet is up to date\n"
+ if git_version == current_version:
+ r = package['name'] + " is up to date"
+ up_to_date = True
+ else:
+ r = package['name'] + " version is out of date"
else:
- message += "LBRYnet version is out of date, restart the daemon to update\n"
- else:
- message += "Unknown version of LBRYnet, try running installer again\n"
+ r = "Unknown version of " + package['name']
- git_version = subprocess.check_output("git ls-remote https://github.com/jackrobison/lbrynet-app.git | grep HEAD | cut -f 1", shell=True)
- if os.path.isfile(os.path.join(self.wallet_dir, "lbry_app_version.txt")):
- f = open(os.path.join(self.wallet_dir, "lbry_app_version.txt"), 'r')
- current_version = f.read()
- f.close()
+ return (up_to_date, r)
- if git_version == current_version:
- message += "LBRY is up to date"
+ package_infos = {
+ "lbrynet": {"name": "LBRYnet",
+ "git": "https://github.com/lbryio/lbry.git",
+ "version_file": os.path.join(self.db_dir, ".lbrynet_version"),
+ "clone": ".lbrygit",
+ },
+ "lbryum": {"name": "lbryum",
+ "git": "https://github.com/lbryio/lbryum.git",
+ "version_file": os.path.join(self.db_dir, ".lbryum_version"),
+ "clone": ".lbryumgit",
+ },
+ "lbry": {"name": "LBRY",
+ "git": "https://github.com/jackrobison/lbrynet-app.git",
+ "version_file": os.path.join(self.db_dir, ".lbry_app_version"),
+ "clone": None,
+ },
+ }
+
+ return [_check_for_updates(package_infos[p]) for p in package_infos.keys()]
+
+ def xmlrpc_start_status_bar_app(self):
+ if sys.platform == 'darwin':
+ if os.path.isdir("/Applications/LBRY.app"):
+ # subprocess.Popen("screen -dmS lbry-status bash -c 'lbrynet-daemon-status --startdaemon=False'", shell=True)
+ subprocess.Popen("screen -dmS lbry-status bash -c 'open /Applications/LBRY.app'")
+ return "Started"
else:
- message += "LBRY version is out of date, restart the daemon to update"
+ return "Couldn't find LBRY.app, try running the installer"
else:
- message += "Unknown version of LBRYnet, try running installer again\n"
+ return "Status bar not implemented on non OS X"
- return message
+
+def stop():
+ daemon = xmlrpclib.ServerProxy("http://localhost:7080/")
+ try:
+ status = daemon.is_running()
+ except:
+ status = False
+
+ if status:
+ daemon.stop()
+ print "LBRYnet daemon stopped"
+ else:
+ print "LBRYnet daemon wasn't running"
def main():
+ parser = argparse.ArgumentParser(description="Launch lbrynet-daemon")
+ parser.add_argument("--wallet",
+ help="lbrycrd or lbryum, default lbryum",
+ type=str,
+ default="lbryum")
+ parser.add_argument("--update",
+ help="True or false, default true",
+ type=str,
+ default="True")
+
+ args = parser.parse_args()
+
try:
- d = xmlrpclib.ServerProxy('http://localhost:7080')
- d.stop()
+ daemon = xmlrpclib.ServerProxy("http://localhost:7080")
+ daemon.stop()
except:
pass
daemon = LBRYDaemon()
- daemon.setup()
- reactor.listenTCP(7080, server.Site(daemon))
+ daemon.setup(args.wallet, args.update)
+ reactor.listenTCP(7080, server.Site(daemon), interface='localhost')
reactor.run()
-if __name__ == '__main__':
- main()
+if __name__ == '__main__':
+ main()
\ No newline at end of file
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/update_lbrynet.sh b/lbrynet/lbrynet_daemon/scripts/update_lbrynet.sh
index c35723a75..3ce6dd15b 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 -b development --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 -b development --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)
@@ -83,15 +128,15 @@ if [ -d "$lbrynet_directory" ]; then
echo "Downloading LBRYnet update"
- git clone --depth 1 https://github.com/lbryio/lbry.git &>/dev/null
+ git clone -b development --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
+ git clone -b development --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")