Rumps/Mac UI stuff is fucked and disables ^C etc.; threading doesn't help

Sat, 20 Jan 2018 15:55:09 +0000

author
Tuomo Valkonen <tuomov@iki.fi>
date
Sat, 20 Jan 2018 15:55:09 +0000
changeset 9
aa121291eb0e
parent 8
7b2d2eac6a48
child 10
76dbfb06eba0

Rumps/Mac UI stuff is fucked and disables ^C etc.; threading doesn't help

borgend.py file | annotate | diff | comparison | revisions
ui.py file | annotate | diff | comparison | revisions
--- a/borgend.py	Sat Jan 20 15:08:16 2018 +0000
+++ b/borgend.py	Sat Jan 20 15:55:09 2018 +0000
@@ -1,6 +1,7 @@
 #!/usr/local/bin/python3
 
 import logging
+from threading import Thread
 
 logging.basicConfig(#filename='example.log',
                     format='%(levelname)s:%(message)s',
@@ -10,7 +11,7 @@
 from config import settings
 from queue import Queue
 from ui import BorgendTray
-
+import signal, os
 
 backupconfigs=settings['backups']
 backups=[None]*len(backupconfigs);
@@ -27,5 +28,22 @@
 
 if __name__ == "__main__":
     #print(settings)
-    BorgendTray("Borgend").run()
-    pass
+    tray=BorgendTray("Borgend", backups);
+    tray.run()
+
+    #
+    # This shit is fucked, disables ^C etc., and threading doesn't seem to help
+    #
+
+    # ui_thread=Thread(target=tray.run)
+    # ui_thread.daemon=True
+    # ui_thread.start()
+
+    # def quit_signal_handler(signum, frame):
+    #     print('Signal handler called with signal %s' % str(signum))
+    #     ui_thread.terminate()
+    #     os.exit()
+
+    # signal.signal(signal.SIGTERM, quit_signal_handler)
+    # signal.signal(signal.SIGINT, quit_signal_handler)
+
--- a/ui.py	Sat Jan 20 15:08:16 2018 +0000
+++ b/ui.py	Sat Jan 20 15:55:09 2018 +0000
@@ -5,6 +5,14 @@
 import rumps
 
 class BorgendTray(rumps.App):
-    @rumps.clicked("Status...")
-    def prefs(self, _):
-        rumps.alert("None")
+    def __init__(self, name, backups):
+        menu=[rumps.MenuItem(b.name, callback=self.silly) for b in backups]
+        menu = menu + [rumps.MenuItem("Quit...", callback=self.my_quit_button)]
+        super().__init__(name, menu=menu, quit_button=None)
+
+    def my_quit_button(self, _):
+        rumps.quit_application()
+
+    def silly(self, sender):
+        sender.state=not sender.state
+

mercurial