forked from LBRYCommunity/lbry-sdk
Merge branch 'master' of github.com:lbryio/lbry
This commit is contained in:
commit
7837738c17
3 changed files with 85 additions and 28 deletions
|
@ -8,6 +8,7 @@ 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
|
||||||
|
@ -21,18 +22,11 @@ from lbrynet.lbryfile.LBRYFileMetadataManager import DBLBRYFileMetadataManager,
|
||||||
from twisted.web import xmlrpc, server
|
from twisted.web import xmlrpc, server
|
||||||
from twisted.internet import defer, threads, reactor, error
|
from twisted.internet import defer, threads, reactor, error
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
import logging
|
|
||||||
import os
|
|
||||||
import sys
|
|
||||||
import json
|
|
||||||
import binascii
|
|
||||||
import webbrowser
|
|
||||||
import xmlrpclib
|
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
import subprocess
|
|
||||||
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
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -63,6 +57,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")
|
||||||
|
# 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
|
||||||
|
@ -140,6 +135,7 @@ class LBRYDaemon(xmlrpc.XMLRPC):
|
||||||
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())
|
||||||
|
# d.addCallback(lambda _: 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)
|
||||||
|
@ -294,6 +290,8 @@ 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):
|
||||||
|
@ -565,12 +563,6 @@ class LBRYDaemon(xmlrpc.XMLRPC):
|
||||||
d.cancel()
|
d.cancel()
|
||||||
return defer.succeed(None)
|
return defer.succeed(None)
|
||||||
|
|
||||||
def _to_dict(r):
|
|
||||||
t = {}
|
|
||||||
for i in r:
|
|
||||||
t[i[0]] = i[1]
|
|
||||||
return t
|
|
||||||
|
|
||||||
def _add_key_fee(data_cost):
|
def _add_key_fee(data_cost):
|
||||||
d = self.session.wallet.get_stream_info_for_name(name)
|
d = self.session.wallet.get_stream_info_for_name(name)
|
||||||
d.addCallback(lambda info: data_cost + info['key_fee'] if 'key_fee' in info.keys() else data_cost)
|
d.addCallback(lambda info: data_cost + info['key_fee'] if 'key_fee' in info.keys() else data_cost)
|
||||||
|
@ -581,14 +573,16 @@ class LBRYDaemon(xmlrpc.XMLRPC):
|
||||||
self.blob_request_payment_rate_manager))
|
self.blob_request_payment_rate_manager))
|
||||||
d.addCallback(self.sd_identifier.get_metadata_for_sd_blob)
|
d.addCallback(self.sd_identifier.get_metadata_for_sd_blob)
|
||||||
d.addCallback(lambda metadata: metadata.validator.info_to_show())
|
d.addCallback(lambda metadata: metadata.validator.info_to_show())
|
||||||
d.addCallback(_to_dict)
|
d.addCallback(lambda info: int(dict(info)['stream_size']) / 1000000 * self.data_rate)
|
||||||
d.addCallback(lambda info: int(info['stream_size']) / 1000000 * self.data_rate)
|
|
||||||
d.addCallback(_add_key_fee)
|
d.addCallback(_add_key_fee)
|
||||||
d.addErrback(lambda _: _add_key_fee(0.0))
|
d.addErrback(lambda _: _add_key_fee(0.0))
|
||||||
reactor.callLater(self.search_timeout, _check_est, d, name)
|
reactor.callLater(self.search_timeout, _check_est, d, name)
|
||||||
|
|
||||||
return d
|
return d
|
||||||
|
|
||||||
|
def xmlrpc_is_running(self):
|
||||||
|
return True
|
||||||
|
|
||||||
def xmlrpc_get_settings(self):
|
def xmlrpc_get_settings(self):
|
||||||
"""
|
"""
|
||||||
Get LBRY payment settings
|
Get LBRY payment settings
|
||||||
|
@ -855,16 +849,6 @@ class LBRYDaemon(xmlrpc.XMLRPC):
|
||||||
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])
|
||||||
d.addCallback(lambda claims: claims[:self.max_search_results])
|
d.addCallback(lambda claims: claims[:self.max_search_results])
|
||||||
d.addCallback(resolve_claims)
|
d.addCallback(resolve_claims)
|
||||||
|
|
||||||
#filtered_results = [n for n in self.session.wallet.get_nametrie() if n['name'].startswith(search)]
|
|
||||||
#if len(filtered_results) > self.max_search_results:
|
|
||||||
# filtered_results = filtered_results[:self.max_search_results]
|
|
||||||
#filtered_results = [n for n in filtered_results if 'txid' in n.keys()]
|
|
||||||
#resolved_results = [defer.DeferredList([_return_d(n), self._resolve_name_wc(n['name']),
|
|
||||||
# self._get_est_cost(n['name'])], consumeErrors=True)
|
|
||||||
# for n in filtered_results]
|
|
||||||
|
|
||||||
#d = defer.DeferredList(resolved_results)
|
|
||||||
d.addCallback(_clean)
|
d.addCallback(_clean)
|
||||||
d.addCallback(_parse)
|
d.addCallback(_parse)
|
||||||
d.addCallback(_disp)
|
d.addCallback(_disp)
|
||||||
|
@ -1036,8 +1020,8 @@ class LBRYDaemon(xmlrpc.XMLRPC):
|
||||||
|
|
||||||
return message
|
return message
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
# shut down existing instance of lbrynet-daemon if there is one
|
|
||||||
try:
|
try:
|
||||||
d = xmlrpclib.ServerProxy('http://localhost:7080')
|
d = xmlrpclib.ServerProxy('http://localhost:7080')
|
||||||
d.stop()
|
d.stop()
|
||||||
|
@ -1049,6 +1033,6 @@ def main():
|
||||||
reactor.listenTCP(7080, server.Site(daemon))
|
reactor.listenTCP(7080, server.Site(daemon))
|
||||||
reactor.run()
|
reactor.run()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
|
||||||
|
|
15
lbrynet/lbrynet_daemon/LBRYOSXStatusBar.py
Normal file
15
lbrynet/lbrynet_daemon/LBRYOSXStatusBar.py
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
import rumps
|
||||||
|
import xmlrpclib
|
||||||
|
import os
|
||||||
|
|
||||||
|
class DaemonStatusBarApp(rumps.App):
|
||||||
|
def __init__(self):
|
||||||
|
super(DaemonStatusBarApp, self).__init__("LBRYnet", icon=os.path.join(os.path.expanduser("~"), "Downloads/lbryio//web/img/fav/apple-touch-icon.png"), quit_button=None)
|
||||||
|
self.menu = ["Quit"]
|
||||||
|
|
||||||
|
@rumps.clicked('Quit')
|
||||||
|
def clean_quit(self):
|
||||||
|
d = xmlrpclib.ServerProxy('http://localhost:7080')
|
||||||
|
d.stop()
|
||||||
|
rumps.quit_application()
|
||||||
|
|
|
@ -1,5 +1,63 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
|
if ! which brew &>/dev/null; then
|
||||||
|
echo "Installing brew..."
|
||||||
|
sudo -u ${SUDO_USER} ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" < /dev/null &>/dev/null
|
||||||
|
else
|
||||||
|
echo "Updating brew..."
|
||||||
|
sudo -u ${SUDO_USER} brew update &>/dev/null
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! brew list mpfr &>/dev/null; then
|
||||||
|
echo "Installing mpfr..."
|
||||||
|
sudo -u ${SUDO_USER} brew install mpfr &>/dev/null
|
||||||
|
else
|
||||||
|
echo "mpfr already installed..."
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! brew list libmpc &>/dev/null; then
|
||||||
|
echo "Installing libmpc..."
|
||||||
|
sudo -u ${SUDO_USER} brew install libmpc &>/dev/null
|
||||||
|
else
|
||||||
|
echo "libmpc already installed..."
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! brew list openssl &>/dev/null; then
|
||||||
|
echo "Installing openssl..."
|
||||||
|
sudo -u ${SUDO_USER} brew install openssl &>/dev/null
|
||||||
|
sudo -u ${SUDO_USER} brew link --force openssl &>/dev/null
|
||||||
|
else
|
||||||
|
echo "openssl already installed..."
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! which pip &>/dev/null; then
|
||||||
|
echo "Installing pip..."
|
||||||
|
sudo easy_install pip &>/dev/null
|
||||||
|
else
|
||||||
|
echo "pip already installed"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! python -c 'import gmpy' &>/dev/null; then
|
||||||
|
echo "Installing gmpy..."
|
||||||
|
sudo pip install gmpy &>/dev/null
|
||||||
|
else
|
||||||
|
echo "gmpy already installed..."
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! python -c 'import service_identity' &>/dev/null; then
|
||||||
|
echo "Installing service_identity..."
|
||||||
|
sudo pip install service_identity &>/dev/null
|
||||||
|
else
|
||||||
|
echo "gmpy already installed..."
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! python -c 'import rumps' &>/dev/null; then
|
||||||
|
echo "Installing rumps..."
|
||||||
|
sudo pip install rumps &>/dev/null
|
||||||
|
else
|
||||||
|
echo "rumps already installed..."
|
||||||
|
fi
|
||||||
|
|
||||||
lbrycrd_directory="/Users/${SUDO_USER}/Library/Application Support/lbrycrd"
|
lbrycrd_directory="/Users/${SUDO_USER}/Library/Application Support/lbrycrd"
|
||||||
|
|
||||||
current_version=$(git ls-remote https://github.com/jackrobison/lbrynet-app.git | grep HEAD | cut -f 1)
|
current_version=$(git ls-remote https://github.com/jackrobison/lbrynet-app.git | grep HEAD | cut -f 1)
|
||||||
|
|
Loading…
Reference in a new issue