/mandos/release

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

« back to all changes in this revision

Viewing changes to mandos-ctl

  • Committer: Teddy Hogeborn
  • Date: 2019-03-15 23:55:53 UTC
  • mto: This revision was merged to the branch mainline in revision 382.
  • Revision ID: teddy@recompile.se-20190315235553-znbpfn7d8o84tyt6
mandos-ctl: Refactor

* mandos-ctl (main): Do some minor refactoring.

Show diffs side-by-side

added added

removed removed

Lines of Context:
102
102
    mandos_serv_object_manager = dbus.Interface(
103
103
        mandos_dbus_object, dbus_interface=dbus.OBJECT_MANAGER_IFACE)
104
104
 
 
105
    log.debug("D-Bus: %s:%s:%s.GetManagedObjects()", dbus_busname,
 
106
              server_dbus_path, dbus.OBJECT_MANAGER_IFACE)
105
107
    try:
106
 
        log.debug("D-Bus: %s:%s:%s.GetManagedObjects()", dbus_busname,
107
 
                  server_dbus_path, dbus.OBJECT_MANAGER_IFACE)
108
108
        with SilenceLogger("dbus.proxies"):
109
 
            all_clients = {path: ifs_and_props[client_dbus_interface]
110
 
                              for path, ifs_and_props in
111
 
                              mandos_serv_object_manager
112
 
                              .GetManagedObjects().items()
113
 
                              if client_dbus_interface in ifs_and_props}
 
109
            managed_objects = (mandos_serv_object_manager
 
110
                               .GetManagedObjects())
114
111
    except dbus.exceptions.DBusException as e:
115
112
        log.critical("Failed to access Mandos server through D-Bus:"
116
113
                     "\n%s", e)
117
114
        sys.exit(1)
118
115
 
119
 
    # Compile dict of (clients: properties) to process
120
 
    clients = {}
 
116
    all_clients = {}
 
117
    for path, ifs_and_props in managed_objects.items():
 
118
        try:
 
119
            all_clients[path] = ifs_and_props[client_dbus_interface]
 
120
        except KeyError:
 
121
            pass
121
122
 
 
123
    # Compile dict of (clientpath: properties) to process
122
124
    if not clientnames:
123
125
        clients = all_clients
124
126
    else:
 
127
        clients = {}
125
128
        for name in clientnames:
126
129
            for objpath, properties in all_clients.items():
127
130
                if properties["Name"] == name: