/mandos/trunk

To get this branch, use:
bzr branch http://bzr.recompile.se/loggerhead/mandos/trunk

« back to all changes in this revision

Viewing changes to mandos-ctl

  • Committer: Teddy Hogeborn
  • Date: 2019-03-05 19:14:51 UTC
  • Revision ID: teddy@recompile.se-20190305191451-jikzc84nv6h53l5u
mandos-ctl: Refactor

* mandos-ctl (commands_and_clients_from_options): Rename to
                         "commands_from_options"; all clients changed.
  (main): Get "clientnames" directly from "options.client", and move
          invocation of commands_from_options() to after "clients" is
          available.

Show diffs side-by-side

added added

removed removed

Lines of Context:
580
580
    parser.add_argument("client", nargs="*", help="Client name")
581
581
 
582
582
 
583
 
def commands_and_clients_from_options(options):
 
583
def commands_from_options(options):
584
584
 
585
585
    commands = []
586
586
 
594
594
        commands.append(DisableCmd())
595
595
 
596
596
    if options.bump_timeout:
597
 
        commands.append(BumpTimeoutCmd(options.bump_timeout))
 
597
        commands.append(BumpTimeoutCmd())
598
598
 
599
599
    if options.start_checker:
600
600
        commands.append(StartCheckerCmd())
651
651
    if not commands:
652
652
        commands.append(PrintTableCmd(verbose=options.verbose))
653
653
 
654
 
    return commands, options.client
 
654
    return commands
655
655
 
656
656
 
657
657
def main():
673
673
    if options.is_enabled and len(options.client) > 1:
674
674
        parser.error("--is-enabled requires exactly one client")
675
675
 
676
 
    commands, clientnames = commands_and_clients_from_options(options)
 
676
    clientnames = options.client
677
677
 
678
678
    try:
679
679
        bus = dbus.SystemBus()
726
726
                sys.exit(1)
727
727
 
728
728
    # Run all commands on clients
 
729
    commands = commands_from_options(options)
729
730
    for command in commands:
730
731
        command.run(mandos_serv, clients)
731
732