forked from LBRYCommunity/lbry-sdk
update daemon
This commit is contained in:
parent
6633370a34
commit
6f1ee78623
4 changed files with 64 additions and 34 deletions
|
@ -1,3 +1,22 @@
|
|||
import os
|
||||
import sys
|
||||
import json
|
||||
import binascii
|
||||
import webbrowser
|
||||
import xmlrpclib
|
||||
import subprocess
|
||||
import logging
|
||||
import argparse
|
||||
|
||||
from twisted.web import xmlrpc, server
|
||||
from twisted.internet import defer, threads, reactor, error
|
||||
|
||||
from datetime import datetime
|
||||
from decimal import Decimal
|
||||
from StringIO import StringIO
|
||||
from zipfile import ZipFile
|
||||
from urllib import urlopen
|
||||
|
||||
from lbrynet.core.PaymentRateManager import PaymentRateManager
|
||||
from lbrynet.core.server.BlobAvailabilityHandler import BlobAvailabilityHandlerFactory
|
||||
from lbrynet.core.server.BlobRequestHandler import BlobRequestHandlerFactory
|
||||
|
@ -18,15 +37,7 @@ from lbrynet.core.PTCWallet import PTCWallet
|
|||
from lbrynet.core.LBRYcrdWallet import LBRYcrdWallet, LBRYumWallet
|
||||
from lbrynet.lbryfilemanager.LBRYFileManager import LBRYFileManager
|
||||
from lbrynet.lbryfile.LBRYFileMetadataManager import DBLBRYFileMetadataManager, TempLBRYFileMetadataManager
|
||||
from twisted.web import xmlrpc, server
|
||||
from twisted.internet import defer, threads, reactor, error
|
||||
from datetime import datetime
|
||||
from decimal import Decimal
|
||||
from StringIO import StringIO
|
||||
from zipfile import ZipFile
|
||||
from urllib import urlopen
|
||||
|
||||
import os, sys, json, binascii, webbrowser, xmlrpclib, subprocess, logging, argparse
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
# logging.basicConfig(level=logging.DEBUG)
|
||||
|
@ -138,9 +149,8 @@ class LBRYDaemon(xmlrpc.XMLRPC):
|
|||
d.addCallback(lambda _: self._setup_lbry_file_opener())
|
||||
d.addCallback(lambda _: self._setup_query_handlers())
|
||||
d.addCallback(lambda _: self._setup_server())
|
||||
if sys.platform == "darwin":
|
||||
d.addCallback(lambda _: self._update() if self.check_for_updates == "True" else defer.succeed(None))
|
||||
# d.addCallback(lambda _: defer.succeed(self.status_app.run()))
|
||||
d.addCallback(lambda _: self._update() if self.check_for_updates == "True" and sys.platform == "darwin"
|
||||
else defer.succeed(None))
|
||||
d.addCallback(lambda _: self._setup_fetcher())
|
||||
d.addCallback(lambda _: _disp_startup())
|
||||
d.callback(None)
|
||||
|
@ -218,8 +228,7 @@ class LBRYDaemon(xmlrpc.XMLRPC):
|
|||
|
||||
d = _check_for_updater()
|
||||
d.addCallback(lambda _: _update_lbrynet())
|
||||
d.addCallback(lambda _: _update_lbrycrdd())
|
||||
d.addCallback(lambda _: _update_lbryum())
|
||||
d.addCallback(lambda _: _update_lbrycrdd() if self.wallet_type == 'lbrycrd' else _update_lbryum())
|
||||
d.addCallback(lambda _: os.system("open /Applications/LBRY\ Updater.app &>/dev/null") if self.restart_message
|
||||
else defer.succeed(None))
|
||||
d.addCallbacks(lambda _: self._restart() if self.restart_message else defer.succeed(None))
|
||||
|
@ -1071,6 +1080,27 @@ class LBRYDaemon(xmlrpc.XMLRPC):
|
|||
|
||||
return message
|
||||
|
||||
def xmlrpc_start_status_bar_app(self):
|
||||
if sys.platform == 'darwin':
|
||||
subprocess.Popen("screen -dmS lbry-status bash -c 'lbrynet-daemon-status --startdaemon=False'", shell=True)
|
||||
return "Started"
|
||||
else:
|
||||
return "Status bar not implemented on non OS X"
|
||||
|
||||
|
||||
def stop():
|
||||
daemon = xmlrpclib.ServerProxy("http://localhost:7080/")
|
||||
try:
|
||||
status = daemon.is_running()
|
||||
except:
|
||||
status = False
|
||||
|
||||
if status:
|
||||
daemon.stop()
|
||||
print "LBRYnet daemon stopped"
|
||||
else:
|
||||
print "LBRYnet daemon wasn't running"
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description="Launch lbrynet-daemon")
|
||||
|
@ -1096,5 +1126,6 @@ def main():
|
|||
reactor.listenTCP(7080, server.Site(daemon), interface='localhost')
|
||||
reactor.run()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
|
@ -1,18 +0,0 @@
|
|||
import xmlrpclib
|
||||
|
||||
|
||||
def main():
|
||||
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"
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
|
@ -3,11 +3,19 @@ import xmlrpclib
|
|||
import os
|
||||
import webbrowser
|
||||
import subprocess
|
||||
import argparse
|
||||
|
||||
|
||||
class DaemonStatusBarApp(rumps.App):
|
||||
def __init__(self):
|
||||
icon_path = os.path.join(os.path.expanduser("~"), "Downloads/lbryio/web/img/fav/apple-touch-icon.png")
|
||||
#detect if being run as root, if so find the correct icon path
|
||||
if os.path.expanduser("~") != '/var/root':
|
||||
icon_path = os.path.join(os.path.expanduser("~"), "Downloads/lbryio/web/img/fav/apple-touch-icon.png")
|
||||
else:
|
||||
icon_path = os.path.join("/Users",
|
||||
subprocess.check_output('echo $SUDO_USER', shell=True)[:-1],
|
||||
"Downloads/lbryio/web/img/fav/apple-touch-icon.png")
|
||||
|
||||
if os.path.isfile(icon_path):
|
||||
rumps.App.__init__(self, name="LBRY", icon=icon_path, quit_button=None,
|
||||
menu=["Open", "Preferences", "View balance", "Quit"])
|
||||
|
@ -64,7 +72,16 @@ class DaemonStatusBarApp(rumps.App):
|
|||
|
||||
|
||||
def main():
|
||||
subprocess.Popen("screen -dmS lbry bash -c 'lbrynet-daemon --update=False'", shell=True)
|
||||
parser = argparse.ArgumentParser(description="Launch lbrynet status bar application")
|
||||
parser.add_argument("--startdaemon",
|
||||
help="true or false, default true",
|
||||
type=str,
|
||||
default="true")
|
||||
args = parser.parse_args()
|
||||
|
||||
if args.startdaemon.lower() == "true":
|
||||
subprocess.Popen("screen -dmS lbrynet bash -c 'lbrynet-daemon'", shell=True)
|
||||
|
||||
status_app = DaemonStatusBarApp()
|
||||
status_app.run()
|
||||
|
||||
|
|
2
setup.py
2
setup.py
|
@ -16,7 +16,7 @@ console_scripts = ['lbrynet-console = lbrynet.lbrynet_console.LBRYConsole:launch
|
|||
'lbrynet-lookup-hosts-for-hash = lbrynet.dht_scripts:get_hosts_for_hash_in_dht',
|
||||
'lbrynet-announce_hash_to_dht = lbrynet.dht_scripts:announce_hash_to_dht',
|
||||
'lbrynet-daemon = lbrynet.lbrynet_daemon.LBRYDaemon:main',
|
||||
'stop-lbrynet-daemon = lbrynet.lbrynet_daemon.LBRYDaemonStopper:main']
|
||||
'stop-lbrynet-daemon = lbrynet.lbrynet_daemon.LBRYDaemon:stop']
|
||||
|
||||
if sys.platform == 'darwin':
|
||||
console_scripts.append('lbrynet-daemon-status = lbrynet.lbrynet_daemon.LBRYOSXStatusBar:main')
|
||||
|
|
Loading…
Reference in a new issue