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