MCPcopy Create free account
hub / github.com/Keeper-Security/Commander / runcommands

Function runcommands

keepercommander/cli.py:479–516  ·  view source on GitHub ↗
(params, commands=None, command_delay=0, quiet=False)

Source from the content-addressed store, hash-verified

477
478
479def runcommands(params, commands=None, command_delay=0, quiet=False):
480 if commands is None:
481 commands = params.commands
482
483 keep_running = True
484 first_command = True
485 timedelay = params.timedelay
486
487 while keep_running:
488 for command in commands:
489 if first_command:
490 first_command = False
491 elif command_delay != 0:
492 time.sleep(command_delay)
493
494 if not quiet:
495 logging.info('Executing [%s]...', command)
496 try:
497 result = do_command(params, command)
498 if result is not None:
499 print(result)
500 except CommandError as e:
501 msg = f'{e.command}: {e.message}' if e.command else f'{e.message}'
502 logging.error(msg)
503 except Error as e:
504 logging.error("Communication Error: %s", e.message)
505 except Exception as e:
506 logging.debug(e, exc_info=True)
507 logging.error('An unexpected error occurred: %s', sys.exc_info()[0])
508
509 if timedelay == 0:
510 keep_running = False
511 else:
512 logging.info("%s Waiting for %d seconds", datetime.datetime.now().strftime('%Y/%m/%d %H:%M:%S'), timedelay)
513 try:
514 time.sleep(timedelay)
515 except KeyboardInterrupt:
516 keep_running = False
517
518
519def force_quit():

Callers

nothing calls this directly

Calls 4

do_commandFunction · 0.85
infoMethod · 0.45
errorMethod · 0.45
debugMethod · 0.45

Tested by

no test coverage detected