Manage the device json list.
970825
def handle_device_json(self, data):
        """"""
        self._device_json.insert(0, data)
        self._device_json.pop()
81100
def devices
      devices = @adb.devices.map { |d|
        serial = d.serial_number
        (@devices.has_key?(serial) && same_jobject?(@devices[serial].jobject, d)) \
          ? @devices[serial] : Device.new(d)
      }
      @devices = DeviceList.new(devices)
      return @devices
    end
228942
def refresh_data(self):
        """"""
        j = self.data_request({'id': 'sdata'}).json()

        self.temperature_units = j.get('temperature', 'C')
        self.model = j.get('model')
        self.version = j.get('version')
        self.serial_number = j.get('serial_number')

        categories = {}
        cats = j.get('categories')

        for cat in cats:
            categories[cat.get('id')] = cat.get('name')

        device_id_map = {}

        devs = j.get('devices')
        for dev in devs:
            dev['categoryName'] = categories.get(dev.get('category'))
            device_id_map[dev.get('id')] = dev

        return device_id_map
534102
def update(self, device_json=None, info_json=None, settings_json=None,
               avatar_json=None):
        """"""
        if device_json:
            UTILS.update(self._device_json, device_json)

        if avatar_json:
            UTILS.update(self._avatar_json, avatar_json)

        if info_json:
            UTILS.update(self._info_json, info_json)

        if settings_json:
            UTILS.update(self._settings_json, settings_json)
418635
function listDevices() {
    return getDevice()
    .then(device => {
        console.log(`Device: ${device.id}`);
        return device.listResources();
    })
    .then(resources => {
        resources.forEach(resource => {
            resource.getValue()
            .then(value => {
                console.log(`\t└\x1b[1m${resource.path}\x1b[0m: ${value}`);
            })
            .catch(error => {
                console.log(`\t└\x1b[1m${resource.path}\x1b[0m: Error: ${error.message}`);
            });
        });
    });
}
937375
def serialize(self):
        """"""
        commands = []

        for cmd in self.commands:
            commands.append(cmd.serialize())

        out = {'commands': commands, 'deviceURL': self.__device_url}

        return out
954764
def list_all(dev: Device):
    """"""
    for name, service in dev.services.items():
        click.echo(click.style("\nService %s" % name, bold=True))
        for method in service.methods:
            click.echo("  %s" % method.name)
173407
def json_data(self):
        """"""
        return {
            "info_in_id": self.info_in_id,
            "info_out_id": self.info_out_id,
            "node_id": self.node_id,
            "network_id": self.network_id,
        }
1250043
def update(self):
        """"""
        with self._lock:
            devices = self._request_devices(MINUT_DEVICES_URL, 'devices')

            if devices:
                self._state = {
                    device['device_id']: device
                    for device in devices
                }
                _LOGGER.debug("Found devices: %s", list(self._state.keys()))
                # _LOGGER.debug("Device status: %s", devices)
            homes = self._request_devices(MINUT_HOMES_URL, 'homes')
            if homes:
                self._homes = homes
            return self.devices
978329
def get_device_name_list():
    """"""
    dev_names = ctypes.create_string_buffer(1024)
    pydaq.DAQmxGetSysDevNames(dev_names, len(dev_names))
    return dev_names.value.split(', ')
218921
def json(self):
        
        return {
            "status": self.status,
            "criteria_name": self.criteria_name,
            "warnings": [w.json() for w in self.warnings],
            "settings": self.settings,
        }
290747
def display_inventory(my_devices):
    """"""
    inventory_groups = ["all"]
    inventory_devices = []
    for k, v in my_devices.items():
        if isinstance(v, list):
            inventory_groups.append(k)
        elif isinstance(v, dict):
            inventory_devices.append((k, v["device_type"]))

    inventory_groups.sort()
    inventory_devices.sort(key=lambda x: x[0])
    print("\nDevices:")
    print("-" * 40)
    for a_device, device_type in inventory_devices:
        device_type = "  ({})".format(device_type)
        print("{:<25}{:>15}".format(a_device, device_type))
    print("\n\nGroups:")
    print("-" * 40)
    for a_group in inventory_groups:
        print(a_group)
    print()
1028698
def device_state(device_id):
    
    if device_id not in devices:
        return jsonify(success=False)
    return jsonify(state=devices[device_id].state)
1028303
def update(self):
        """"""
        for device in self.devices:
            device.update()
        for i in range(len(self._channel_dict["devices"])):
            device_dict = self._channel_dict["devices"][i]
            for device in self._devices:
                if device.name == device_dict["common.ALLTYPES_NAME"]:
                    self._channel_dict["devices"][i] = device.as_dict()
734484
def device_info(self):
        """"""
        return {
            'family': self.family,
            'platform': self.platform,
            'os_type': self.os_type,
            'os_version': self.os_version,
            'udi': self.udi,
            # TODO(klstanie): add property to make driver automatically
            'driver_name': self.driver.platform,
            'mode': self.mode,
            'is_console': self.is_console,
            'is_target': self.is_target,
            # 'prompt': self.driver.base_prompt(self.prompt),
            'hostname': self.hostname,
        }
453638
def json_data(self):
        """"""
        return {
            "vector_id": self.vector_id,
            "origin_id": self.origin_id,
            "destination_id": self.destination_id,
            "info_id": self.info_id,
            "network_id": self.network_id,
            "receive_time": self.receive_time,
            "status": self.status,
        }
906987
def _treat_devices_added(self):
        """"""
        try:
            devices_details_list = self._plugin_rpc.get_devices_details_list(
                self._context, self._added_ports, self._agent_id)
        except Exception as exc:
            LOG.debug("Unable to get ports details for "
                      "devices %(devices)s: %(exc)s",
                      {'devices': self._added_ports, 'exc': exc})
            return

        for device_details in devices_details_list:
            device = device_details['device']
            LOG.info("Adding port %s", device)
            if 'port_id' in device_details:
                LOG.info("Port %(device)s updated. "
                         "Details: %(device_details)s",
                         {'device': device, 'device_details': device_details})
                eventlet.spawn_n(self.process_added_port, device_details)
            else:
                LOG.debug("Missing port_id from device details: "
                          "%(device)s. Details: %(device_details)s",
                          {'device': device, 'device_details': device_details})

            LOG.debug("Remove the port from added ports set, so it "
                      "doesn't get reprocessed.")
            self._added_ports.discard(device)