157
156
self._update_timer_callback_tag = None
158
157
self.logger(u'Checker for client %s (command "%s")'
159
158
u' was successful'
160
% (self.properties[u"Name"], command))
159
% (self.properties[u"name"], command))
169
168
if os.WIFEXITED(condition):
170
169
self.logger(u'Checker for client %s (command "%s")'
171
170
u' failed with exit code %s'
172
% (self.properties[u"Name"], command,
171
% (self.properties[u"name"], command,
173
172
os.WEXITSTATUS(condition)))
174
173
elif os.WIFSIGNALED(condition):
175
174
self.logger(u'Checker for client %s (command "%s")'
176
175
u' was killed by signal %s'
177
% (self.properties[u"Name"], command,
176
% (self.properties[u"name"], command,
178
177
os.WTERMSIG(condition)))
179
178
elif os.WCOREDUMP(condition):
180
179
self.logger(u'Checker for client %s (command "%s")'
182
% (self.properties[u"Name"], command))
181
% (self.properties[u"name"], command))
184
self.logger(u'Checker for client %s completed'
183
self.logger(u'Checker for client %s completed mysteriously')
188
186
def checker_started(self, command):
189
187
#self.logger(u'Client %s started checker "%s"'
190
# % (self.properties[u"Name"], unicode(command)))
188
# % (self.properties[u"name"], unicode(command)))
193
191
def got_secret(self):
194
self.last_checker_failed = False
195
192
self.logger(u'Client %s received its secret'
196
% self.properties[u"Name"])
193
% self.properties[u"name"])
198
195
def need_approval(self, timeout, default):
202
199
message = u'Client %s will get its secret in %s seconds'
203
200
self.logger(message
204
% (self.properties[u"Name"], timeout/1000))
201
% (self.properties[u"name"], timeout/1000))
206
203
def rejected(self, reason):
207
204
self.logger(u'Client %s was rejected; reason: %s'
208
% (self.properties[u"Name"], reason))
205
% (self.properties[u"name"], reason))
210
207
def selectable(self):
211
208
"""Make this a "selectable" widget.
239
236
# Base part of a client. Name!
240
237
base = (u'%(name)s: '
241
% {u"name": self.properties[u"Name"]})
242
if not self.properties[u"Enabled"]:
238
% {u"name": self.properties[u"name"]})
239
if not self.properties[u"enabled"]:
243
240
message = u"DISABLED"
244
elif self.properties[u"ApprovalPending"]:
245
if self.properties[u"ApprovedByDefault"]:
246
message = u"Connection established to client. (d)eny?"
248
message = u"Seeks approval to send secret. (a)pprove?"
249
241
elif self.last_checker_failed:
250
242
timeout = datetime.timedelta(milliseconds
243
= self.properties[u"timeout"])
253
244
last_ok = isoformat_to_datetime(
254
max((self.properties[u"LastCheckedOK"]
255
or self.properties[u"Created"]),
256
self.properties[u"LastEnabled"]))
245
max((self.properties["last_checked_ok"]
246
or self.properties["created"]),
247
self.properties[u"last_enabled"]))
257
248
timer = timeout - (datetime.datetime.utcnow() - last_ok)
258
message = (u'A checker has failed! Time until client'
249
message = (u'A checker has failed! Time until client gets diabled: %s'
260
250
% unicode(timer).rsplit(".", 1)[0])
251
elif self.properties[u"approved_pending"]:
252
if self.properties[u"approved_by_default"]:
253
message = u"Connection established to client. (d)eny?"
255
message = u"Seeks approval to send secret. (a)pprove?"
262
257
message = u"enabled"
263
258
self._text = "%s%s" % (base, message)
350
345
use them as an excuse to shift focus away from this widget.
352
347
def keypress(self, (maxcol, maxrow), key):
353
ret = super(ConstrainedListBox, self).keypress((maxcol,
348
ret = super(ConstrainedListBox, self).keypress((maxcol, maxrow), key)
355
349
if ret in (u"up", u"down"):
474
468
Call this when the widget layout needs to change"""
476
470
#self.uilist.append(urwid.ListBox(self.clients))
477
self.uilist.append(urwid.Frame(ConstrainedListBox(self.
471
self.uilist.append(urwid.Frame(ConstrainedListBox(self.clients),
479
472
#header=urwid.Divider(),
482
urwid.Divider(div_char=
474
footer=urwid.Divider(div_char=self.divider)))
484
475
if self.log_visible:
485
476
self.uilist.append(self.logbox)
550
541
path = client.proxy.object_path
551
542
self.clients_dict[path] = client
552
self.clients.sort(None, lambda c: c.properties[u"Name"])
543
self.clients.sort(None, lambda c: c.properties[u"name"])
555
546
def remove_client(self, client, path=None):