Merge pull request #27 from lbryio/development

merge updates from development into master
This commit is contained in:
Jack Robison 2016-04-16 01:15:50 -04:00
commit e1b4fe02d6
17 changed files with 1110 additions and 458 deletions

View file

@ -4,5 +4,5 @@ import logging
logging.getLogger(__name__).addHandler(logging.NullHandler()) logging.getLogger(__name__).addHandler(logging.NullHandler())
version = (0, 2, 0) version = (0, 2, 1)
__version__ = ".".join([str(x) for x in version]) __version__ = ".".join([str(x) for x in version])

View file

@ -70,6 +70,8 @@ class LBRYWallet(object):
self.max_expected_payment_time = datetime.timedelta(minutes=3) self.max_expected_payment_time = datetime.timedelta(minutes=3)
self.stopped = True self.stopped = True
self.is_lagging = None
self.manage_running = False self.manage_running = False
self._manage_count = 0 self._manage_count = 0
self._balance_refresh_time = 3 self._balance_refresh_time = 3
@ -365,7 +367,8 @@ class LBRYWallet(object):
value['content_license'] = content_license value['content_license'] = content_license
if author is not None: if author is not None:
value['author'] = author value['author'] = author
if sources is not None: if isinstance(sources, dict):
sources['lbry_sd_hash'] = sd_hash
value['sources'] = sources value['sources'] = sources
d = self._send_name_claim(name, json.dumps(value), amount) d = self._send_name_claim(name, json.dumps(value), amount)
@ -436,7 +439,8 @@ class LBRYWallet(object):
d.addCallback(set_first_run) d.addCallback(set_first_run)
else: else:
d = defer.succeed(None) d = defer.succeed(self._FIRST_RUN_YES if self._first_run else self._FIRST_RUN_NO)
d.addCallback(lambda _: self._first_run == self._FIRST_RUN_YES) d.addCallback(lambda _: self._first_run == self._FIRST_RUN_YES)
return d return d
@ -900,6 +904,9 @@ class LBRYumWallet(LBRYWallet):
self._start_check = None self._start_check = None
self._catch_up_check = None self._catch_up_check = None
self._caught_up_counter = 0 self._caught_up_counter = 0
self.blocks_behind_alert = 0
self.catchup_progress = 0
self.max_behind = 0
def _start(self): def _start(self):
@ -991,10 +998,18 @@ class LBRYumWallet(LBRYWallet):
self._catch_up_check = None self._catch_up_check = None
blockchain_caught_d.callback(True) blockchain_caught_d.callback(True)
elif remote_height != 0: elif remote_height != 0:
self.blocks_behind_alert = remote_height - local_height
if self.blocks_behind_alert > self.max_behind:
self.max_behind = self.blocks_behind_alert
self.catchup_progress = int(100 * (self.blocks_behind_alert / (5 + self.max_behind)))
if self._caught_up_counter == 0: if self._caught_up_counter == 0:
alert.info('Catching up to the blockchain...showing blocks left...') alert.info('Catching up to the blockchain...showing blocks left...')
if self._caught_up_counter % 30 == 0: if self._caught_up_counter % 30 == 0:
alert.info('%d...', (remote_height - local_height)) alert.info('%d...', (remote_height - local_height))
alert.info("Catching up: " + str(self.catchup_progress) + "%")
if self._caught_up_counter >= 600:
self.is_lagging = True
self._caught_up_counter += 1 self._caught_up_counter += 1
@ -1067,11 +1082,12 @@ class LBRYumWallet(LBRYWallet):
decoded_tx['vout'] = [] decoded_tx['vout'] = []
for output in tx.outputs(): for output in tx.outputs():
out = {} out = {}
out['value'] = output[2] out['value'] = Decimal(output[2]) / Decimal(COIN)
decoded_tx['vout'].append(out) decoded_tx['vout'].append(out)
return decoded_tx return decoded_tx
def _send_abandon(self, txid, address, amount): def _send_abandon(self, txid, address, amount):
log.info("Abandon " + str(txid) + " " + str(address) + " " + str(amount))
cmd = known_commands['abandonclaim'] cmd = known_commands['abandonclaim']
func = getattr(self.cmd_runner, cmd.name) func = getattr(self.cmd_runner, cmd.name)
d = threads.deferToThread(func, txid, address, amount) d = threads.deferToThread(func, txid, address, amount)
@ -1079,6 +1095,7 @@ class LBRYumWallet(LBRYWallet):
return d return d
def _broadcast_transaction(self, raw_tx): def _broadcast_transaction(self, raw_tx):
log.info("Broadcast: " + str(raw_tx))
cmd = known_commands['broadcast'] cmd = known_commands['broadcast']
func = getattr(self.cmd_runner, cmd.name) func = getattr(self.cmd_runner, cmd.name)
d = threads.deferToThread(func, raw_tx) d = threads.deferToThread(func, raw_tx)

View file

@ -119,7 +119,7 @@ class ManagedLBRYFileDownloaderFactory(object):
def can_download(self, sd_validator): def can_download(self, sd_validator):
return True return True
def make_downloader(self, metadata, options, payment_rate_manager): def make_downloader(self, metadata, options, payment_rate_manager, download_directory=None):
data_rate = options[0] data_rate = options[0]
upload_allowed = options[1] upload_allowed = options[1]
@ -137,7 +137,8 @@ class ManagedLBRYFileDownloaderFactory(object):
d.addCallback(lambda stream_hash: self.lbry_file_manager.add_lbry_file(stream_hash, d.addCallback(lambda stream_hash: self.lbry_file_manager.add_lbry_file(stream_hash,
payment_rate_manager, payment_rate_manager,
data_rate, data_rate,
upload_allowed)) upload_allowed,
download_directory=download_directory))
return d return d
@staticmethod @staticmethod

View file

@ -28,7 +28,7 @@ class LBRYFileManager(object):
Keeps track of currently opened LBRY Files, their options, and their LBRY File specific metadata. Keeps track of currently opened LBRY Files, their options, and their LBRY File specific metadata.
""" """
def __init__(self, session, stream_info_manager, sd_identifier, delete_data=False): def __init__(self, session, stream_info_manager, sd_identifier, delete_data=False, download_directory=None):
self.session = session self.session = session
self.stream_info_manager = stream_info_manager self.stream_info_manager = stream_info_manager
self.sd_identifier = sd_identifier self.sd_identifier = sd_identifier
@ -36,8 +36,8 @@ class LBRYFileManager(object):
self.sql_db = None self.sql_db = None
# self.delete_data = delete_data # self.delete_data = delete_data
# self.check_exists_loop = LoopingCall(self.check_files_exist) # self.check_exists_loop = LoopingCall(self.check_files_exist)
if sys.platform.startswith("darwin"): if download_directory:
self.download_directory = os.path.join(os.path.expanduser("~"), 'Downloads') self.download_directory = download_directory
else: else:
self.download_directory = os.getcwd() self.download_directory = os.getcwd()
log.debug("Download directory for LBRYFileManager: %s", str(self.download_directory)) log.debug("Download directory for LBRYFileManager: %s", str(self.download_directory))
@ -122,7 +122,10 @@ class LBRYFileManager(object):
d.addCallback(start_lbry_files) d.addCallback(start_lbry_files)
return d return d
def start_lbry_file(self, rowid, stream_hash, payment_rate_manager, blob_data_rate=None, upload_allowed=True): def start_lbry_file(self, rowid, stream_hash, payment_rate_manager, blob_data_rate=None, upload_allowed=True,
download_directory=None):
if not download_directory:
download_directory = self.download_directory
payment_rate_manager.min_blob_data_payment_rate = blob_data_rate payment_rate_manager.min_blob_data_payment_rate = blob_data_rate
lbry_file_downloader = ManagedLBRYFileDownloader(rowid, stream_hash, lbry_file_downloader = ManagedLBRYFileDownloader(rowid, stream_hash,
self.session.peer_finder, self.session.peer_finder,
@ -130,17 +133,17 @@ class LBRYFileManager(object):
self.session.blob_manager, self.session.blob_manager,
self.stream_info_manager, self, self.stream_info_manager, self,
payment_rate_manager, self.session.wallet, payment_rate_manager, self.session.wallet,
self.download_directory, download_directory,
upload_allowed) upload_allowed)
self.lbry_files.append(lbry_file_downloader) self.lbry_files.append(lbry_file_downloader)
d = lbry_file_downloader.set_stream_info() d = lbry_file_downloader.set_stream_info()
d.addCallback(lambda _: lbry_file_downloader) d.addCallback(lambda _: lbry_file_downloader)
return d return d
def add_lbry_file(self, stream_hash, payment_rate_manager, blob_data_rate=None, upload_allowed=True): def add_lbry_file(self, stream_hash, payment_rate_manager, blob_data_rate=None, upload_allowed=True, download_directory=None):
d = self._save_lbry_file(stream_hash, blob_data_rate) d = self._save_lbry_file(stream_hash, blob_data_rate)
d.addCallback(lambda rowid: self.start_lbry_file(rowid, stream_hash, payment_rate_manager, d.addCallback(lambda rowid: self.start_lbry_file(rowid, stream_hash, payment_rate_manager,
blob_data_rate, upload_allowed)) blob_data_rate, upload_allowed, download_directory))
return d return d
def delete_lbry_file(self, lbry_file): def delete_lbry_file(self, lbry_file):

View file

@ -28,7 +28,7 @@ class LBRYURIHandler(object):
def check_status(self): def check_status(self):
status = None status = None
try: try:
status = json.loads(self.daemon.is_running())['result'] status = self.daemon.is_running()
if self.start_timeout < 30 and not status: if self.start_timeout < 30 and not status:
sleep(1) sleep(1)
self.start_timeout += 1 self.start_timeout += 1
@ -45,11 +45,11 @@ class LBRYURIHandler(object):
else: else:
raise Timeout("Timed out trying to start LBRY daemon") raise Timeout("Timed out trying to start LBRY daemon")
def handle(self, lbry_name): def handle_osx(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 and 'LBRYURIHandler' not in d] if 'LBRY.app' in d and 'LBRYURIHandler' not in d]
try: try:
status = json.loads(self.daemon.is_running())['result'] status = self.daemon.is_running()
except: except:
status = None status = None
@ -62,18 +62,22 @@ class LBRYURIHandler(object):
started = True started = True
if lbry_name == "lbry" or lbry_name == "" and not started: if lbry_name == "lbry" or lbry_name == "" and not started:
webbrowser.get('safari').open(UI_ADDRESS) webbrowser.open(UI_ADDRESS)
else: else:
r = json.loads(self.daemon.get({'name': lbry_name})) webbrowser.open(UI_ADDRESS + "/view?name=" + lbry_name)
if r['code'] == 200:
path = r['result']['path'].encode('utf-8') def handle_linux(self, lbry_name):
extension = os.path.splitext(path)[1] try:
if extension in ['mp4', 'flv', 'mov', 'ogv']: is_running = self.daemon.is_running()
webbrowser.get('safari').open(UI_ADDRESS + "/view?name=" + lbry_name) if not is_running:
else: sys.exit(0)
webbrowser.get('safari').open('file://' + path) except:
else: sys.exit(0)
webbrowser.get('safari').open('http://lbry.io/get')
if lbry_name == "lbry":
webbrowser.open(UI_ADDRESS)
else:
webbrowser.open(UI_ADDRESS + "/view?name=" + lbry_name)
def main(args): def main(args):
@ -81,8 +85,10 @@ def main(args):
args = ['lbry://lbry'] args = ['lbry://lbry']
name = args[0][7:] name = args[0][7:]
LBRYURIHandler().handle(lbry_name=name) if sys.platform == "darwin":
LBRYURIHandler().handle_osx(lbry_name=name)
else:
LBRYURIHandler().handle_linux(lbry_name=name)
if __name__ == "__main__": if __name__ == "__main__":
main(sys.argv[1:]) main(sys.argv[1:])

File diff suppressed because it is too large Load diff

View file

@ -1,22 +1,49 @@
import argparse import argparse
import logging import logging
import tempfile import logging.handlers
import subprocess
import os import os
import shutil import shutil
import webbrowser
import sys
import socket
from StringIO import StringIO from StringIO import StringIO
from zipfile import ZipFile from zipfile import ZipFile
from urllib import urlopen from urllib import urlopen
from datetime import datetime
from appdirs import user_data_dir
from twisted.web import server, static from twisted.web import server, static
from twisted.internet import reactor, defer from twisted.internet import reactor, defer
from jsonrpc.proxy import JSONRPCProxy from jsonrpc.proxy import JSONRPCProxy
from lbrynet.lbrynet_daemon.LBRYDaemon import LBRYDaemon, LBRYindex, LBRYDaemonWeb, LBRYFileRender from lbrynet.lbrynet_daemon.LBRYDaemon import LBRYDaemon, LBRYindex, LBRYFileRender
from lbrynet.conf import API_CONNECTION_STRING, API_INTERFACE, API_ADDRESS, API_PORT, DEFAULT_WALLET from lbrynet.conf import API_CONNECTION_STRING, API_INTERFACE, API_ADDRESS, API_PORT, DEFAULT_WALLET, UI_ADDRESS
if sys.platform != "darwin":
log_dir = os.path.join(os.path.expanduser("~"), ".lbrynet")
else:
log_dir = user_data_dir("LBRY")
if not os.path.isdir(log_dir):
os.mkdir(log_dir)
LOG_FILENAME = os.path.join(log_dir, 'lbrynet-daemon.log')
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
logging.basicConfig(level=logging.INFO) handler = logging.handlers.RotatingFileHandler(LOG_FILENAME, maxBytes=262144, backupCount=5)
log.addHandler(handler)
log.setLevel(logging.INFO)
REMOTE_SERVER = "www.google.com"
def test_internet_connection():
try:
host = socket.gethostbyname(REMOTE_SERVER)
s = socket.create_connection((host, 80), 2)
return True
except:
return False
def stop(): def stop():
@ -38,45 +65,114 @@ def start():
help="lbrycrd or lbryum, default lbryum", help="lbrycrd or lbryum, default lbryum",
type=str, type=str,
default=DEFAULT_WALLET) default=DEFAULT_WALLET)
parser.add_argument("--update",
help="True or false, default true",
type=str,
default="True")
parser.add_argument("--ui", parser.add_argument("--ui",
help="temp or path, default temp, path is the path of the dist folder", help="path to custom UI folder",
default="temp") default="")
parser.add_argument("--branch",
help="Branch of lbry-web-ui repo to use, defaults on HEAD",
default="HEAD")
parser.add_argument('--no-launch', dest='launchui', action="store_false")
parser.set_defaults(launchui=True)
try:
JSONRPCProxy.from_url(API_CONNECTION_STRING).is_running()
log.info("lbrynet-daemon is already running")
return
except:
pass
log.info("Starting lbrynet-daemon from command line") log.info("Starting lbrynet-daemon from command line")
print "Starting lbrynet-daemon from command line"
print "To view activity, view the log file here: " + LOG_FILENAME
print "Web UI is available at http://%s:%i" %(API_INTERFACE, API_PORT)
print "JSONRPC API is available at " + API_CONNECTION_STRING
print "To quit press ctrl-c or call 'stop' via the API"
args = parser.parse_args() args = parser.parse_args()
download_ui = True
if args.ui != "temp" and os.path.isdir(args.ui): if args.branch == "HEAD":
download_ui = False GIT_CMD_STRING = "git ls-remote https://github.com/lbryio/lbry-web-ui.git | grep %s | cut -f 1" % args.branch
ui_dir = args.ui DIST_URL = "https://raw.githubusercontent.com/lbryio/lbry-web-ui/master/dist.zip"
log.info("Using user specified UI directory: " + str(ui_dir)) else:
log.info("Using UI branch: " + args.branch)
GIT_CMD_STRING = "git ls-remote https://github.com/lbryio/lbry-web-ui.git | grep refs/heads/%s | cut -f 1" % args.branch
DIST_URL = "https://raw.githubusercontent.com/lbryio/lbry-web-ui/%s/dist.zip" % args.branch
if args.ui == "temp" or download_ui: def getui(ui_dir=None):
log.info("Downloading current web ui to temp directory") if ui_dir:
ui_dir = tempfile.mkdtemp() if os.path.isdir(ui_dir):
url = urlopen("https://rawgit.com/lbryio/lbry-web-ui/master/dist.zip") log.info("Using user specified UI directory: " + str(ui_dir))
z = ZipFile(StringIO(url.read())) ui_version_info = "user-specified"
z.extractall(ui_dir) return defer.succeed([ui_dir, ui_version_info])
else:
log.info("User specified UI directory doesn't exist: " + str(ui_dir))
daemon = LBRYDaemon() def download_ui(dest_dir, ui_version):
daemon.setup(args.wallet, args.update) url = urlopen(DIST_URL)
z = ZipFile(StringIO(url.read()))
names = [i for i in z.namelist() if '.DS_Store' not in i and '__MACOSX' not in i]
z.extractall(dest_dir, members=names)
return defer.succeed([dest_dir, ui_version])
root = LBRYindex(ui_dir) data_dir = user_data_dir("LBRY")
root.putChild("css", static.File(os.path.join(ui_dir, "css"))) version_dir = os.path.join(data_dir, "ui_version_history")
root.putChild("font", static.File(os.path.join(ui_dir, "font")))
root.putChild("img", static.File(os.path.join(ui_dir, "img")))
root.putChild("js", static.File(os.path.join(ui_dir, "js")))
root.putChild(API_ADDRESS, daemon)
root.putChild("webapi", LBRYDaemonWeb())
root.putChild("view", LBRYFileRender())
reactor.listenTCP(API_PORT, server.Site(root), interface=API_INTERFACE) git_version = subprocess.check_output(GIT_CMD_STRING, shell=True)
reactor.run() if not git_version:
log.info("You should have been notified to install xcode command line tools, once it's installed you can start LBRY")
print "You should have been notified to install xcode command line tools, once it's installed you can start LBRY"
sys.exit(0)
if download_ui: ui_version_info = git_version
shutil.rmtree(ui_dir)
if not os.path.isdir(data_dir):
os.mkdir(data_dir)
if not os.path.isdir(os.path.join(data_dir, "ui_version_history")):
os.mkdir(version_dir)
if not os.path.isfile(os.path.join(version_dir, git_version)):
f = open(os.path.join(version_dir, git_version), "w")
version_message = "[" + str(datetime.now()) + "] Updating UI --> " + git_version
f.write(version_message)
f.close()
log.info(version_message)
if os.path.isdir(os.path.join(data_dir, "lbry-web-ui")):
shutil.rmtree(os.path.join(data_dir, "lbry-web-ui"))
else:
version_message = "[" + str(datetime.now()) + "] UI version " + git_version + " up to date"
log.info(version_message)
if os.path.isdir(os.path.join(data_dir, "lbry-web-ui")):
return defer.succeed([os.path.join(data_dir, "lbry-web-ui"), ui_version_info])
else:
return download_ui(os.path.join(data_dir, "lbry-web-ui"), ui_version_info)
def setupserver(ui_dir, ui_version):
root = LBRYindex(ui_dir)
root.putChild("css", static.File(os.path.join(ui_dir, "css")))
root.putChild("font", static.File(os.path.join(ui_dir, "font")))
root.putChild("img", static.File(os.path.join(ui_dir, "img")))
root.putChild("js", static.File(os.path.join(ui_dir, "js")))
root.putChild("view", LBRYFileRender())
return defer.succeed([root, ui_version])
def setupapi(root, wallet, ui_version):
daemon = LBRYDaemon(ui_version, wallet_type=wallet)
root.putChild(API_ADDRESS, daemon)
reactor.listenTCP(API_PORT, server.Site(root), interface=API_INTERFACE)
return daemon.setup()
if test_internet_connection():
d = getui(args.ui)
d.addCallback(lambda r: setupserver(r[0], r[1]))
d.addCallback(lambda r: setupapi(r[0], args.wallet, r[1]))
if args.launchui:
d.addCallback(lambda _: webbrowser.open(UI_ADDRESS))
reactor.run()
print "\nClosing lbrynet-daemon"
else:
log.info("Not connected to internet, unable to start")
print "Not connected to internet, unable to start"
return

View file

@ -17,7 +17,7 @@ log = logging.getLogger(__name__)
class GetStream(object): class GetStream(object):
def __init__(self, sd_identifier, session, wallet, lbry_file_manager, max_key_fee, pay_key=True, data_rate=0.5, def __init__(self, sd_identifier, session, wallet, lbry_file_manager, max_key_fee, pay_key=True, data_rate=0.5,
timeout=DEFAULT_TIMEOUT): timeout=DEFAULT_TIMEOUT, download_directory=None):
self.wallet = wallet self.wallet = wallet
self.resolved_name = None self.resolved_name = None
self.description = None self.description = None
@ -37,6 +37,7 @@ class GetStream(object):
self.d = defer.Deferred(None) self.d = defer.Deferred(None)
self.timeout = timeout self.timeout = timeout
self.timeout_counter = 0 self.timeout_counter = 0
self.download_directory = download_directory
self.download_path = None self.download_path = None
self.checker = LoopingCall(self.check_status) self.checker = LoopingCall(self.check_status)
@ -68,6 +69,8 @@ class GetStream(object):
self.key_fee_address = None self.key_fee_address = None
self.stream_hash = self.stream_info['stream_hash'] self.stream_hash = self.stream_info['stream_hash']
if isinstance(self.stream_hash, dict):
self.stream_hash = self.stream_hash['sd_hash']
else: else:
log.error("InvalidStreamInfoError in autofetcher: ", stream_info) log.error("InvalidStreamInfoError in autofetcher: ", stream_info)
@ -86,7 +89,10 @@ class GetStream(object):
self.d.addCallback(lambda _: download_sd_blob(self.session, self.stream_hash, self.payment_rate_manager)) self.d.addCallback(lambda _: download_sd_blob(self.session, self.stream_hash, self.payment_rate_manager))
self.d.addCallback(self.sd_identifier.get_metadata_for_sd_blob) self.d.addCallback(self.sd_identifier.get_metadata_for_sd_blob)
self.d.addCallback(lambda metadata: (next(factory for factory in metadata.factories if isinstance(factory, ManagedLBRYFileDownloaderFactory)), metadata)) self.d.addCallback(lambda metadata: (next(factory for factory in metadata.factories if isinstance(factory, ManagedLBRYFileDownloaderFactory)), metadata))
self.d.addCallback(lambda (factory, metadata): factory.make_downloader(metadata, [self.data_rate, True], self.payment_rate_manager)) self.d.addCallback(lambda (factory, metadata): factory.make_downloader(metadata,
[self.data_rate, True],
self.payment_rate_manager,
download_directory=self.download_directory))
self.d.addErrback(lambda err: err.trap(defer.CancelledError)) self.d.addErrback(lambda err: err.trap(defer.CancelledError))
self.d.addErrback(lambda err: log.error("An exception occurred attempting to load the stream descriptor: %s", err.getTraceback())) self.d.addErrback(lambda err: log.error("An exception occurred attempting to load the stream descriptor: %s", err.getTraceback()))
self.d.addCallback(self._start_download) self.d.addCallback(self._start_download)

View file

@ -43,7 +43,7 @@ class Publisher(object):
message = "[" + str(datetime.now()) + "] Published " + self.file_name + " --> lbry://" + \ message = "[" + str(datetime.now()) + "] Published " + self.file_name + " --> lbry://" + \
str(self.publish_name) + " with txid: " + str(self.tx_hash) str(self.publish_name) + " with txid: " + str(self.tx_hash)
log.info(message) log.info(message)
return defer.succeed(message) return defer.succeed(self.tx_hash)
self.publish_name = name self.publish_name = name
self.file_path = file_path self.file_path = file_path
@ -108,7 +108,7 @@ class Publisher(object):
return d return d
def _claim_name(self): def _claim_name(self):
d = self.wallet.claim_name(self.publish_name, {'sd_hash': self.sd_hash}, self.bid_amount, d = self.wallet.claim_name(self.publish_name, self.sd_hash, self.bid_amount,
description=self.description, key_fee=self.key_fee, description=self.description, key_fee=self.key_fee,
key_fee_address=self.key_fee_address, thumbnail=self.thumbnail, key_fee_address=self.key_fee_address, thumbnail=self.thumbnail,
content_license=self.content_license, author=self.author, content_license=self.content_license, author=self.author,
@ -121,6 +121,7 @@ class Publisher(object):
return d return d
def _show_publish_error(self, err): def _show_publish_error(self, err):
log.info(err.getTraceback())
message = "An error occurred publishing %s to %s. Error: %s." message = "An error occurred publishing %s to %s. Error: %s."
if err.check(InsufficientFundsError): if err.check(InsufficientFundsError):
error_message = "Insufficient funds" error_message = "Insufficient funds"

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

View file

@ -0,0 +1,5 @@
# package scripts
How to build LBRY packages.
For best results, run on a fresh image.

32
packaging/ubuntu/lbry Executable file
View file

@ -0,0 +1,32 @@
#!/bin/bash
set -euo pipefail
urlencode() {
local LANG=C
local length="${#1}"
for (( i = 0; i < length; i++ )); do
local c="${1:i:1}"
case $c in
[a-zA-Z0-9.~_-]) printf "$c" ;;
*) printf '%%%02X' "'$c" ;;
esac
done
}
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
if [ -z "$(pgrep lbrynet-daemon)" ]; then
echo "running lbrynet-daemon..."
$DIR/lbrynet-daemon --branch=settings-page &
sleep 3 # let the daemon load before connecting
fi
ARG=${1:-}
if [ -z "$ARG" ]; then
URL=""
else
URL="view?name=$(urlencode "$(echo "$ARG" | cut -c 8-)")"
fi
/usr/bin/xdg-open "http://localhost:5279/$URL"

View file

@ -0,0 +1,11 @@
description "LBRY Daemon"
#start on (local-filesystems and net-device-up IFACE=eth0)
stop on runlevel [016]
#expect fork
respawn
respawn limit 5 20
exec /usr/share/python/lbrynet/bin/lbrynet-daemon

View file

@ -0,0 +1,15 @@
[Desktop Entry]
Version=0.2.1
Name=LBRY
# Only KDE 4 seems to use GenericName, so we reuse the KDE strings.
# From Ubuntu's language-pack-kde-XX-base packages, version 9.04-20090413.
GenericName=Filesharing
# Gnome and KDE 3 uses Comment.
Comment=Stream. Share. Earn.
#Exec=/usr/bin/xdg-open http://localhost:5279/view?name=%U
Exec=/usr/share/python/lbrynet/bin/lbry %U
Terminal=false
Icon=/usr/share/python/lbrynet/lbrynet/lbrynet_gui/lbry.png
Type=Application
Categories=Network;Internet;Filesharing
MimeType=x-scheme-handler/lbry;

View file

@ -0,0 +1,67 @@
#!/bin/bash
# Tested on fresh Ubuntu 14.04 install.
# wget https://raw.githubusercontent.com/lbryio/lbry/master/packaging/ubuntu/ubuntu_package_setup.sh
# bash ubuntu_package_setup.sh master
set -euo pipefail
BRANCH=${1:-master}
BUILD_DIR="lbry-build-$(date +%Y%m%d-%H%M%S)"
mkdir "$BUILD_DIR"
cd "$BUILD_DIR"
# get the required OS packages
sudo add-apt-repository -y ppa:spotify-jyrki/dh-virtualenv
sudo apt-get update
sudo apt-get install -y build-essential git python-dev libffi-dev libssl-dev libgmp3-dev dh-virtualenv debhelper
# need a modern version of pip (more modern than ubuntu default)
wget https://bootstrap.pypa.io/get-pip.py
sudo python get-pip.py
rm get-pip.py
sudo pip install make-deb
# check out LBRY
git clone https://github.com/lbryio/lbry.git --branch "$BRANCH"
# build packages
(
cd lbry
make-deb
dpkg-buildpackage -us -uc
)
### insert our extra files
# extract .deb
PACKAGE="$(ls | grep '.deb')"
ar vx "$PACKAGE"
mkdir control data
tar -xvzf control.tar.gz --directory control
tar -xvJf data.tar.xz --directory data
# add files
function addfile() {
FILE="$1"
TARGET="$2"
mkdir -p "$(dirname "data/$TARGET")"
cp "$FILE" "data/$TARGET"
echo "$(md5sum "data/$TARGET" | cut -d' ' -f1) $TARGET" >> control/md5sums
}
PACKAGING_DIR='lbry/packaging/ubuntu'
addfile "$PACKAGING_DIR/lbry" usr/share/python/lbrynet/bin/lbry
addfile "$PACKAGING_DIR/lbry.desktop" usr/share/applications/lbry.desktop
#addfile lbry/packaging/ubuntu/lbry-init.conf etc/init/lbry.conf
# repackage .deb
sudo chown -R root:root control data
tar -cvzf control.tar.gz -C control .
tar -cvJf data.tar.xz -C data .
sudo chown root:root debian-binary control.tar.gz data.tar.xz
ar r "$PACKAGE" debian-binary control.tar.gz data.tar.xz
# TODO: we can append to data.tar instead of extracting it all and recompressing

View file

@ -19,9 +19,10 @@ qrcode==5.2.2
requests==2.9.1 requests==2.9.1
seccure==0.3.1.3 seccure==0.3.1.3
simplejson==3.8.2 simplejson==3.8.2
six==1.10.0 six==1.9.0
slowaes==0.1a1 slowaes==0.1a1
txJSON-RPC==0.3.1 txJSON-RPC==0.3.1
unqlite==0.2.0 unqlite==0.2.0
wsgiref==0.1.2 wsgiref==0.1.2
zope.interface==4.1.3 zope.interface==4.1.3
base58==0.2.2

View file

@ -26,15 +26,10 @@ console_scripts = ['lbrynet-console = lbrynet.lbrynet_console.LBRYConsole:launch
requires = ['pycrypto', 'twisted', 'miniupnpc', 'yapsy', 'seccure', requires = ['pycrypto', 'twisted', 'miniupnpc', 'yapsy', 'seccure',
'python-bitcoinrpc==0.1', 'txJSON-RPC', 'requests>=2.4.2', 'unqlite==0.2.0', 'python-bitcoinrpc==0.1', 'txJSON-RPC', 'requests>=2.4.2', 'unqlite==0.2.0',
'leveldb', 'lbryum', 'jsonrpc', 'simplejson', 'appdirs'] 'leveldb', 'lbryum>=2.6.0.1', 'jsonrpc', 'simplejson', 'appdirs', 'six==1.9.0', 'base58']
if sys.platform == 'darwin':
requires.append('six==1.9.0')
else:
requires.append('six>=1.9.0')
gui_data_files = ['close2.gif', 'lbry-dark-242x80.gif', 'lbry-dark-icon.xbm', 'lbry-dark-icon.ico', gui_data_files = ['close2.gif', 'lbry-dark-242x80.gif', 'lbry-dark-icon.xbm', 'lbry-dark-icon.ico',
'drop_down.gif', 'show_options.gif', 'hide_options.gif', 'lbry.conf'] 'drop_down.gif', 'show_options.gif', 'hide_options.gif', 'lbry.conf', 'lbry.png']
gui_data_paths = [os.path.join(base_dir, 'lbrynet', 'lbrynet_gui', f) for f in gui_data_files] gui_data_paths = [os.path.join(base_dir, 'lbrynet', 'lbrynet_gui', f) for f in gui_data_files]
setup(name='lbrynet', setup(name='lbrynet',