--- a/ui.py Wed Jan 24 20:18:45 2018 +0000 +++ b/ui.py Wed Jan 24 22:04:16 2018 +0000 @@ -76,25 +76,24 @@ return '{0:.2f}TB'.format(B/TB) def make_title(status): - def add_detail(detail, new): - if detail: - return "%s; %s" % (detail, new) + def add_info(info, new): + if info: + return "%s; %s" % (info, new) else: return new - errors=status['errors'] - detail=None + info=None - if not errors.ok(): - detail=add_detail(detail, str(errors)) + if not status.errors.ok(): + info=add_info(info, str(status.errors)) - if status['state']==backup.State.SCHEDULED: + if status.state==backup.State.SCHEDULED: # Operation scheduled - when=status['when'] + when=status.when() now=time.time() if when<now: whenstr='overdue' - detail='' + info='' else: diff=datetime.timedelta(seconds=when-now) if diff.days>0: @@ -107,37 +106,38 @@ twhen=time.localtime(when+30) whenstr='at %02d:%02d' % (twhen.tm_hour, twhen.tm_min) - this_detail='' - if status['detail']!='normal': - this_detail=status['detail'] + ' ' + this_info='' + if 'reason' in status.detail: + this_info=status.detail['reason'] + ' ' - when_how_sched= "%s%s %s" % (this_detail, status['operation'], whenstr) + when_how_sched= "%s%s %s" % (this_info, status.operation, whenstr) - detail=add_detail(detail, when_how_sched) + info=add_info(info, when_how_sched) - elif status['state']==backup.State.QUEUED: - detail=add_detail(detail, "queued") - elif status['state']==backup.State.ACTIVE: + elif status.state==backup.State.QUEUED: + info=add_info(info, "queued") + elif status.state==backup.State.ACTIVE: # Operation running progress='' - if 'progress_current' in status and 'progress_total' in status: - progress=' %d%%' % (status['progress_current']/status['progress_total']) - elif 'original_size' in status and 'deduplicated_size' in status: - progress=' %s→%s' % (humanbytes(status['original_size']), - humanbytes(status['deduplicated_size'])) + d=status.detail + if 'progress_current' in d and 'progress_total' in d: + progress=' %d%%' % (d['progress_current']/d['progress_total']) + elif 'original_size' in d and 'deduplicated_size' in d: + progress=' %s→%s' % (humanbytes(d['original_size']), + humanbytes(d['deduplicated_size'])) - howrunning = "running %s%s" % (status['operation'], progress) + howrunning = "running %s%s" % (status.operation, progress) - detail=add_detail(detail, howrunning) + info=add_info(info, howrunning) else: pass - if detail: - title=status['name'] + ' (' + detail + ')' + if info: + title=status.name + ' (' + info + ')' else: - title=status['name'] + title=status.name - return title, (status['state'], status['errors']) + return title, (status.state, status.errors) class BorgendTray(rumps.App): def __init__(self, backups):