update status bar app

This commit is contained in:
Jack 2016-02-27 17:49:49 -05:00
parent 33c1a002da
commit 59d08a92d0
2 changed files with 71 additions and 23 deletions

View file

@ -3,23 +3,69 @@ import xmlrpclib
import os import os
import webbrowser 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 = ["Open UI", "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 UI') @rumps.clicked('Open')
def get_ui(self): def get_ui(self):
try:
daemon = xmlrpclib.ServerProxy('http://localhost:7080')
daemon.is_running()
webbrowser.open("lbry://lbry") 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):
daemon = xmlrpclib.ServerProxy('http://localhost:7080') daemon = xmlrpclib.ServerProxy('http://localhost:7080')
try:
daemon.stop() daemon.stop()
except:
pass
rumps.quit_application() rumps.quit_application()
def main(): def main():
DaemonStatusBarApp().run() status_app = DaemonStatusBarApp()
status_app.run()
if __name__ == '__main__': if __name__ == '__main__':
main() main()

View file

@ -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',
[ [