Returns Hardware device path
    Parameters:
        h_info,         interface set info handler
        interface_data, device interface enumeration data
        ptr_info_data,  pointer to SP_DEVINFO_DATA() instance to receive details
490327
def get_device_path(h_info, interface_data, ptr_info_data = None):
    "
    required_size = c_ulong(0)

    dev_inter_detail_data         = SP_DEVICE_INTERFACE_DETAIL_DATA()
    dev_inter_detail_data.cb_size = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA)

    # get actual storage requirement
    SetupDiGetDeviceInterfaceDetail(h_info, byref(interface_data),
            None, 0, byref(required_size),
            None)
    ctypes.resize(dev_inter_detail_data, required_size.value)

    # read value
    SetupDiGetDeviceInterfaceDetail(h_info, byref(interface_data),
            byref(dev_inter_detail_data), required_size, None,
            ptr_info_data)

    # extract string only
    return dev_inter_detail_data.get_string()
140858
def hid_device_path_exists(device_path, guid = None):
    
    # expecing HID devices
    if not guid:
        guid = winapi.GetHidGuid()

    info_data         = winapi.SP_DEVINFO_DATA()
    info_data.cb_size = sizeof(winapi.SP_DEVINFO_DATA)

    with winapi.DeviceInterfaceSetInfo(guid) as h_info:
        for interface_data in winapi.enum_device_interfaces(h_info, guid):
            test_device_path = winapi.get_device_path(h_info,
                    interface_data,
                    byref(info_data))
            if test_device_path == device_path:
                return True
    # Not any device now with that path
    return False
955815
def find_all_hid_devices():
    ""
    #
    # From DDK documentation (finding and Opening HID collection):
    # After a user-mode application is loaded, it does the following sequence
    # of operations:
    #
    #   * Calls HidD_GetHidGuid to obtain the system-defined GUID for HIDClass
    #     devices.
    #
    #   * Calls SetupDiGetClassDevs to obtain a handle to an opaque device
    #     information set that describes the device interfaces supported by all
    #     the HID collections currently installed in the system. The
    #     application should specify DIGCF_PRESENT and DIGCF_INTERFACEDEVICE
    #     in the Flags parameter passed to SetupDiGetClassDevs.
    #
    #   * Calls SetupDiEnumDeviceInterfaces repeatedly to retrieve all the
    #     available interface information.
    #
    #   * Calls SetupDiGetDeviceInterfaceDetail to format interface information
    #     for each collection as a SP_INTERFACE_DEVICE_DETAIL_DATA structure.
    #     The device_path member of this structure contains the user-mode name
    #     that the application uses with the Win32 function CreateFile to
    #     obtain a file handle to a HID collection.
    #
    # get HID device class guid
    guid = winapi.GetHidGuid()

    # retrieve all the available interface information.
    results = []
    required_size = DWORD()

    info_data         = winapi.SP_DEVINFO_DATA()
    info_data.cb_size = sizeof(winapi.SP_DEVINFO_DATA)

    with winapi.DeviceInterfaceSetInfo(guid) as h_info:
        for interface_data in winapi.enum_device_interfaces(h_info, guid):
            device_path = winapi.get_device_path(h_info,
                    interface_data,
                    byref(info_data))

            parent_device = c_ulong()

            #get parent instance id (so we can discriminate on port)
            if setup_api.CM_Get_Parent(byref(parent_device),
                    info_data.dev_inst, 0) != 0: #CR_SUCCESS = 0
                parent_device.value = 0 #null

            #get unique instance id string
            required_size.value = 0
            winapi.SetupDiGetDeviceInstanceId(h_info, byref(info_data),
                    None, 0,
                    byref(required_size) )

            device_instance_id = create_unicode_buffer(required_size.value)
            if required_size.value > 0:
                winapi.SetupDiGetDeviceInstanceId(h_info, byref(info_data),
                        device_instance_id, required_size,
                        byref(required_size) )

                hid_device = HidDevice(device_path,
                        parent_device.value, device_instance_id.value )
            else:
                hid_device = HidDevice(device_path, parent_device.value )

            # add device to results, if not protected
            if hid_device.vendor_id:
                results.append(hid_device)
    return results
706899
def _get_iface_info(iface):
    '''
    
    '''
    iface_info = interfaces()

    if iface in iface_info.keys():
        return iface_info, False
    else:
        error_msg = ('Interface "{0}" not in available interfaces: "{1}"'
                     ''.format(iface, '", "'.join(iface_info.keys())))
        log.error(error_msg)
        return None, error_msg
448959
def interfaces_info():
    
    def replace(value):
        if value == netifaces.AF_LINK:
            return 'link'
        if value == netifaces.AF_INET:
            return 'ipv4'
        if value == netifaces.AF_INET6:
            return 'ipv6'
        return value

    results = {}
    for iface in netifaces.interfaces():
        addrs = netifaces.ifaddresses(iface)
        results[iface] = {replace(k): v for k, v in addrs.items()}

    return results
1015132
def _parse_device_information(device_info_string) -> dict:
    '''
    
    '''
    error_msg = 'Unexpected argument to _parse_device_information: {}'.format(
        device_info_string)
    if not device_info_string or \
            not isinstance(device_info_string, str):
        raise ParseError(error_msg)
    parsed_values = device_info_string.strip().split(' ')
    if len(parsed_values) < 3:
        log.error(error_msg)
        raise ParseError(error_msg)
    res = {
        _parse_key_from_substring(s): _parse_string_value_from_substring(s)
        for s in parsed_values[:3]
    }
    for key in ['model', 'version', 'serial']:
        if key not in res:
            raise ParseError(error_msg)
    return res
253141
def _device_to_sysfs_path(device):
    """"""
    return '%s-%s' % (
        device.getBusNumber(),
        '.'.join([str(item) for item in device.GetPortNumberList()]))
175133
def GetRawDevice(path):
  """"""
  device_map = GetMountpoints()

  path = utils.SmartUnicode(path)
  mount_point = path = utils.NormalizePath(path, "/")

  result = rdf_paths.PathSpec(pathtype=rdf_paths.PathSpec.PathType.OS)

  # Assign the most specific mount point to the result
  while mount_point:
    try:
      result.path, fs_type = device_map[mount_point]
      if fs_type in [
          "ext2", "ext3", "ext4", "vfat", "ntfs", "Apple_HFS", "hfs", "msdos"
      ]:
        # These are read filesystems
        result.pathtype = rdf_paths.PathSpec.PathType.OS
      else:
        result.pathtype = rdf_paths.PathSpec.PathType.UNSET

      # Drop the mount point
      path = utils.NormalizePath(path[len(mount_point):])

      return result, path
    except KeyError:
      mount_point = os.path.dirname(mount_point)
986482
def get_peb_address(self):
        
        try:
            return self._peb_ptr
        except AttributeError:
            hProcess = self.get_handle(win32.PROCESS_QUERY_INFORMATION)
            pbi = win32.NtQueryInformationProcess(hProcess,
                                                win32.ProcessBasicInformation)
            address = pbi.PebBaseAddress
            self._peb_ptr = address
            return address
1289110
def get_info(self):
        '''  '''
        return {
            'Connected': self.is_connected(),
            'Port': self.port,
            'Bytes Waiting': self.ser.in_waiting if self.ser else 0
        }
1259269
def get_details(self):
        """"""
        body = helpers.req_body(self.manager, 'devicedetail')
        head = helpers.req_headers(self.manager)

        r, _ = helpers.call_api('/131airpurifier/v1/device/deviceDetail',
                                method='post', headers=head, json=body)

        if r is not None and helpers.check_response(r, 'airpur_detail'):
            self.device_status = r.get('deviceStatus', 'unknown')
            self.connection_status = r.get('connectionStatus', 'unknown')
            self.details['active_time'] = r.get('activeTime', 0)
            self.details['filter_life'] = r.get('filterLife', {})
            self.details['screeen_status'] = r.get('screenStatus', 'unknown')
            self.details['mode'] = r.get('mode', 'unknown')
            self.details['level'] = r.get('level', None)
806878
def parse_device_information(
        device_info_string: str) -> Mapping[str, str]:
    '''
        
    '''
    error_msg = 'Unexpected argument to parse_device_information: {}'.format(
        device_info_string)
    if not device_info_string or \
            not isinstance(device_info_string, str):
        raise ParseError(error_msg)
    parsed_values = device_info_string.strip().split(' ')
    if len(parsed_values) < 3:
        log.error(error_msg)
        raise ParseError(error_msg)
    res = {
        parse_key_from_substring(s): parse_string_value_from_substring(s)
        for s in parsed_values[:3]
    }
    for key in ['model', 'version', 'serial']:
        if key not in res:
            raise ParseError(error_msg)
    return res
269357
def hardware_info():
    
    try:
        if sys.platform == 'darwin':
            out = _mac_hardware_info()
        elif sys.platform == 'win32':
            out = _win_hardware_info()
        elif sys.platform in ['linux', 'linux2']:
            out = _linux_hardware_info()
        else:
            out = {}
    except:
        return {}
    else:
        return out
642108
def _get_hparams_path():
  """"""
  hparams_path = None
  if FLAGS.output_dir:
    hparams_path = os.path.join(FLAGS.output_dir, "hparams.json")
  else:
    tf.logging.warning(
        "--output_dir not specified. Hyper-parameters will be infered from"
        "--hparams_set and --hparams only. These may not match training time"
        "hyper-parameters.")
  return hparams_path
665277
def get_hardware_grains(service_instance):
    '''
    
    '''
    hw_grain_data = {}
    if get_inventory(service_instance).about.apiType == 'HostAgent':
        view = service_instance.content.viewManager.CreateContainerView(service_instance.RetrieveContent().rootFolder,
                                                                        [vim.HostSystem], True)
        if view and view.view:
            hw_grain_data['manufacturer'] = view.view[0].hardware.systemInfo.vendor
            hw_grain_data['productname'] = view.view[0].hardware.systemInfo.model

            for _data in view.view[0].hardware.systemInfo.otherIdentifyingInfo:
                if _data.identifierType.key == 'ServiceTag':
                    hw_grain_data['serialnumber'] = _data.identifierValue

            hw_grain_data['osfullname'] = view.view[0].summary.config.product.fullName
            hw_grain_data['osmanufacturer'] = view.view[0].summary.config.product.vendor
            hw_grain_data['osrelease'] = view.view[0].summary.config.product.version
            hw_grain_data['osbuild'] = view.view[0].summary.config.product.build
            hw_grain_data['os_family'] = view.view[0].summary.config.product.name
            hw_grain_data['os'] = view.view[0].summary.config.product.name
            hw_grain_data['mem_total'] = view.view[0].hardware.memorySize /1024/1024
            hw_grain_data['biosversion'] = view.view[0].hardware.biosInfo.biosVersion
            hw_grain_data['biosreleasedate'] = view.view[0].hardware.biosInfo.releaseDate.date().strftime('%m/%d/%Y')
            hw_grain_data['cpu_model'] = view.view[0].hardware.cpuPkg[0].description
            hw_grain_data['kernel'] = view.view[0].summary.config.product.productLineId
            hw_grain_data['num_cpu_sockets'] = view.view[0].hardware.cpuInfo.numCpuPackages
            hw_grain_data['num_cpu_cores'] = view.view[0].hardware.cpuInfo.numCpuCores
            hw_grain_data['num_cpus'] = hw_grain_data['num_cpu_sockets'] * hw_grain_data['num_cpu_cores']
            hw_grain_data['ip_interfaces'] = {}
            hw_grain_data['ip4_interfaces'] = {}
            hw_grain_data['ip6_interfaces'] = {}
            hw_grain_data['hwaddr_interfaces'] = {}
            for _vnic in view.view[0].configManager.networkSystem.networkConfig.vnic:
                hw_grain_data['ip_interfaces'][_vnic.device] = []
                hw_grain_data['ip4_interfaces'][_vnic.device] = []
                hw_grain_data['ip6_interfaces'][_vnic.device] = []

                hw_grain_data['ip_interfaces'][_vnic.device].append(_vnic.spec.ip.ipAddress)
                hw_grain_data['ip4_interfaces'][_vnic.device].append(_vnic.spec.ip.ipAddress)
                if _vnic.spec.ip.ipV6Config:
                    hw_grain_data['ip6_interfaces'][_vnic.device].append(_vnic.spec.ip.ipV6Config.ipV6Address)
                hw_grain_data['hwaddr_interfaces'][_vnic.device] = _vnic.spec.mac
            hw_grain_data['host'] = view.view[0].configManager.networkSystem.dnsConfig.hostName
            hw_grain_data['domain'] = view.view[0].configManager.networkSystem.dnsConfig.domainName
            hw_grain_data['fqdn'] = '{0}{1}{2}'.format(
                view.view[0].configManager.networkSystem.dnsConfig.hostName,
                ('.' if view.view[0].configManager.networkSystem.dnsConfig.domainName else ''),
                view.view[0].configManager.networkSystem.dnsConfig.domainName)

            for _pnic in view.view[0].configManager.networkSystem.networkInfo.pnic:
                hw_grain_data['hwaddr_interfaces'][_pnic.device] = _pnic.mac

            hw_grain_data['timezone'] = view.view[0].configManager.dateTimeSystem.dateTimeInfo.timeZone.name
        view = None
    return hw_grain_data
146965
def get_page_info(self, addr):
        
        assert self.region is not None
        if not self.region.contains_address(addr):
            return None

        info = PageInfo()
        info.program_weight = self.region.program_page_weight
        info.size = self.region.page_size
        info.base_addr = addr - (addr % info.size)
        return info
1175234
def get_navicli_SP_info(self, SP_address):
        
        self.add_cmd_output([
            "navicli -h %s getall" % SP_address,
            "navicli -h %s getsptime -spa" % SP_address,
            "navicli -h %s getsptime -spb" % SP_address,
            "navicli -h %s getlog" % SP_address,
            "navicli -h %s getdisk" % SP_address,
            "navicli -h %s getcache" % SP_address,
            "navicli -h %s getlun" % SP_address,
            "navicli -h %s getlun -rg -type -default -owner -crus "
            "-capacity" % SP_address,
            "navicli -h %s lunmapinfo" % SP_address,
            "navicli -h %s getcrus" % SP_address,
            "navicli -h %s port -list -all" % SP_address,
            "navicli -h %s storagegroup -list" % SP_address,
            "navicli -h %s spportspeed -get" % SP_address
        ])