forked from LBRYCommunity/lbry-sdk
Merge branch 'development' of github.com:lbryio/lbry into development
This commit is contained in:
commit
96c8d1f68b
8 changed files with 212 additions and 108 deletions
6
.gitignore
vendored
6
.gitignore
vendored
|
@ -17,3 +17,9 @@ lbrynet.egg-info/PKG-INFO
|
||||||
/build
|
/build
|
||||||
|
|
||||||
/dist
|
/dist
|
||||||
|
|
||||||
|
*.so
|
||||||
|
|
||||||
|
*.pem
|
||||||
|
|
||||||
|
*.decTest
|
||||||
|
|
|
@ -1006,7 +1006,7 @@ class LBRYumWallet(LBRYWallet):
|
||||||
return defer.succeed(Decimal(self.wallet.get_addr_received(address))/COIN)
|
return defer.succeed(Decimal(self.wallet.get_addr_received(address))/COIN)
|
||||||
|
|
||||||
def get_nametrie(self):
|
def get_nametrie(self):
|
||||||
cmd = known_commands['getnametrie']
|
cmd = known_commands['getclaimtrie']
|
||||||
func = getattr(self.cmd_runner, cmd.name)
|
func = getattr(self.cmd_runner, cmd.name)
|
||||||
return threads.deferToThread(func)
|
return threads.deferToThread(func)
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,6 @@ from lbrynet.lbryfile.StreamDescriptor import LBRYFileStreamType
|
||||||
from lbrynet.lbryfile.client.LBRYFileDownloader import LBRYFileSaverFactory, LBRYFileOpenerFactory
|
from lbrynet.lbryfile.client.LBRYFileDownloader import LBRYFileSaverFactory, LBRYFileOpenerFactory
|
||||||
from lbrynet.lbryfile.client.LBRYFileOptions import add_lbry_file_to_sd_identifier
|
from lbrynet.lbryfile.client.LBRYFileOptions import add_lbry_file_to_sd_identifier
|
||||||
from lbrynet.lbrynet_daemon.LBRYDownloader import GetStream, FetcherDaemon
|
from lbrynet.lbrynet_daemon.LBRYDownloader import GetStream, FetcherDaemon
|
||||||
# from lbrynet.lbrynet_daemon.LBRYOSXStatusBar import DaemonStatusBarApp
|
|
||||||
from lbrynet.lbrynet_daemon.LBRYPublisher import Publisher
|
from lbrynet.lbrynet_daemon.LBRYPublisher import Publisher
|
||||||
from lbrynet.core.utils import generate_id
|
from lbrynet.core.utils import generate_id
|
||||||
from lbrynet.lbrynet_console.LBRYSettings import LBRYSettings
|
from lbrynet.lbrynet_console.LBRYSettings import LBRYSettings
|
||||||
|
@ -16,7 +15,7 @@ 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.StreamDescriptor import StreamDescriptorIdentifier, download_sd_blob
|
||||||
from lbrynet.core.Session import LBRYSession
|
from lbrynet.core.Session import LBRYSession
|
||||||
from lbrynet.core.PTCWallet import PTCWallet
|
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.lbryfilemanager.LBRYFileManager import LBRYFileManager
|
||||||
from lbrynet.lbryfile.LBRYFileMetadataManager import DBLBRYFileMetadataManager, TempLBRYFileMetadataManager
|
from lbrynet.lbryfile.LBRYFileMetadataManager import DBLBRYFileMetadataManager, TempLBRYFileMetadataManager
|
||||||
from twisted.web import xmlrpc, server
|
from twisted.web import xmlrpc, server
|
||||||
|
@ -26,9 +25,11 @@ from decimal import Decimal
|
||||||
from StringIO import StringIO
|
from StringIO import StringIO
|
||||||
from zipfile import ZipFile
|
from zipfile import ZipFile
|
||||||
from urllib import urlopen
|
from urllib import urlopen
|
||||||
import os, sys, json, binascii, webbrowser, xmlrpclib, subprocess, logging
|
|
||||||
|
import os, sys, json, binascii, webbrowser, xmlrpclib, subprocess, logging, argparse
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
# logging.basicConfig(level=logging.DEBUG)
|
||||||
|
|
||||||
|
|
||||||
# TODO add login credentials in a conf file
|
# TODO add login credentials in a conf file
|
||||||
|
@ -46,8 +47,8 @@ class LBRYDaemon(xmlrpc.XMLRPC):
|
||||||
LBRYnet daemon
|
LBRYnet daemon
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def setup(self):
|
def setup(self, wallet_type, check_for_updates):
|
||||||
def _set_vars():
|
def _set_vars(wallet_type, check_for_updates):
|
||||||
self.fetcher = None
|
self.fetcher = None
|
||||||
self.current_db_revision = 1
|
self.current_db_revision = 1
|
||||||
self.run_server = True
|
self.run_server = True
|
||||||
|
@ -57,6 +58,7 @@ class LBRYDaemon(xmlrpc.XMLRPC):
|
||||||
self.db_dir = os.path.join(os.path.expanduser("~"), ".lbrynet")
|
self.db_dir = os.path.join(os.path.expanduser("~"), ".lbrynet")
|
||||||
else:
|
else:
|
||||||
self.db_dir = os.path.join(os.path.expanduser("~"), "Library/Application Support/lbrynet")
|
self.db_dir = os.path.join(os.path.expanduser("~"), "Library/Application Support/lbrynet")
|
||||||
|
# from lbrynet.lbrynet_daemon.LBRYOSXStatusBar import DaemonStatusBarApp
|
||||||
# self.status_app = DaemonStatusBarApp()
|
# self.status_app = DaemonStatusBarApp()
|
||||||
self.blobfile_dir = os.path.join(self.db_dir, "blobfiles")
|
self.blobfile_dir = os.path.join(self.db_dir, "blobfiles")
|
||||||
self.peer_port = 3333
|
self.peer_port = 3333
|
||||||
|
@ -93,10 +95,10 @@ class LBRYDaemon(xmlrpc.XMLRPC):
|
||||||
self.lbry_file_metadata_manager = None
|
self.lbry_file_metadata_manager = None
|
||||||
self.lbry_file_manager = None
|
self.lbry_file_manager = None
|
||||||
self.settings = LBRYSettings(self.db_dir)
|
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.lbrycrd_conf = os.path.join(self.wallet_dir, "lbrycrd.conf")
|
||||||
self.autofetcher_conf = os.path.join(self.wallet_dir, "autofetcher.conf")
|
self.autofetcher_conf = os.path.join(self.wallet_dir, "autofetcher.conf")
|
||||||
self.files = []
|
|
||||||
self.created_data_dir = False
|
self.created_data_dir = False
|
||||||
if not os.path.exists(self.db_dir):
|
if not os.path.exists(self.db_dir):
|
||||||
os.mkdir(self.db_dir)
|
os.mkdir(self.db_dir)
|
||||||
|
@ -117,11 +119,14 @@ class LBRYDaemon(xmlrpc.XMLRPC):
|
||||||
else:
|
else:
|
||||||
print "Started LBRYnet daemon"
|
print "Started LBRYnet daemon"
|
||||||
print "The daemon can be shut down by running 'stop-lbrynet-daemon' in a terminal"
|
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)
|
return defer.succeed(None)
|
||||||
|
|
||||||
|
log.info('[' + str(datetime.now()) + '] Starting lbrynet-daemon')
|
||||||
|
|
||||||
d = defer.Deferred()
|
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 _: threads.deferToThread(self._setup_data_directory))
|
||||||
d.addCallback(lambda _: self._check_db_migration())
|
d.addCallback(lambda _: self._check_db_migration())
|
||||||
d.addCallback(lambda _: self._get_settings())
|
d.addCallback(lambda _: self._get_settings())
|
||||||
|
@ -134,8 +139,8 @@ class LBRYDaemon(xmlrpc.XMLRPC):
|
||||||
d.addCallback(lambda _: self._setup_query_handlers())
|
d.addCallback(lambda _: self._setup_query_handlers())
|
||||||
d.addCallback(lambda _: self._setup_server())
|
d.addCallback(lambda _: self._setup_server())
|
||||||
if sys.platform == "darwin":
|
if sys.platform == "darwin":
|
||||||
d.addCallback(lambda _: self._update())
|
d.addCallback(lambda _: self._update() if self.check_for_updates == "True" else defer.succeed(None))
|
||||||
# d.addCallback(lambda _: self.status_app.run())
|
# d.addCallback(lambda _: defer.succeed(self.status_app.run()))
|
||||||
d.addCallback(lambda _: self._setup_fetcher())
|
d.addCallback(lambda _: self._setup_fetcher())
|
||||||
d.addCallback(lambda _: _disp_startup())
|
d.addCallback(lambda _: _disp_startup())
|
||||||
d.callback(None)
|
d.callback(None)
|
||||||
|
@ -397,6 +402,8 @@ class LBRYDaemon(xmlrpc.XMLRPC):
|
||||||
|
|
||||||
def get_wallet():
|
def get_wallet():
|
||||||
if self.wallet_type == "lbrycrd":
|
if self.wallet_type == "lbrycrd":
|
||||||
|
print "Using lbrycrd wallet"
|
||||||
|
log.info("Using lbrycrd wallet")
|
||||||
lbrycrdd_path = None
|
lbrycrdd_path = None
|
||||||
if self.start_lbrycrdd is True:
|
if self.start_lbrycrdd is True:
|
||||||
lbrycrdd_path = self.lbrycrdd_path
|
lbrycrdd_path = self.lbrycrdd_path
|
||||||
|
@ -404,8 +411,17 @@ class LBRYDaemon(xmlrpc.XMLRPC):
|
||||||
lbrycrdd_path = self.default_lbrycrdd_path
|
lbrycrdd_path = self.default_lbrycrdd_path
|
||||||
d = defer.succeed(LBRYcrdWallet(self.db_dir, wallet_dir=self.wallet_dir, wallet_conf=self.lbrycrd_conf,
|
d = defer.succeed(LBRYcrdWallet(self.db_dir, wallet_dir=self.wallet_dir, wallet_conf=self.lbrycrd_conf,
|
||||||
lbrycrdd_path=lbrycrdd_path))
|
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))
|
d = defer.succeed(PTCWallet(self.db_dir))
|
||||||
|
else:
|
||||||
|
d = defer.fail()
|
||||||
|
|
||||||
d.addCallback(lambda wallet: {"wallet": wallet})
|
d.addCallback(lambda wallet: {"wallet": wallet})
|
||||||
return d
|
return d
|
||||||
|
|
||||||
|
@ -530,9 +546,11 @@ class LBRYDaemon(xmlrpc.XMLRPC):
|
||||||
path = os.path.join(self.blobfile_dir, stream_hash)
|
path = os.path.join(self.blobfile_dir, stream_hash)
|
||||||
if os.path.isfile(path):
|
if os.path.isfile(path):
|
||||||
print "[" + str(datetime.now()) + "] Search for lbry_file, returning: " + stream_hash
|
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))
|
return defer.succeed(_get_lbry_file(path))
|
||||||
else:
|
else:
|
||||||
print "[" + str(datetime.now()) + "] Search for lbry_file didn't return anything"
|
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)
|
return defer.succeed(False)
|
||||||
|
|
||||||
d = self._resolve_name(name)
|
d = self._resolve_name(name)
|
||||||
|
@ -578,8 +596,10 @@ class LBRYDaemon(xmlrpc.XMLRPC):
|
||||||
def _check_est(d, name):
|
def _check_est(d, name):
|
||||||
if type(d.result) is float:
|
if type(d.result) is float:
|
||||||
print '[' + str(datetime.now()) + '] Cost est for lbry://' + name + ': ' + str(d.result) + 'LBC'
|
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:
|
else:
|
||||||
print '[' + str(datetime.now()) + '] Timeout estimating cost for lbry://' + name + ', using key fee'
|
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()
|
d.cancel()
|
||||||
return defer.succeed(None)
|
return defer.succeed(None)
|
||||||
|
|
||||||
|
@ -636,6 +656,7 @@ class LBRYDaemon(xmlrpc.XMLRPC):
|
||||||
|
|
||||||
self.fetcher.start()
|
self.fetcher.start()
|
||||||
print '[' + str(datetime.now()) + '] Start autofetcher'
|
print '[' + str(datetime.now()) + '] Start autofetcher'
|
||||||
|
log.info('[' + str(datetime.now()) + '] Start autofetcher')
|
||||||
return 'Started autofetching'
|
return 'Started autofetching'
|
||||||
|
|
||||||
def xmlrpc_stop_fetcher(self):
|
def xmlrpc_stop_fetcher(self):
|
||||||
|
@ -645,6 +666,7 @@ class LBRYDaemon(xmlrpc.XMLRPC):
|
||||||
|
|
||||||
self.fetcher.stop()
|
self.fetcher.stop()
|
||||||
print '[' + str(datetime.now()) + '] Stop autofetcher'
|
print '[' + str(datetime.now()) + '] Stop autofetcher'
|
||||||
|
log.info('[' + str(datetime.now()) + '] Stop autofetcher')
|
||||||
return 'Stopped autofetching'
|
return 'Stopped autofetching'
|
||||||
|
|
||||||
def xmlrpc_fetcher_status(self):
|
def xmlrpc_fetcher_status(self):
|
||||||
|
@ -669,6 +691,7 @@ class LBRYDaemon(xmlrpc.XMLRPC):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def _disp_shutdown():
|
def _disp_shutdown():
|
||||||
|
log.info('Shutting down lbrynet daemon')
|
||||||
print 'Shutting down lbrynet daemon'
|
print 'Shutting down lbrynet daemon'
|
||||||
|
|
||||||
d = self._shutdown()
|
d = self._shutdown()
|
||||||
|
@ -711,7 +734,6 @@ class LBRYDaemon(xmlrpc.XMLRPC):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def _disp(info):
|
def _disp(info):
|
||||||
log.debug('[' + str(datetime.now()) + ']' + ' Resolved info: ' + str(info['stream_hash']))
|
|
||||||
print '[' + str(datetime.now()) + ']' + ' Resolved info: ' + str(info['stream_hash'])
|
print '[' + str(datetime.now()) + ']' + ' Resolved info: ' + str(info['stream_hash'])
|
||||||
return info
|
return info
|
||||||
|
|
||||||
|
@ -813,13 +835,6 @@ class LBRYDaemon(xmlrpc.XMLRPC):
|
||||||
@return:
|
@return:
|
||||||
"""
|
"""
|
||||||
|
|
||||||
#def _return_d(x):
|
|
||||||
# d = defer.Deferred()
|
|
||||||
# d.addCallback(lambda _: x)
|
|
||||||
# d.callback(None)
|
|
||||||
|
|
||||||
# return d
|
|
||||||
|
|
||||||
def _clean(n):
|
def _clean(n):
|
||||||
t = []
|
t = []
|
||||||
for i in n:
|
for i in n:
|
||||||
|
@ -861,9 +876,13 @@ class LBRYDaemon(xmlrpc.XMLRPC):
|
||||||
|
|
||||||
def _disp(results):
|
def _disp(results):
|
||||||
print '[' + str(datetime.now()) + '] Found ' + str(len(results)) + ' 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
|
return results
|
||||||
|
|
||||||
print '[' + str(datetime.now()) + '] Search nametrie: ' + search
|
print '[' + str(datetime.now()) + '] Search nametrie: ' + search
|
||||||
|
log.info('[' + str(datetime.now()) + '] Search nametrie: ' + search)
|
||||||
|
|
||||||
d = self.session.wallet.get_nametrie()
|
d = self.session.wallet.get_nametrie()
|
||||||
d.addCallback(lambda trie: [claim for claim in trie if claim['name'].startswith(search) and 'txid' in claim])
|
d.addCallback(lambda trie: [claim for claim in trie if claim['name'].startswith(search) and 'txid' in claim])
|
||||||
|
@ -944,6 +963,9 @@ class LBRYDaemon(xmlrpc.XMLRPC):
|
||||||
else:
|
else:
|
||||||
content_license = None
|
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)
|
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)
|
d = p.start(name, file_path, bid, title, description, thumbnail, key_fee, key_fee_address, content_license)
|
||||||
|
|
||||||
|
@ -981,6 +1003,15 @@ class LBRYDaemon(xmlrpc.XMLRPC):
|
||||||
|
|
||||||
return d
|
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 xmlrpc_update_name(self, metadata):
|
||||||
# def _disp(x):
|
# def _disp(x):
|
||||||
# print x
|
# print x
|
||||||
|
@ -1042,17 +1073,28 @@ class LBRYDaemon(xmlrpc.XMLRPC):
|
||||||
|
|
||||||
|
|
||||||
def main():
|
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:
|
try:
|
||||||
d = xmlrpclib.ServerProxy('http://localhost:7080')
|
daemon = xmlrpclib.ServerProxy("http://localhost:7080")
|
||||||
d.stop()
|
daemon.stop()
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
daemon = LBRYDaemon()
|
daemon = LBRYDaemon()
|
||||||
daemon.setup()
|
daemon.setup(args.wallet, args.update)
|
||||||
reactor.listenTCP(7080, server.Site(daemon))
|
reactor.listenTCP(7080, server.Site(daemon), interface='localhost')
|
||||||
reactor.run()
|
reactor.run()
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
|
||||||
|
|
|
@ -4,12 +4,11 @@ import xmlrpclib
|
||||||
def main():
|
def main():
|
||||||
daemon = xmlrpclib.ServerProxy("http://localhost:7080/")
|
daemon = xmlrpclib.ServerProxy("http://localhost:7080/")
|
||||||
try:
|
try:
|
||||||
b = daemon.get_balance()
|
status = daemon.is_running()
|
||||||
is_running = True
|
|
||||||
except:
|
except:
|
||||||
is_running = False
|
status = False
|
||||||
|
|
||||||
if is_running:
|
if status:
|
||||||
daemon.stop()
|
daemon.stop()
|
||||||
print "LBRYnet daemon stopped"
|
print "LBRYnet daemon stopped"
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -1,15 +1,71 @@
|
||||||
import rumps
|
import rumps
|
||||||
import xmlrpclib
|
import xmlrpclib
|
||||||
import os
|
import os
|
||||||
|
import webbrowser
|
||||||
|
|
||||||
|
|
||||||
class DaemonStatusBarApp(rumps.App):
|
class DaemonStatusBarApp(rumps.App):
|
||||||
def __init__(self):
|
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)
|
icon_path = os.path.join(os.path.expanduser("~"), "Downloads/lbryio/web/img/fav/apple-touch-icon.png")
|
||||||
self.menu = ["Quit"]
|
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.clicked('Open')
|
||||||
|
def get_ui(self):
|
||||||
|
try:
|
||||||
|
daemon = xmlrpclib.ServerProxy('http://localhost:7080')
|
||||||
|
daemon.is_running()
|
||||||
|
webbrowser.open("lbry://lbry")
|
||||||
|
except:
|
||||||
|
try:
|
||||||
|
rumps.notification(title='LBRY', subtitle='status', 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, _):
|
||||||
|
try:
|
||||||
|
daemon = xmlrpclib.ServerProxy('http://localhost:7080')
|
||||||
|
daemon.is_running()
|
||||||
|
webbrowser.open("lbry://settings")
|
||||||
|
except:
|
||||||
|
rumps.notification(title='LBRY', subtitle='status', 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()
|
||||||
|
try:
|
||||||
|
rumps.notification(title='LBRY', subtitle='status', message="Your balance is " + str(balance), sound=False)
|
||||||
|
except:
|
||||||
|
rumps.alert(title='LBRY', message="Your balance is " + str(balance))
|
||||||
|
|
||||||
|
except:
|
||||||
|
try:
|
||||||
|
rumps.notification(title='LBRY', subtitle='status', message="Couldn't connect to lbrynet daemon", sound=True)
|
||||||
|
except:
|
||||||
|
rumps.alert(title='LBRY', message="Couldn't connect to lbrynet daemon")
|
||||||
|
|
||||||
@rumps.clicked('Quit')
|
@rumps.clicked('Quit')
|
||||||
def clean_quit(self):
|
def clean_quit(self):
|
||||||
d = xmlrpclib.ServerProxy('http://localhost:7080')
|
daemon = xmlrpclib.ServerProxy('http://localhost:7080')
|
||||||
d.stop()
|
try:
|
||||||
|
daemon.stop()
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
rumps.quit_application()
|
rumps.quit_application()
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
status_app = DaemonStatusBarApp()
|
||||||
|
status_app.run()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
|
@ -59,7 +59,7 @@ else
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! python -c "import six; exit(0) if six.__version__ == '1.9.0' else exit(1)" &>/dev/null; then
|
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
|
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
|
tar xf six-1.9.0.tar.gz &>/dev/null
|
||||||
cd six-1.9.0
|
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
|
fi
|
||||||
|
|
||||||
lbrynet_directory="/Users/${SUDO_USER}/Library/Application Support/lbrynet"
|
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)
|
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"
|
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
|
cd lbry
|
||||||
|
|
||||||
echo "Installing update"
|
echo "Installing update..."
|
||||||
sudo python setup.py install &>/dev/null
|
sudo python setup.py install &>/dev/null
|
||||||
mkdir -p "$lbrynet_directory"
|
mkdir -p "$lbrynet_directory"
|
||||||
echo $lbrynet_current_version > "${lbrynet_directory}/lbrynet_version.txt"
|
echo $lbrynet_current_version > "${lbrynet_directory}/lbrynet_version.txt"
|
||||||
|
|
||||||
echo "Cleaning up"
|
echo "Cleaning up..."
|
||||||
|
|
||||||
cd ../../
|
cd ../../
|
||||||
rm -rf $tmp
|
rm -rf $tmp
|
||||||
|
@ -100,63 +145,17 @@ if [ -d "$lbrynet_directory" ]; then
|
||||||
tmp=$(mktemp -d)
|
tmp=$(mktemp -d)
|
||||||
cd $tmp
|
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
|
cd lbry
|
||||||
|
|
||||||
echo "Installing update"
|
echo "Installing..."
|
||||||
sudo python setup.py install &>/dev/null
|
sudo python setup.py install &>/dev/null
|
||||||
mkdir -p "$lbrynet_directory"
|
mkdir -p "$lbrynet_directory"
|
||||||
echo $lbrynet_current_version > "${lbrynet_directory}/lbrynet_version.txt"
|
echo $lbrynet_current_version > "${lbrynet_directory}/lbrynet_version.txt"
|
||||||
|
|
||||||
echo "Cleaning up"
|
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"
|
|
||||||
|
|
||||||
cd ../../
|
cd ../../
|
||||||
rm -rf $tmp
|
rm -rf $tmp
|
||||||
|
|
24
setup.py
24
setup.py
|
@ -2,16 +2,10 @@
|
||||||
|
|
||||||
import ez_setup
|
import ez_setup
|
||||||
ez_setup.use_setuptools()
|
ez_setup.use_setuptools()
|
||||||
|
|
||||||
from setuptools import setup, find_packages
|
from setuptools import setup, find_packages
|
||||||
|
import sys
|
||||||
|
|
||||||
setup(name='lbrynet',
|
console_scripts = ['lbrynet-console = lbrynet.lbrynet_console.LBRYConsole:launch_lbry_console',
|
||||||
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-stdin-uploader = lbrynet.lbrynet_console.LBRYStdinUploader:launch_stdin_uploader',
|
||||||
'lbrynet-stdout-downloader = lbrynet.lbrynet_console.LBRYStdoutDownloader:launch_stdout_downloader',
|
'lbrynet-stdout-downloader = lbrynet.lbrynet_console.LBRYStdoutDownloader:launch_stdout_downloader',
|
||||||
'lbrynet-create-network = lbrynet.create_network:main',
|
'lbrynet-create-network = lbrynet.create_network:main',
|
||||||
|
@ -22,9 +16,17 @@ setup(name='lbrynet',
|
||||||
'lbrynet-lookup-hosts-for-hash = lbrynet.dht_scripts:get_hosts_for_hash_in_dht',
|
'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-announce_hash_to_dht = lbrynet.dht_scripts:announce_hash_to_dht',
|
||||||
'lbrynet-daemon = lbrynet.lbrynet_daemon.LBRYDaemon:main',
|
'lbrynet-daemon = lbrynet.lbrynet_daemon.LBRYDaemon:main',
|
||||||
'stop-lbrynet-daemon = lbrynet.lbrynet_daemon.LBRYDaemonStopper:main',
|
'stop-lbrynet-daemon = lbrynet.lbrynet_daemon.LBRYDaemonStopper:main']
|
||||||
]
|
|
||||||
},
|
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': console_scripts},
|
||||||
data_files=[
|
data_files=[
|
||||||
('lbrynet/lbrynet_console/plugins',
|
('lbrynet/lbrynet_console/plugins',
|
||||||
[
|
[
|
||||||
|
|
|
@ -7,9 +7,8 @@ from slackclient import SlackClient
|
||||||
def get_conf():
|
def get_conf():
|
||||||
f = open('testbot.conf', 'r')
|
f = open('testbot.conf', 'r')
|
||||||
token = f.readline().replace('\n', '')
|
token = f.readline().replace('\n', '')
|
||||||
channel = f.readline().replace('\n', '')
|
|
||||||
f.close()
|
f.close()
|
||||||
return token, channel
|
return token
|
||||||
|
|
||||||
def test_lbrynet(lbry, slack, channel):
|
def test_lbrynet(lbry, slack, channel):
|
||||||
logfile = open('lbrynet_test_log.txt', 'a')
|
logfile = open('lbrynet_test_log.txt', 'a')
|
||||||
|
@ -48,10 +47,11 @@ def test_lbrynet(lbry, slack, channel):
|
||||||
lbry.delete_lbry_file('test.jpg')
|
lbry.delete_lbry_file('test.jpg')
|
||||||
logfile.close()
|
logfile.close()
|
||||||
|
|
||||||
token, channel = get_conf()
|
token = get_conf()
|
||||||
|
|
||||||
sc = SlackClient(token)
|
sc = SlackClient(token)
|
||||||
sc.rtm_connect()
|
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'
|
print 'Connected to slack'
|
||||||
daemon = xmlrpclib.ServerProxy("http://localhost:7080")
|
daemon = xmlrpclib.ServerProxy("http://localhost:7080")
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue