List devices in settings file and print versions
505359
def list_devices(names=None, continue_from=None, **kwargs):
    """"""

    if not names:
        names = [device for device, _type in settings.GOLDEN_DEVICES if _type == 'OpenThread']

    if continue_from:
        continue_from = names.index(continue_from)
    else:
        continue_from = 0

    for port in names[continue_from:]:
        try:
            with OpenThreadController(port) as otc:
                print('%s: %s' % (port, otc.version))
        except:
            logger.exception('failed to get version of %s' % port)
1219988
def show(self, resolve_mac=True):
        """"""

        print("%s  %s  %s  %s" % ("INDEX".ljust(5), "IFACE".ljust(35), "IP".ljust(15), "MAC"))
        for iface_name in sorted(self.data.keys()):
            dev = self.data[iface_name]
            mac = dev.mac
            if resolve_mac and iface_name != LOOPBACK_NAME:
                mac = conf.manufdb._resolve_MAC(mac)
            print("%s  %s  %s  %s" % (str(dev.win_index).ljust(5), str(dev.name).ljust(35), str(dev.ip).ljust(15), mac)     )
1146725
def print_device_list(self, device_list=None):
        
        dev_list = device_list if device_list is not None else self.get_all_devices_in_portal()

        for dev in dev_list:
            print('{0}\t\t{1}\t\t{2}'.format(
                    dev['info']['description']['name'],
                    dev['sn'],
                    dev['portals_aliases']\
                        if len(dev['portals_aliases']) != 1
                        else dev['portals_aliases'][0]
                )
            )
490627
def list_dfu_devices(*args, **kwargs):
    """"""
    devices = get_dfu_devices(*args, **kwargs)
    if not devices:
        print("No DFU capable devices found")
        return
    for device in devices:
        print("Bus {} Device {:03d}: ID {:04x}:{:04x}"
              .format(device.bus, device.address,
                      device.idVendor, device.idProduct))
        layout = get_memory_layout(device)
        print("Memory Layout")
        for entry in layout:
            print("    0x{:x} {:2d} pages of {:3d}K bytes"
                  .format(entry['addr'], entry['num_pages'],
                          entry['page_size'] // 1024))
88175
def cli(env, ip_version):
    """"""

    mgr = SoftLayer.NetworkManager(env.client)

    table = formatting.Table(['id', 'ip', 'assigned', 'target'])

    version = None
    if ip_version == 'v4':
        version = 4
    elif ip_version == 'v6':
        version = 6

    ips = mgr.list_global_ips(version=version)

    for ip_address in ips:
        assigned = 'No'
        target = 'None'
        if ip_address.get('destinationIpAddress'):
            dest = ip_address['destinationIpAddress']
            assigned = 'Yes'
            target = dest['ipAddress']
            virtual_guest = dest.get('virtualGuest')
            if virtual_guest:
                target += (' (%s)'
                           % virtual_guest['fullyQualifiedDomainName'])
            elif ip_address['destinationIpAddress'].get('hardware'):
                target += (' (%s)'
                           % dest['hardware']['fullyQualifiedDomainName'])

        table.add_row([ip_address['id'],
                       ip_address['ipAddress']['ipAddress'],
                       assigned,
                       target])
    env.fout(table)
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()
215847
async def get_devices(self, covers_only: bool = True) -> list:
        """"""
        from .device import MyQDevice

        _LOGGER.debug('Retrieving list of devices')
        devices_resp = await self._request('get', DEVICE_LIST_ENDPOINT)
        # print(json.dumps(devices_resp, indent=4))

        device_list = []
        if devices_resp is None:
            return device_list

        for device in devices_resp['Devices']:
            if not covers_only or \
               device['MyQDeviceTypeName'] in SUPPORTED_DEVICE_TYPE_NAMES:

                self._devices.append({
                    'device_id': device['MyQDeviceId'],
                    'device_info': device
                })
                myq_device = MyQDevice(
                    self._devices[-1], self._brand, self)
                device_list.append(myq_device)

        # Store current device states.
        self._store_device_states(devices_resp.get('Devices', []))

        _LOGGER.debug('List of devices retrieved')
        return device_list
960690
def get_settings(all,key):
    """"""
    with Database("settings") as s:
        if all:
            for k, v in zip(list(s.keys()), list(s.values())):
                print("{} = {}".format(k, v))
        elif key:
            print("{} = {}".format(key, s[key]))
        else:
            print("Don't know what you want? Try --all")
49318
def devices(self):
        
        eax = self.attributes.get('devices')
        if eax is None:
            eax = self._all_devices
        if not isinstance(eax, list):
            eax = [eax]
        return [str(dev) for dev in eax]
583365
async def device_info():
    """"""
    async with aiohttp.ClientSession() as session:
        ghlocalapi = DeviceInfo(LOOP, session, IPADDRESS)
        await ghlocalapi.get_device_info()

        print("Device info:", ghlocalapi.device_info)
16081
def info(ctx, check_fips):
    
    dev = ctx.obj['dev']

    if dev.is_fips and check_fips:
        fips_status = get_overall_fips_status(dev.serial, dev.config)

    click.echo('Device type: {}'.format(dev.device_name))
    click.echo('Serial number: {}'.format(
        dev.serial or 'Not set or unreadable'))
    if dev.version:
        f_version = '.'.join(str(x) for x in dev.version)
        click.echo('Firmware version: {}'.format(f_version))
    else:
        click.echo('Firmware version: Uncertain, re-run with only one '
                   'YubiKey connected')

    config = dev.config
    if config.form_factor:
        click.echo('Form factor: {!s}'.format(config.form_factor))
    click.echo('Enabled USB interfaces: {}'.format(dev.mode))
    if config.nfc_supported:
        f_nfc = 'enabled' if config.nfc_enabled else 'disabled'
        click.echo('NFC interface is {}.'.format(f_nfc))
    if config.configuration_locked:
        click.echo('Configured applications are protected by a lock code.')
    click.echo()

    print_app_status_table(config)

    if dev.is_fips and check_fips:
        click.echo()

        click.echo('FIPS Approved Mode: {}'.format(
            'Yes' if all(fips_status.values()) else 'No'))

        status_keys = list(fips_status.keys())
        status_keys.sort()
        for status_key in status_keys:
            click.echo('  {}: {}'.format(
                status_key, 'Yes' if fips_status[status_key] else 'No'))
70900
def show_version_queue(a_device, output_q):
    
    output_dict = {}
    remote_conn = ConnectHandler(**a_device)
    hostname = remote_conn.base_prompt
    output = ("#" * 80) + "\n"
    output += remote_conn.send_command("show version") + "\n"
    output += ("#" * 80) + "\n"
    output_dict[hostname] = output
    output_q.put(output_dict)
81691
def refresh_devices(self):
        ''''''
        try:
            response = self.api.get("/api/v2/devices", {'properties':'all'})
            for device_data in response['DeviceList']:
                self.devices.append(Device(device_data, self))
        except APIError as e:
            print("API error: ")
            for key,value in e.data.iteritems:
                print(str(key) + ": " + str(value))
504054
def get_device_configs():
    '''
    
    '''
    frames = []

    for i in range(2):
        for device in get_video_sources():
            df_device_i = get_configs(device)
            df_device_i.insert(0, 'device', str(device))
            frames.append(df_device_i)

    device_configs = pd.concat(frames).drop_duplicates()
    device_configs['label'] = device_configs.device.map(
        lambda x: x.split('/')[-1].split('-')[1].split('_')[0])
    device_configs['bitrate'] = device_configs.height.map(get_bitrate)
    return device_configs
1255554
def device_statistics(fritz, args):
    """"""
    stats = fritz.get_device_statistics(args.ain)
    print(stats)
620516
def loopback_devices():
    '''
    
    '''
    loopbacks = {}
    cmd = ['losetup', '-a']
    output = check_output(cmd)
    if six.PY3:
        output = output.decode('utf-8')
    devs = [d.strip().split(' ') for d in output.splitlines() if d != '']
    for dev, _, f in devs:
        loopbacks[dev.replace(':', '')] = re.search(r'\((\S+)\)', f).groups()[0]
    return loopbacks
1108933
async def dump_devinfo(dev: Device, file):
    
    import attr

    methods = await dev.get_supported_methods()
    res = {
        "supported_methods": {k: v.asdict() for k, v in methods.items()},
        "settings": [attr.asdict(x) for x in await dev.get_settings()],
        "sysinfo": attr.asdict(await dev.get_system_info()),
        "interface_info": attr.asdict(await dev.get_interface_information()),
    }
    if file:
        click.echo("Saving to file: %s" % file.name)
        json.dump(res, file, sort_keys=True, indent=4)
    else:
        click.echo(json.dumps(res, sort_keys=True, indent=4))