81 elif TB <= B: |
82 elif TB <= B: |
82 return '{0:.2f}TB'.format(B/TB) |
83 return '{0:.2f}TB'.format(B/TB) |
83 |
84 |
84 |
85 |
85 def progress_percentage(done, total, d): |
86 def progress_percentage(done, total, d): |
86 progress='' |
87 percentage = 100*float(done)/float(total) |
87 try: |
88 progress=': %d%%' % int(round(percentage)) |
88 percentage = 100*float(done)/float(total) |
89 if 'operation_no' in d: |
89 progress=': %d%%' % int(round(percentage)) |
90 progress=':#%d%s' % (d['operation_no'], progress) |
90 if 'operation_no' in d: |
|
91 progress=':#%d%s' % (d['operation_no'], progress) |
|
92 except: |
|
93 pass |
|
94 return progress |
91 return progress |
95 |
92 |
96 def progress_parts(done, total, d): |
93 def progress_parts(done, total, d): |
97 progress='' |
94 progress=': %d/%d' % (int(done), int(total)) |
98 try: |
95 if 'operation_no' in d: |
99 progress=': %d/%d' % (int(done), int(total)) |
96 progress=':#%d%s' % (d['operation_no'], progress) |
100 if 'operation_no' in d: |
|
101 progress=':#%d%s' % (d['operation_no'], progress) |
|
102 except: |
|
103 pass |
|
104 return progress |
97 return progress |
105 |
98 |
|
99 _error_state=(backup.State.INACTIVE, backup.Errors.ERRORS) |
106 |
100 |
107 def make_title(status): |
101 def make_title(status): |
108 def add_info(info, new): |
102 def add_info(info, new): |
109 if info: |
103 if info: |
110 return "%s; %s" % (info, new) |
104 return "%s; %s" % (info, new) |
280 self.refresh_timer_time=refresh_time |
274 self.refresh_timer_time=refresh_time |
281 self.refresh_timer.start() |
275 self.refresh_timer.start() |
282 |
276 |
283 return menu, title |
277 return menu, title |
284 |
278 |
|
279 # Callbacks -- exception-protected to get any indications of errors |
|
280 |
|
281 @protect_noreturn |
285 def refresh_ui(self): |
282 def refresh_ui(self): |
286 with self.lock: |
283 with self.lock: |
287 menu, title=self.build_menu_and_timer() |
284 menu, title=self.build_menu_and_timer() |
288 self.menu.clear() |
285 self.menu.clear() |
289 self.menu.update(menu) |
286 self.menu.update(menu) |
290 self.title=title |
287 self.title=title |
291 |
288 |
|
289 @protect_noreturn |
292 def __status_callback(self, index, status, errorlog=None): |
290 def __status_callback(self, index, status, errorlog=None): |
293 logger.debug("Tray status callback") |
291 logger.debug("Tray status callback") |
294 with self.lock: |
292 with self.lock: |
295 self.statuses[index]=status |
293 self.statuses[index]=status |
296 # Time the refresh if it has not been timed, or if the timer |
294 # Time the refresh if it has not been timed, or if the timer |
312 msgid, errorlog['message']) |
310 msgid, errorlog['message']) |
313 |
311 |
314 notification_workaround(branding.appname_stylised, |
312 notification_workaround(branding.appname_stylised, |
315 msgid, errorlog['message']) |
313 msgid, errorlog['message']) |
316 |
314 |
317 def __sleepwake_callback(self, woke): |
315 @protect_noreturn |
318 if woke: |
|
319 self.refresh_ui() |
|
320 |
|
321 def pause_resume_all(self): |
316 def pause_resume_all(self): |
322 with self.lock: |
317 with self.lock: |
323 try: |
318 try: |
324 all_paused=True |
319 all_paused=True |
325 for b in self.backups: |
320 for b in self.backups: |
333 for b in self.backups: |
328 for b in self.backups: |
334 b.pause() |
329 b.pause() |
335 except: |
330 except: |
336 logger.exception("Pause/resume error") |
331 logger.exception("Pause/resume error") |
337 |
332 |
|
333 @protect_noreturn |
|
334 def __sleepwake_callback(self, woke): |
|
335 if woke: |
|
336 self.refresh_ui() |
|
337 |
|
338 @protect_noreturn |
338 def quit(self): |
339 def quit(self): |
339 rumps.quit_application() |
340 rumps.quit_application() |
340 |
341 |
|
342 @protect_noreturn |
341 def __menu_select_backup(self, sender, b): |
343 def __menu_select_backup(self, sender, b): |
342 #sender.state=not sender.state |
344 #sender.state=not sender.state |
343 logger.debug("Manually backup '%s'", b.name) |
345 logger.debug("Manually backup '%s'", b.name) |
344 try: |
346 try: |
345 b.create() |
347 b.create() |