183
181
using_timer(bool(value))
184
182
if property == "LastCheckerStatus":
185
183
using_timer(value != 0)
186
#self.logger('Checker for client {0} (command "{1}") was '
187
# ' successful'.format(self.properties["Name"],
184
#self.logger('Checker for client %s (command "%s")'
186
# % (self.properties["Name"], command))
190
188
def using_timer(self, flag):
191
189
"""Call this method with True or False when timer should be
213
211
if os.WIFEXITED(condition):
214
self.logger('Checker for client {0} (command "{1}")'
215
' failed with exit code {2}'
216
.format(self.properties["Name"], command,
217
os.WEXITSTATUS(condition)))
212
self.logger('Checker for client %s (command "%s")'
213
' failed with exit code %s'
214
% (self.properties["Name"], command,
215
os.WEXITSTATUS(condition)))
218
216
elif os.WIFSIGNALED(condition):
219
self.logger('Checker for client {0} (command "{1}") was'
220
' killed by signal {2}'
221
.format(self.properties["Name"], command,
222
os.WTERMSIG(condition)))
217
self.logger('Checker for client %s (command "%s")'
218
' was killed by signal %s'
219
% (self.properties["Name"], command,
220
os.WTERMSIG(condition)))
223
221
elif os.WCOREDUMP(condition):
224
self.logger('Checker for client {0} (command "{1}")'
222
self.logger('Checker for client %s (command "%s")'
226
.format(self.properties["Name"], command))
224
% (self.properties["Name"], command))
228
self.logger('Checker for client {0} completed'
230
.format(self.properties["Name"]))
226
self.logger('Checker for client %s completed'
233
230
def checker_started(self, command):
234
231
"""Server signals that a checker started. This could be useful
235
232
to log in the future. """
236
#self.logger('Client {0} started checker "{1}"'
237
# .format(self.properties["Name"],
233
#self.logger('Client %s started checker "%s"'
234
# % (self.properties["Name"], unicode(command)))
241
237
def got_secret(self):
242
self.logger('Client {0} received its secret'
243
.format(self.properties["Name"]))
238
self.logger('Client %s received its secret'
239
% self.properties["Name"])
245
241
def need_approval(self, timeout, default):
247
message = 'Client {0} needs approval within {1} seconds'
243
message = 'Client %s needs approval within %s seconds'
249
message = 'Client {0} will get its secret in {1} seconds'
250
self.logger(message.format(self.properties["Name"],
245
message = 'Client %s will get its secret in %s seconds'
247
% (self.properties["Name"], timeout/1000))
252
248
self.using_timer(True)
254
250
def rejected(self, reason):
255
self.logger('Client {0} was rejected; reason: {1}'
256
.format(self.properties["Name"], reason))
251
self.logger('Client %s was rejected; reason: %s'
252
% (self.properties["Name"], reason))
258
254
def selectable(self):
259
255
"""Make this a "selectable" widget.
301
298
timer = datetime.timedelta()
302
299
if self.properties["ApprovedByDefault"]:
303
message = "Approval in {0}. (d)eny?"
300
message = "Approval in %s. (d)eny?"
305
message = "Denial in {0}. (a)pprove?"
306
message = message.format(unicode(timer).rsplit(".", 1)[0])
302
message = "Denial in %s. (a)pprove?"
303
message = message % unicode(timer).rsplit(".", 1)[0]
307
304
elif self.properties["LastCheckerStatus"] != 0:
308
# When checker has failed, show timer until client expires
305
# When checker has failed, print a timer until client expires
309
306
expires = self.properties["Expires"]
310
307
if expires == "":
311
308
timer = datetime.timedelta(0)
313
expires = (datetime.datetime.strptime
314
(expires, '%Y-%m-%dT%H:%M:%S.%f'))
310
expires = datetime.datetime.strptime(expires,
311
'%Y-%m-%dT%H:%M:%S.%f')
315
312
timer = expires - datetime.datetime.utcnow()
316
313
message = ('A checker has failed! Time until client'
317
' gets disabled: {0}'
318
.format(unicode(timer).rsplit(".", 1)[0]))
315
% unicode(timer).rsplit(".", 1)[0])
320
317
message = "enabled"
321
self._text = "{0}{1}".format(base, message)
318
self._text = "%s%s" % (base, message)
323
320
if not urwid.supports_unicode():
324
321
self._text = self._text.encode("ascii", "replace")
489
486
self.main_loop = gobject.MainLoop()
491
488
def client_not_found(self, fingerprint, address):
492
self.log_message("Client with address {0} and fingerprint"
493
" {1} could not be found"
494
.format(address, fingerprint))
489
self.log_message(("Client with address %s and fingerprint %s"
490
" could not be found" % (address,
496
493
def rebuild(self):
497
494
"""This rebuilds the User Interface.