fix conflicts
This commit is contained in:
commit
ef62b0e746
2 changed files with 219 additions and 133 deletions
|
@ -28,10 +28,8 @@ from lbrynet.lbryfile.client.LBRYFileOptions import add_lbry_file_to_sd_identifi
|
||||||
from lbrynet.lbryfile.client.LBRYFileDownloader import LBRYFileOpenerFactory
|
from lbrynet.lbryfile.client.LBRYFileDownloader import LBRYFileOpenerFactory
|
||||||
from lbrynet.lbryfile.StreamDescriptor import LBRYFileStreamType
|
from lbrynet.lbryfile.StreamDescriptor import LBRYFileStreamType
|
||||||
from lbrynet.lbryfile.LBRYFileMetadataManager import DBLBRYFileMetadataManager, TempLBRYFileMetadataManager
|
from lbrynet.lbryfile.LBRYFileMetadataManager import DBLBRYFileMetadataManager, TempLBRYFileMetadataManager
|
||||||
#from lbrynet.lbrylive.PaymentRateManager import LiveStreamPaymentRateManager
|
|
||||||
from lbrynet.lbrynet_console.ControlHandlers import ApplicationStatusFactory, GetWalletBalancesFactory, ShutDownFactory
|
from lbrynet.lbrynet_console.ControlHandlers import ApplicationStatusFactory, GetWalletBalancesFactory, ShutDownFactory
|
||||||
#from lbrynet.lbrynet_console.ControlHandlers import AutoFetcherStartFactory, AutoFetcherStopFactory
|
from lbrynet.lbrynet_console.ControlHandlers import ImmediateAnnounceAllBlobsFactory
|
||||||
from lbrynet.lbrynet_console.ControlHandlers import ImmediateAnnounceAllBlobsFactory #, AutoFetcherStatusFactory
|
|
||||||
from lbrynet.lbrynet_console.ControlHandlers import LBRYFileStatusFactory, DeleteLBRYFileChooserFactory
|
from lbrynet.lbrynet_console.ControlHandlers import LBRYFileStatusFactory, DeleteLBRYFileChooserFactory
|
||||||
from lbrynet.lbrynet_console.ControlHandlers import ToggleLBRYFileRunningChooserFactory
|
from lbrynet.lbrynet_console.ControlHandlers import ToggleLBRYFileRunningChooserFactory
|
||||||
from lbrynet.lbrynet_console.ControlHandlers import ModifyApplicationDefaultsFactory
|
from lbrynet.lbrynet_console.ControlHandlers import ModifyApplicationDefaultsFactory
|
||||||
|
@ -54,9 +52,9 @@ alert = logging.getLogger("lbryalert." + __name__)
|
||||||
|
|
||||||
class LBRYConsole():
|
class LBRYConsole():
|
||||||
"""A class which can upload and download file streams to and from the network"""
|
"""A class which can upload and download file streams to and from the network"""
|
||||||
def __init__(self, peer_port, dht_node_port, known_dht_nodes, wallet_type,
|
def __init__(self, peer_port, dht_node_port, known_dht_nodes, fake_wallet,
|
||||||
lbrycrd_conf, lbrycrd_dir, use_upnp, data_dir, created_data_dir,
|
lbrycrd_conf, lbrycrd_dir, use_upnp, data_dir, created_data_dir,
|
||||||
lbrycrdd_path, start_lbrycrdd):
|
lbrycrdd_path):
|
||||||
"""
|
"""
|
||||||
@param peer_port: the network port on which to listen for peers
|
@param peer_port: the network port on which to listen for peers
|
||||||
|
|
||||||
|
@ -67,7 +65,7 @@ class LBRYConsole():
|
||||||
self.peer_port = peer_port
|
self.peer_port = peer_port
|
||||||
self.dht_node_port = dht_node_port
|
self.dht_node_port = dht_node_port
|
||||||
self.known_dht_nodes = known_dht_nodes
|
self.known_dht_nodes = known_dht_nodes
|
||||||
self.wallet_type = wallet_type
|
self.fake_wallet = fake_wallet
|
||||||
self.lbrycrd_conf = lbrycrd_conf
|
self.lbrycrd_conf = lbrycrd_conf
|
||||||
self.lbrycrd_dir = lbrycrd_dir
|
self.lbrycrd_dir = lbrycrd_dir
|
||||||
if not self.lbrycrd_dir:
|
if not self.lbrycrd_dir:
|
||||||
|
@ -77,10 +75,7 @@ class LBRYConsole():
|
||||||
self.lbrycrd_dir = os.path.join(os.path.expanduser("~"), ".lbrycrd")
|
self.lbrycrd_dir = os.path.join(os.path.expanduser("~"), ".lbrycrd")
|
||||||
if not self.lbrycrd_conf:
|
if not self.lbrycrd_conf:
|
||||||
self.lbrycrd_conf = os.path.join(self.lbrycrd_dir, "lbrycrd.conf")
|
self.lbrycrd_conf = os.path.join(self.lbrycrd_dir, "lbrycrd.conf")
|
||||||
# self.autofetcher_conf = os.path.join(self.lbrycrd_dir, "autofetcher.conf")
|
|
||||||
self.lbrycrdd_path = lbrycrdd_path
|
self.lbrycrdd_path = lbrycrdd_path
|
||||||
self.default_lbrycrdd_path = "./lbrycrdd"
|
|
||||||
self.start_lbrycrdd = start_lbrycrdd
|
|
||||||
self.use_upnp = use_upnp
|
self.use_upnp = use_upnp
|
||||||
self.lbry_server_port = None
|
self.lbry_server_port = None
|
||||||
self.session = None
|
self.session = None
|
||||||
|
@ -104,7 +99,6 @@ class LBRYConsole():
|
||||||
self.sd_identifier = StreamDescriptorIdentifier()
|
self.sd_identifier = StreamDescriptorIdentifier()
|
||||||
self.plugin_objects = []
|
self.plugin_objects = []
|
||||||
self.db_migration_revisions = None
|
self.db_migration_revisions = None
|
||||||
# self.autofetcher = None
|
|
||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
"""Initialize the session and restore everything to its saved state"""
|
"""Initialize the session and restore everything to its saved state"""
|
||||||
|
@ -116,7 +110,6 @@ class LBRYConsole():
|
||||||
d.addCallback(lambda _: add_lbry_file_to_sd_identifier(self.sd_identifier))
|
d.addCallback(lambda _: add_lbry_file_to_sd_identifier(self.sd_identifier))
|
||||||
d.addCallback(lambda _: self._setup_lbry_file_manager())
|
d.addCallback(lambda _: self._setup_lbry_file_manager())
|
||||||
d.addCallback(lambda _: self._setup_lbry_file_opener())
|
d.addCallback(lambda _: self._setup_lbry_file_opener())
|
||||||
#d.addCallback(lambda _: self._get_autofetcher())
|
|
||||||
d.addCallback(lambda _: self._setup_control_handlers())
|
d.addCallback(lambda _: self._setup_control_handlers())
|
||||||
d.addCallback(lambda _: self._setup_query_handlers())
|
d.addCallback(lambda _: self._setup_query_handlers())
|
||||||
d.addCallback(lambda _: self._load_plugins())
|
d.addCallback(lambda _: self._load_plugins())
|
||||||
|
@ -125,10 +118,6 @@ class LBRYConsole():
|
||||||
d.addErrback(self._show_start_error)
|
d.addErrback(self._show_start_error)
|
||||||
return d
|
return d
|
||||||
|
|
||||||
# def _get_autofetcher(self):
|
|
||||||
# self.autofetcher = AutoFetcher(self.session, self.lbry_file_manager, self.lbry_file_metadata_manager,
|
|
||||||
# self.session.wallet, self.sd_identifier, self.autofetcher_conf)
|
|
||||||
|
|
||||||
def _show_start_error(self, error):
|
def _show_start_error(self, error):
|
||||||
print error.getTraceback()
|
print error.getTraceback()
|
||||||
log.error("An error occurred during start up: %s", error.getTraceback())
|
log.error("An error occurred during start up: %s", error.getTraceback())
|
||||||
|
@ -205,30 +194,6 @@ class LBRYConsole():
|
||||||
d = self.settings.start()
|
d = self.settings.start()
|
||||||
d.addCallback(lambda _: self.settings.get_lbryid())
|
d.addCallback(lambda _: self.settings.get_lbryid())
|
||||||
d.addCallback(self.set_lbryid)
|
d.addCallback(self.set_lbryid)
|
||||||
d.addCallback(lambda _: self.get_lbrycrdd_path())
|
|
||||||
return d
|
|
||||||
|
|
||||||
def get_lbrycrdd_path(self):
|
|
||||||
|
|
||||||
if not self.start_lbrycrdd:
|
|
||||||
return defer.succeed(None)
|
|
||||||
|
|
||||||
def get_lbrycrdd_path_conf_file():
|
|
||||||
lbrycrdd_path_conf_path = os.path.join(os.path.expanduser("~"), ".lbrycrddpath.conf")
|
|
||||||
if not os.path.exists(lbrycrdd_path_conf_path):
|
|
||||||
return ""
|
|
||||||
lbrycrdd_path_conf = open(lbrycrdd_path_conf_path)
|
|
||||||
lines = lbrycrdd_path_conf.readlines()
|
|
||||||
return lines
|
|
||||||
|
|
||||||
d = threads.deferToThread(get_lbrycrdd_path_conf_file)
|
|
||||||
|
|
||||||
def load_lbrycrdd_path(conf):
|
|
||||||
for line in conf:
|
|
||||||
if len(line.strip()) and line.strip()[0] != "#":
|
|
||||||
self.lbrycrdd_path = line.strip()
|
|
||||||
|
|
||||||
d.addCallback(load_lbrycrdd_path)
|
|
||||||
return d
|
return d
|
||||||
|
|
||||||
def set_lbryid(self, lbryid):
|
def set_lbryid(self, lbryid):
|
||||||
|
@ -249,21 +214,14 @@ class LBRYConsole():
|
||||||
return d
|
return d
|
||||||
|
|
||||||
def get_wallet():
|
def get_wallet():
|
||||||
if self.wallet_type == "lbrycrd":
|
if self.fake_wallet:
|
||||||
lbrycrdd_path = None
|
d = defer.succeed(PTCWallet(self.db_dir))
|
||||||
if self.start_lbrycrdd is True:
|
elif self.lbrycrdd_path is not None:
|
||||||
lbrycrdd_path = self.lbrycrdd_path
|
|
||||||
if not lbrycrdd_path:
|
|
||||||
lbrycrdd_path = self.default_lbrycrdd_path
|
|
||||||
d = defer.succeed(LBRYcrdWallet(self.db_dir, wallet_dir=self.lbrycrd_dir,
|
d = defer.succeed(LBRYcrdWallet(self.db_dir, wallet_dir=self.lbrycrd_dir,
|
||||||
wallet_conf=self.lbrycrd_conf,
|
wallet_conf=self.lbrycrd_conf,
|
||||||
lbrycrdd_path=lbrycrdd_path))
|
lbrycrdd_path=self.lbrycrdd_path))
|
||||||
elif self.wallet_type == 'ptc':
|
|
||||||
d = defer.succeed(PTCWallet(self.db_dir))
|
|
||||||
elif self.wallet_type == 'lbryum':
|
|
||||||
d = defer.succeed(LBRYumWallet(self.db_dir))
|
|
||||||
else:
|
else:
|
||||||
d = defer.fail(Failure(ValueError("Invalid wallet type")))
|
d = defer.succeed(LBRYumWallet(self.db_dir))
|
||||||
d.addCallback(lambda wallet: {"wallet": wallet})
|
d.addCallback(lambda wallet: {"wallet": wallet})
|
||||||
return d
|
return d
|
||||||
|
|
||||||
|
@ -381,14 +339,11 @@ class LBRYConsole():
|
||||||
ModifyLBRYFileOptionsChooserFactory(self.lbry_file_manager),
|
ModifyLBRYFileOptionsChooserFactory(self.lbry_file_manager),
|
||||||
AddStreamFromHashFactory(self.sd_identifier, self.session, self.session.wallet),
|
AddStreamFromHashFactory(self.sd_identifier, self.session, self.session.wallet),
|
||||||
StatusFactory(self, self.session.rate_limiter, self.lbry_file_manager,
|
StatusFactory(self, self.session.rate_limiter, self.lbry_file_manager,
|
||||||
self.session.blob_manager, self.session.wallet if self.wallet_type in ['lbrycrd', 'lbryum'] else None),
|
self.session.blob_manager, self.session.wallet if not self.fake_wallet else None),
|
||||||
# AutoFetcherStartFactory(self.autofetcher),
|
|
||||||
# AutoFetcherStopFactory(self.autofetcher),
|
|
||||||
# AutoFetcherStatusFactory(self.autofetcher),
|
|
||||||
ImmediateAnnounceAllBlobsFactory(self.session.blob_manager)
|
ImmediateAnnounceAllBlobsFactory(self.session.blob_manager)
|
||||||
]
|
]
|
||||||
self.add_control_handlers(handlers)
|
self.add_control_handlers(handlers)
|
||||||
if self.wallet_type in ['lbrycrd', 'lbryum']:
|
if not self.fake_wallet:
|
||||||
lbrycrd_handlers = [
|
lbrycrd_handlers = [
|
||||||
AddStreamFromLBRYcrdNameFactory(self.sd_identifier, self.session,
|
AddStreamFromLBRYcrdNameFactory(self.sd_identifier, self.session,
|
||||||
self.session.wallet),
|
self.session.wallet),
|
||||||
|
@ -540,15 +495,9 @@ def launch_lbry_console():
|
||||||
parser.add_argument("--dht_node_port",
|
parser.add_argument("--dht_node_port",
|
||||||
help="The port on which the console will listen for DHT connections.",
|
help="The port on which the console will listen for DHT connections.",
|
||||||
type=int, default=4444)
|
type=int, default=4444)
|
||||||
parser.add_argument("--wallet_type",
|
parser.add_argument("--fake_wallet",
|
||||||
help="Either 'lbrycrd' or 'ptc' or 'lbryum'.",
|
help="Testing purposes only. Use a non-blockchain wallet.",
|
||||||
type=str, default="lbrycrd")
|
action="store_true")
|
||||||
parser.add_argument("--lbrycrd_wallet_dir",
|
|
||||||
help="The directory in which lbrycrd data will stored. Used if lbrycrdd is "
|
|
||||||
"launched by this application.")
|
|
||||||
parser.add_argument("--lbrycrd_wallet_conf",
|
|
||||||
help="The configuration file for the LBRYcrd wallet. Default: ~/.lbrycrd/lbrycrd.conf",
|
|
||||||
type=str)
|
|
||||||
parser.add_argument("--no_dht_bootstrap",
|
parser.add_argument("--no_dht_bootstrap",
|
||||||
help="Don't try to connect to the DHT",
|
help="Don't try to connect to the DHT",
|
||||||
action="store_true")
|
action="store_true")
|
||||||
|
@ -568,12 +517,15 @@ def launch_lbry_console():
|
||||||
"Default: ~/.lbrynet on linux, ~/Library/Application Support/lbrynet on OS X"),
|
"Default: ~/.lbrynet on linux, ~/Library/Application Support/lbrynet on OS X"),
|
||||||
type=str)
|
type=str)
|
||||||
parser.add_argument("--lbrycrdd_path",
|
parser.add_argument("--lbrycrdd_path",
|
||||||
help="The path to lbrycrdd, which will be launched if it isn't running, unless "
|
help="The path to lbrycrdd, which will be launched if it isn't running. If"
|
||||||
"launching lbrycrdd is disabled by --disable_launch_lbrycrdd. By default, "
|
"this option is chosen, lbrycrdd will be used as the interface to the"
|
||||||
"the file ~/.lbrycrddpath.conf will be checked, and if no path is found "
|
"blockchain. By default, a lightweight interface is used.")
|
||||||
"there, it will be ./lbrycrdd")
|
parser.add_argument("--lbrycrd_wallet_dir",
|
||||||
parser.add_argument("--disable_launch_lbrycrdd",
|
help="The directory in which lbrycrd data will stored. Used if lbrycrdd is "
|
||||||
help="Don't launch lbrycrdd even if it's not running.")
|
"launched by this application.")
|
||||||
|
parser.add_argument("--lbrycrd_wallet_conf",
|
||||||
|
help="The configuration file for the LBRYcrd wallet. Default: ~/.lbrycrd/lbrycrd.conf",
|
||||||
|
type=str)
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
@ -604,6 +556,7 @@ def launch_lbry_console():
|
||||||
os.mkdir(data_dir)
|
os.mkdir(data_dir)
|
||||||
created_data_dir = True
|
created_data_dir = True
|
||||||
|
|
||||||
|
|
||||||
log_format = "(%(asctime)s)[%(filename)s:%(lineno)s] %(funcName)s(): %(message)s"
|
log_format = "(%(asctime)s)[%(filename)s:%(lineno)s] %(funcName)s(): %(message)s"
|
||||||
formatter = logging.Formatter(log_format)
|
formatter = logging.Formatter(log_format)
|
||||||
|
|
||||||
|
@ -614,11 +567,10 @@ def launch_lbry_console():
|
||||||
file_handler.addFilter(logging.Filter("lbrynet"))
|
file_handler.addFilter(logging.Filter("lbrynet"))
|
||||||
logger.addHandler(file_handler)
|
logger.addHandler(file_handler)
|
||||||
|
|
||||||
console = LBRYConsole(peer_port, dht_node_port, bootstrap_nodes, wallet_type=args.wallet_type,
|
console = LBRYConsole(peer_port, dht_node_port, bootstrap_nodes, fake_wallet=args.fake_wallet,
|
||||||
lbrycrd_conf=args.lbrycrd_wallet_conf, lbrycrd_dir=args.lbrycrd_wallet_dir,
|
lbrycrd_conf=args.lbrycrd_wallet_conf, lbrycrd_dir=args.lbrycrd_wallet_dir,
|
||||||
use_upnp=not args.disable_upnp, data_dir=data_dir,
|
use_upnp=not args.disable_upnp, data_dir=data_dir,
|
||||||
created_data_dir=created_data_dir, lbrycrdd_path=args.lbrycrdd_path,
|
created_data_dir=created_data_dir, lbrycrdd_path=args.lbrycrdd_path)
|
||||||
start_lbrycrdd=not args.disable_launch_lbrycrdd)
|
|
||||||
|
|
||||||
d = task.deferLater(reactor, 0, console.start)
|
d = task.deferLater(reactor, 0, console.start)
|
||||||
|
|
||||||
|
|
|
@ -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.PaymentRateManager import PaymentRateManager
|
||||||
from lbrynet.core.server.BlobAvailabilityHandler import BlobAvailabilityHandlerFactory
|
from lbrynet.core.server.BlobAvailabilityHandler import BlobAvailabilityHandlerFactory
|
||||||
from lbrynet.core.server.BlobRequestHandler import BlobRequestHandlerFactory
|
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.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,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.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.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__)
|
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
|
||||||
|
|
||||||
# issues with delete:
|
# issues with delete:
|
||||||
|
@ -46,8 +61,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,7 +72,6 @@ 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")
|
||||||
# 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
|
||||||
self.dht_node_port = 4444
|
self.dht_node_port = 4444
|
||||||
|
@ -93,10 +107,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)
|
||||||
|
@ -106,6 +120,8 @@ class LBRYDaemon(xmlrpc.XMLRPC):
|
||||||
self.max_key_fee = DEFAULT_MAX_KEY_FEE
|
self.max_key_fee = DEFAULT_MAX_KEY_FEE
|
||||||
self.max_search_results = DEFAULT_MAX_SEARCH_RESULTS
|
self.max_search_results = DEFAULT_MAX_SEARCH_RESULTS
|
||||||
self.restart_message = ""
|
self.restart_message = ""
|
||||||
|
self.startup_message = ""
|
||||||
|
self.announced_startup = False
|
||||||
self.search_timeout = 3.0
|
self.search_timeout = 3.0
|
||||||
self.query_handlers = {}
|
self.query_handlers = {}
|
||||||
|
|
||||||
|
@ -117,11 +133,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())
|
||||||
|
@ -136,6 +155,8 @@ class LBRYDaemon(xmlrpc.XMLRPC):
|
||||||
# if sys.platform == "darwin":
|
# if sys.platform == "darwin":
|
||||||
# d.addCallback(lambda _: self._update())
|
# d.addCallback(lambda _: self._update())
|
||||||
# d.addCallback(lambda _: self.status_app.run())
|
# 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 _: self._setup_fetcher())
|
||||||
d.addCallback(lambda _: _disp_startup())
|
d.addCallback(lambda _: _disp_startup())
|
||||||
d.callback(None)
|
d.callback(None)
|
||||||
|
@ -213,10 +234,9 @@ class LBRYDaemon(xmlrpc.XMLRPC):
|
||||||
|
|
||||||
d = _check_for_updater()
|
d = _check_for_updater()
|
||||||
d.addCallback(lambda _: _update_lbrynet())
|
d.addCallback(lambda _: _update_lbrynet())
|
||||||
d.addCallback(lambda _: _update_lbrycrdd())
|
d.addCallback(lambda _: _update_lbrycrdd() if self.wallet_type == 'lbrycrd' else _update_lbryum())
|
||||||
d.addCallback(lambda _: _update_lbryum())
|
|
||||||
d.addCallback(lambda _: os.system("open /Applications/LBRY\ Updater.app &>/dev/null") if self.restart_message
|
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))
|
d.addCallbacks(lambda _: self._restart() if self.restart_message else defer.succeed(None))
|
||||||
|
|
||||||
return defer.succeed(None)
|
return defer.succeed(None)
|
||||||
|
@ -310,8 +330,6 @@ class LBRYDaemon(xmlrpc.XMLRPC):
|
||||||
d = self._stop_server()
|
d = self._stop_server()
|
||||||
if self.session is not None:
|
if self.session is not None:
|
||||||
d.addCallback(lambda _: self.session.shut_down())
|
d.addCallback(lambda _: self.session.shut_down())
|
||||||
# if self.status_app:
|
|
||||||
# d.addCallback(lambda _: self.status_app.stop())
|
|
||||||
return d
|
return d
|
||||||
|
|
||||||
def _update_settings(self):
|
def _update_settings(self):
|
||||||
|
@ -397,6 +415,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 +424,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
|
||||||
|
|
||||||
|
@ -429,8 +458,45 @@ class LBRYDaemon(xmlrpc.XMLRPC):
|
||||||
dl.addCallback(combine_results)
|
dl.addCallback(combine_results)
|
||||||
dl.addCallback(create_session)
|
dl.addCallback(create_session)
|
||||||
dl.addCallback(lambda _: self.session.setup())
|
dl.addCallback(lambda _: self.session.setup())
|
||||||
|
dl.addCallback(lambda _: self._check_first_run())
|
||||||
|
dl.addCallback(self._show_first_run_result)
|
||||||
return dl
|
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(self):
|
||||||
def get_lbrycrdd_path_conf_file():
|
def get_lbrycrdd_path_conf_file():
|
||||||
lbrycrdd_path_conf_path = os.path.join(os.path.expanduser("~"), ".lbrycrddpath.conf")
|
lbrycrdd_path_conf_path = os.path.join(os.path.expanduser("~"), ".lbrycrddpath.conf")
|
||||||
|
@ -530,9 +596,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 +646,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)
|
||||||
|
|
||||||
|
@ -601,7 +671,14 @@ class LBRYDaemon(xmlrpc.XMLRPC):
|
||||||
return d
|
return d
|
||||||
|
|
||||||
def xmlrpc_is_running(self):
|
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):
|
def xmlrpc_get_settings(self):
|
||||||
"""
|
"""
|
||||||
|
@ -636,6 +713,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 +723,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 +748,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 +791,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
|
||||||
|
|
||||||
|
@ -782,6 +861,7 @@ class LBRYDaemon(xmlrpc.XMLRPC):
|
||||||
|
|
||||||
d = defer.Deferred()
|
d = defer.Deferred()
|
||||||
d.addCallback(lambda _: _make_file(html, path))
|
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.addCallback(lambda _: webbrowser.open('file://' + path))
|
||||||
d.addErrback(_disp_err)
|
d.addErrback(_disp_err)
|
||||||
d.callback(None)
|
d.callback(None)
|
||||||
|
@ -813,13 +893,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 +934,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 +1021,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 +1061,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
|
||||||
|
@ -1010,49 +1099,94 @@ class LBRYDaemon(xmlrpc.XMLRPC):
|
||||||
return self.fetcher.verbose
|
return self.fetcher.verbose
|
||||||
|
|
||||||
def xmlrpc_check_for_new_version(self):
|
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 git_version == current_version:
|
||||||
if os.path.isfile(os.path.join(self.db_dir, "lbrynet_version.txt")):
|
r = package['name'] + " is up to date"
|
||||||
f = open(os.path.join(self.db_dir, "lbrynet_version.txt"), 'r')
|
up_to_date = True
|
||||||
current_version = f.read()
|
else:
|
||||||
f.close()
|
r = package['name'] + " version is out of date"
|
||||||
|
|
||||||
if git_version == current_version:
|
|
||||||
message += "LBRYnet is up to date\n"
|
|
||||||
else:
|
else:
|
||||||
message += "LBRYnet version is out of date, restart the daemon to update\n"
|
r = "Unknown version of " + package['name']
|
||||||
else:
|
|
||||||
message += "Unknown version of LBRYnet, try running installer again\n"
|
|
||||||
|
|
||||||
git_version = subprocess.check_output("git ls-remote https://github.com/jackrobison/lbrynet-app.git | grep HEAD | cut -f 1", shell=True)
|
return (up_to_date, r)
|
||||||
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()
|
|
||||||
|
|
||||||
if git_version == current_version:
|
package_infos = {
|
||||||
message += "LBRY is up to date"
|
"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:
|
else:
|
||||||
message += "LBRY version is out of date, restart the daemon to update"
|
return "Couldn't find LBRY.app, try running the installer"
|
||||||
else:
|
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():
|
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__':
|
|
||||||
main()
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
Loading…
Reference in a new issue