ui.py

changeset 40
cfbeeec8cb82
parent 38
085a635f23f5
child 42
00accd11978b
equal deleted inserted replaced
39:56af43e9c949 40:cfbeeec8cb82
1 # 1 #
2 # MacOS UI 2 # Borgend MacOS UI
3 # 3 #
4 4
5 import rumps 5 import rumps
6 import time 6 import time
7 import datetime 7 import datetime
8 import logging 8 import logging
9 import borgend 9 import borgend
10 import utils
10 from threading import Lock, Timer 11 from threading import Lock, Timer
11 from config import settings 12 from config import settings
12 import objc 13 import objc
13 14
14 logger=borgend.logger.getChild(__name__) 15 logger=borgend.logger.getChild(__name__)
40 NSDictionary = objc.lookUpClass("NSDictionary") 41 NSDictionary = objc.lookUpClass("NSDictionary")
41 d=NSDictionary() 42 d=NSDictionary()
42 43
43 rumps.notification(title, subtitle, message, data=d) 44 rumps.notification(title, subtitle, message, data=d)
44 except Exception as err: 45 except Exception as err:
45 logger.debug('Unable to display notificaton:%s:%s',err.__class__.__name__, str(err)) 46 utils.log_exception(logger, err,
47 detail='Unable to display notification')
46 48
47 # Based on code snatched from 49 # Based on code snatched from
48 # https://stackoverflow.com/questions/12523586/python-format-size-application-converting-b-to-kb-mb-gb-tb/37423778 50 # https://stackoverflow.com/questions/12523586/python-format-size-application-converting-b-to-kb-mb-gb-tb/37423778
49 def humanbytes(B): 51 def humanbytes(B):
50 'Return the given bytes as a human friendly KB, MB, GB, or TB string' 52 'Return the given bytes as a human friendly KB, MB, GB, or TB string'
209 #sender.state=not sender.state 211 #sender.state=not sender.state
210 logger.debug("Manually backup '%s'", b.name) 212 logger.debug("Manually backup '%s'", b.name)
211 try: 213 try:
212 b.create(None) 214 b.create(None)
213 except Exception as err: 215 except Exception as err:
214 logger.debug("Opening notification for exception %s '%s'", 216 utils.log_exception(logger, err)
215 err.__class__.__name__, str(err))
216 notification_workaround(borgend.appname_stylised, 217 notification_workaround(borgend.appname_stylised,
217 err.__class__.__name__, str(err)) 218 err.__class__.__name__, str(err))
218 219
219 @rumps.notifications 220 @rumps.notifications
220 def notification_center(data): 221 def notification_center(data):
231 dimensions=(640,320)) 232 dimensions=(640,320))
232 self.logwindow.run() 233 self.logwindow.run()
233 # Does not return until closed 234 # Does not return until closed
234 self.logwindow=None 235 self.logwindow=None
235 except Exception as err: 236 except Exception as err:
236 logger.critical('%s:%s', err.__class__.__name__, str(err)) 237 utils.log_exception(logger, err)
237 238

mercurial