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