15 logger=borgend.logger.getChild(__name__) |
15 logger=borgend.logger.getChild(__name__) |
16 |
16 |
17 traynames={ |
17 traynames={ |
18 backup.INACTIVE: 'B.', |
18 backup.INACTIVE: 'B.', |
19 backup.SCHEDULED: 'B.', |
19 backup.SCHEDULED: 'B.', |
|
20 backup.QUEUED: 'B:', |
20 backup.ACTIVE: 'B!', |
21 backup.ACTIVE: 'B!', |
21 backup.BUSY: 'B⦙', |
22 backup.BUSY: 'B⦙', |
22 backup.OFFLINE: 'B⦙', |
23 backup.OFFLINE: 'B⦙', |
23 backup.ERRORS: 'B?' |
24 backup.ERRORS: 'B?' |
24 } |
25 } |
25 |
26 |
26 statestring={ |
27 statestring={ |
27 backup.INACTIVE: 'inactive', |
28 backup.INACTIVE: 'inactive', |
28 backup.SCHEDULED: 'scheduled', |
29 backup.SCHEDULED: 'scheduled', |
|
30 backup.QUEUED: 'queued', |
29 backup.ACTIVE: 'active', |
31 backup.ACTIVE: 'active', |
30 backup.BUSY: 'busy', |
32 backup.BUSY: 'busy', |
31 backup.OFFLINE: 'offline', |
33 backup.OFFLINE: 'offline', |
32 backup.ERRORS: 'errors' |
34 backup.ERRORS: 'errors' |
33 } |
35 } |
93 if state>=backup.BUSY and state in statestring: |
95 if state>=backup.BUSY and state in statestring: |
94 detail=statestring[state] + '; ' |
96 detail=statestring[state] + '; ' |
95 if status['detail']!='normal': |
97 if status['detail']!='normal': |
96 detail=detail+status['detail']+' ' |
98 detail=detail+status['detail']+' ' |
97 title="%s (%s%s %s)" % (status['name'], detail, status['operation'], whenstr) |
99 title="%s (%s%s %s)" % (status['name'], detail, status['operation'], whenstr) |
|
100 elif status['type']=='queued': |
|
101 title="%s (queued)" % status['name'] |
98 elif status['type']=='current': |
102 elif status['type']=='current': |
99 # Operation running |
103 # Operation running |
100 progress='' |
104 progress='' |
101 if 'progress_current' in status and 'progress_total' in status: |
105 if 'progress_current' in status and 'progress_total' in status: |
102 progress=' %d%%' % (status['progress_current']/status['progress_total']) |
106 progress=' %d%%' % (status['progress_current']/status['progress_total']) |
128 # rebuilding the entire menu |
132 # rebuilding the entire menu |
129 for index in range(len(backups)): |
133 for index in range(len(backups)): |
130 b=backups[index] |
134 b=backups[index] |
131 # Python closures suck dog's balls; hence the _index=index hack |
135 # Python closures suck dog's balls; hence the _index=index hack |
132 # See also http://math.andrej.com/2009/04/09/pythons-lambda-is-broken/ |
136 # See also http://math.andrej.com/2009/04/09/pythons-lambda-is-broken/ |
133 cb=(lambda obj, status, _index=index, errors=None: |
137 cb=(lambda status, errors=None, _index=index: |
134 self.__status_callback(obj, _index, status, errors)) |
138 self.__status_callback(_index, status, errorlog=errors)) |
135 b.set_status_update_callback(cb) |
139 b.set_status_update_callback(cb) |
136 self.statuses[index]=b.status() |
140 self.statuses[index]=b.status() |
137 |
141 |
138 menu, state=self.__rebuild_menu() |
142 menu, state=self.__rebuild_menu() |
139 |
143 |
175 menu, active=self.__rebuild_menu() |
179 menu, active=self.__rebuild_menu() |
176 self.menu.clear() |
180 self.menu.clear() |
177 self.menu.update(menu) |
181 self.menu.update(menu) |
178 self.title=traynames[active] |
182 self.title=traynames[active] |
179 |
183 |
180 def __status_callback(self, obj, index, status, errorlog): |
184 def __status_callback(self, index, status, errorlog=None): |
181 logger.debug('Status callback: %s' % str(status)) |
185 logger.debug('Status callback: %s' % str(status)) |
182 |
186 |
183 with self.lock: |
187 with self.lock: |
184 self.statuses[index]=status |
188 self.statuses[index]=status |
185 if self.refresh_timer==None: |
189 if self.refresh_timer==None: |