2016-02-19 06:07:19 +01:00
|
|
|
import rumps
|
|
|
|
import xmlrpclib
|
|
|
|
import os
|
2016-02-25 23:17:07 +01:00
|
|
|
import webbrowser
|
2016-02-29 05:49:37 +01:00
|
|
|
import subprocess
|
2016-02-19 06:07:19 +01:00
|
|
|
|
2016-02-27 23:49:49 +01:00
|
|
|
|
2016-02-19 06:07:19 +01:00
|
|
|
class DaemonStatusBarApp(rumps.App):
|
|
|
|
def __init__(self):
|
2016-02-27 23:49:49 +01:00
|
|
|
icon_path = os.path.join(os.path.expanduser("~"), "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"])
|
|
|
|
else:
|
|
|
|
rumps.App.__init__(self, name="LBRY", title="LBRY", quit_button=None,
|
|
|
|
menu=["Open", "Preferences", "View balance", "Quit"])
|
2016-02-25 23:17:07 +01:00
|
|
|
|
2016-02-27 23:49:49 +01:00
|
|
|
@rumps.clicked('Open')
|
2016-02-25 23:17:07 +01:00
|
|
|
def get_ui(self):
|
2016-02-27 23:49:49 +01:00
|
|
|
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")
|
2016-02-19 06:07:19 +01:00
|
|
|
|
|
|
|
@rumps.clicked('Quit')
|
|
|
|
def clean_quit(self):
|
2016-02-25 23:17:07 +01:00
|
|
|
daemon = xmlrpclib.ServerProxy('http://localhost:7080')
|
2016-02-27 23:49:49 +01:00
|
|
|
try:
|
|
|
|
daemon.stop()
|
|
|
|
except:
|
|
|
|
pass
|
|
|
|
|
2016-02-19 06:07:19 +01:00
|
|
|
rumps.quit_application()
|
|
|
|
|
2016-02-27 23:49:49 +01:00
|
|
|
|
2016-02-25 23:17:07 +01:00
|
|
|
def main():
|
2016-02-29 05:49:37 +01:00
|
|
|
subprocess.Popen("screen -dmS lbry bash -c 'lbrynet-daemon --update=False'", shell=True)
|
2016-02-27 23:49:49 +01:00
|
|
|
status_app = DaemonStatusBarApp()
|
|
|
|
status_app.run()
|
|
|
|
|
2016-02-25 23:17:07 +01:00
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
main()
|