def monitor(state): nmtalk.message("'%s': %s" % (device_iface, nmdevice.device_state_to_str(state))) if state == nmdevice.DEVICE_STATE_ACTIVATED: loop.quit() elif state == nmdevice.DEVICE_STATE_FAILED or state == nmdevice.DEVICE_STATE_DISCONNECTED or \ state == nmdevice.DEVICE_STATE_CANCELLED: loop.quit() self.exit_status = 1
def execute(self, options_dict, non_option_args): manager = self.Manager() device_list = manager.get_devices() if len(device_list) < 1: nmtalk.message("No devices found.") return 0 table_rows = [] for device in device_list: row = (device.get_interface(), str(device), nmdevice.device_state_to_str(device.get_state())) table_rows.append(row) nmformat.tabular(("Interface", "Type", "State"), table_rows) return 0