64
65
"ApprovalDelay": "Approval Delay",
65
66
"ApprovalDuration": "Approval Duration",
66
67
"Checker": "Checker",
67
"ExtendedTimeout": "Extended Timeout"
68
"ExtendedTimeout": "Extended Timeout",
70
"LastCheckerStatus": "Last Checker Status",
69
72
defaultkeywords = ("Name", "Enabled", "Timeout", "LastCheckedOK")
70
73
domain = "se.recompile"
280
283
help="Select all clients")
281
284
parser.add_argument("-v", "--verbose", action="store_true",
282
285
help="Print all fields")
286
parser.add_argument("-j", "--dump-json", action="store_true",
287
help="Dump client data in JSON format")
283
288
parser.add_argument("-e", "--enable", action="store_true",
284
289
help="Enable client")
285
290
parser.add_argument("-d", "--disable", action="store_true",
328
333
if has_actions(options) and not (options.client or options.all):
329
334
parser.error("Options require clients names or --all.")
330
335
if options.verbose and has_actions(options):
331
parser.error("--verbose can only be used alone or with"
336
parser.error("--verbose can only be used alone.")
337
if options.dump_json and (options.verbose or has_actions(options)):
338
parser.error("--dump-json can only be used alone.")
333
339
if options.all and not has_actions(options):
334
340
parser.error("--all requires an action.")
336
342
if options.check:
337
343
fail_count, test_count = doctest.testmod()
338
344
sys.exit(os.EX_OK if fail_count == 0 else 1)
391
397
if not has_actions(options) and clients:
398
if options.verbose or options.dump_json:
393
399
keywords = ("Name", "Enabled", "Timeout", "LastCheckedOK",
394
400
"Created", "Interval", "Host", "Fingerprint",
395
401
"CheckerRunning", "LastEnabled",
396
402
"ApprovalPending", "ApprovedByDefault",
397
403
"LastApprovalRequest", "ApprovalDelay",
398
404
"ApprovalDuration", "Checker",
405
"ExtendedTimeout", "Expires",
401
408
keywords = defaultkeywords
403
print_clients(clients.values(), keywords)
410
if options.dump_json:
411
json.dump({client["Name"]: {key:
413
if isinstance(client[key],
416
for key in keywords }
417
for client in clients.values() },
418
fp = sys.stdout, indent = 4,
419
separators = (',', ': '))
422
print_clients(clients.values(), keywords)
405
424
# Process each client in the list by all selected options
406
425
for client in clients: