ui.py

changeset 38
085a635f23f5
parent 34
9fce700d42de
child 40
cfbeeec8cb82
equal deleted inserted replaced
37:9fab8200f7eb 38:085a635f23f5
12 import objc 12 import objc
13 13
14 logger=borgend.logger.getChild(__name__) 14 logger=borgend.logger.getChild(__name__)
15 15
16 INACTIVE=0 16 INACTIVE=0
17 ACTIVE=1 17 SCHEDULED_OK=1
18 OFFLINE=2 18 ACTIVE=2
19 ERRORS=3 19 OFFLINE=3
20 ERRORS=4
20 21
21 traynames={ 22 traynames={
22 INACTIVE: 'B.', 23 INACTIVE: 'B.',
24 SCHEDULED_OK: 'B.',
23 ACTIVE: 'B!', 25 ACTIVE: 'B!',
24 OFFLINE: 'B⦙', 26 OFFLINE: 'B⦙',
25 ERRORS: 'B?' 27 ERRORS: 'B?'
26 } 28 }
27 29
81 twhen=time.localtime(when) 83 twhen=time.localtime(when)
82 if twhen.tm_sec>30: 84 if twhen.tm_sec>30:
83 # Round up minute display to avoid user confusion 85 # Round up minute display to avoid user confusion
84 twhen=time.localtime(when+30) 86 twhen=time.localtime(when+30)
85 whenstr='at %02d:%02d' % (twhen.tm_hour, twhen.tm_min) 87 whenstr='at %02d:%02d' % (twhen.tm_hour, twhen.tm_min)
86 detail='' 88
87 if 'detail' in status and status['detail']: 89 if status['detail']=='normal':
88 if status['detail']=='retry': 90 state=SCHEDULED_OK
89 state=ERRORS 91 detail=''
90 detail=status['detail']+' ' 92 else:
93 if status['detail']=='retry':
94 state=ERRORS
95 detail=status['detail']+' '
91 title="%s (%s%s %s)" % (status['name'], detail, status['operation'], whenstr) 96 title="%s (%s%s %s)" % (status['name'], detail, status['operation'], whenstr)
92 elif status['type']=='current': 97 elif status['type']=='current':
93 # Operation running 98 # Operation running
94 progress='' 99 progress=''
95 if 'progress_current' in status and 'progress_total' in status: 100 if 'progress_current' in status and 'progress_total' in status:
100 title="%s (running: %s%s)" % (status['name'], status['operation'], progress) 105 title="%s (running: %s%s)" % (status['name'], status['operation'], progress)
101 state=ACTIVE 106 state=ACTIVE
102 else: # status['type']=='nothing': 107 else: # status['type']=='nothing':
103 # Should be unscheduled, nothing running 108 # Should be unscheduled, nothing running
104 title=status['name'] 109 title=status['name']
110 if status['errors']:
111 title=title + " (errors)"
105 112
106 if status['errors']: 113 if status['errors']:
107 state=ERRORS 114 state=ERRORS
108 115
109 return title, state 116 return title, state
146 # Python closures suck dog's balls... 153 # Python closures suck dog's balls...
147 # first and the last program I write in Python until somebody 154 # first and the last program I write in Python until somebody
148 # fixes this brain damage 155 # fixes this brain damage
149 cbm=lambda sender, _b=b: self.__menu_select_backup(sender, _b) 156 cbm=lambda sender, _b=b: self.__menu_select_backup(sender, _b)
150 item=rumps.MenuItem(title, callback=cbm) 157 item=rumps.MenuItem(title, callback=cbm)
158 if this_state==SCHEDULED_OK:
159 item.state=1
160 elif this_state>=OFFLINE:
161 item.state=-1
151 menu.append(item) 162 menu.append(item)
152 state=combine_state(state, this_state) 163 state=combine_state(state, this_state)
153 164
154 menu_log=rumps.MenuItem("Show log", callback=self.showlog) 165 menu_log=rumps.MenuItem("Show log", callback=self.showlog)
155 menu.append(menu_log) 166 menu.append(menu_log)

mercurial