Returns a set of all USB modes, with optional filtering
557372
def all(cls, otp=False, ccid=False, u2f=False):
        """"""
        modes = set([
            cls.OTP,
            cls.CCID,
            cls.OTP_CCID,
            cls.U2F,
            cls.OTP_U2F,
            cls.U2F_CCID,
            cls.OTP_U2F_CCID
        ])

        if otp:
            modes.difference_update(set([
                cls.CCID,
                cls.U2F,
                cls.U2F_CCID
            ]))

        if ccid:
            modes.difference_update(set([
                cls.OTP,
                cls.U2F,
                cls.OTP_U2F
            ]))

        if u2f:
            modes.difference_update(set([
                cls.OTP,
                cls.CCID,
                cls.OTP_CCID
            ]))

        return modes
44020
def get_all_usb_devices(idVendor, idProduct):
        
        all_dev = list(usb.core.find(find_all = True, idVendor = idVendor, idProduct = idProduct))
        for dev in all_dev:
            try:
                dev.detach_kernel_driver(0)
            except usb.USBError:
                pass
        return all_dev
1089235
def file_mode(self):
        """"""
        fms = self.attributes['file_mode']
        eax = set()
        if isinstance(fms, six.string_types):
            fms = shlex.split(fms)
        for fm in fms:
            if fm == 'both':
                eax.add('fpp')
                eax.add('onefile')
            elif fm in ['fpp', 'onefile']:
                eax.add(fm)
            else:
                raise Exception('Invalid IOR file mode: ' + fm)
        return eax
59380
def list_adb_devices_by_usb_id():
    
    out = adb.AdbProxy().devices(['-l'])
    clean_lines = new_str(out, 'utf-8').strip().split('\n')
    results = []
    for line in clean_lines:
        tokens = line.strip().split()
        if len(tokens) > 2 and tokens[1] == 'device':
            results.append(tokens[2])
    return results
547780
def get_all_media(exclude=None):
    

    if not exclude:
        exclude = []

    media = set()

    for root, dirs, files in os.walk(six.text_type(settings.MEDIA_ROOT)):
        for name in files:
            path = os.path.abspath(os.path.join(root, name))
            relpath = os.path.relpath(path, settings.MEDIA_ROOT)
            for e in exclude:
                if re.match(r'^%s$' % re.escape(e).replace('\\*', '.*'), relpath):
                    break
            else:
                media.add(path)

    return media
90480
def _autodiscover_usb(self):
        
        if sys.platform.startswith('win'):
            ports = ['COM%s' % (i + 1) for i in range(256)]
        elif sys.platform.startswith('linux') or sys.platform.startswith('cygwin'):
            ports = glob.glob('/dev/tty[A-Za-z]*')
        elif sys.platform.startswith('darwin'):
            ports = glob.glob('/dev/cu.*')
        else:
            raise EnvironmentError('Unsupported platform')

        match = None
        for port in ports:
            try:
                s = serial.Serial(port)
                s.close()
                if (port.find("/dev/cu.usbserial-") > -1 and
                        port.find('bluetooth') == -1):
                    self.USB_PORT = port
                    match = port
                    break
            except (OSError, serial.SerialException):
                pass
        return match
1172983
def modes(self):
        
        (self._modes, value) = self.get_cached_attr_set(self._modes, 'modes')
        return value
586034
def find_all(cls, vid=None, pid=None):
        
        if not have_pyftdi:
            raise ImportError('The USBDevice class has been disabled due to missing requirement: pyftdi or pyusb.')

        cls.__devices = []

        query = cls.PRODUCT_IDS
        if vid and pid:
            query = [(vid, pid)]

        try:
            cls.__devices = Ftdi.find_all(query, nocache=True)

        except (usb.core.USBError, FtdiError) as err:
            raise CommError('Error enumerating AD2USB devices: {0}'.format(str(err)), err)

        return cls.__devices
562911
def available_modes_with_ids(self):
        """"""
        if not self._available_mode_ids:
            all_modes = FIXED_MODES.copy()
            self._available_mode_ids = all_modes
            modes = self.get_available_modes()
            try:
                if modes:
                    # pylint: disable=consider-using-dict-comprehension
                    simple_modes = dict(
                        [(m.get("type", m.get("name")), m.get("id"))
                         for m in modes]
                    )
                    all_modes.update(simple_modes)
                    self._available_mode_ids = all_modes
            except TypeError:
                _LOGGER.debug("Did not receive a valid response. Passing..")
        return self._available_mode_ids
1305018
def listports():
    
    detected = False
    for port in serial.tools.list_ports.comports():
        detected = True
        if port.vid:
            micropythonPort = ''
            if is_micropython_usb_device(port):
                micropythonPort = ' *'
            print('USB Serial Device {:04x}:{:04x}{} found @{}{}\r'.format(
                  port.vid, port.pid,
                  extra_info(port), port.device, micropythonPort))
        else:
            print('Serial Device:', port.device)
    if not detected:
        print('No serial devices detected')
29009
def find_serial_devices(serial_matcher="ED"):
    
    objWMIService = win32com.client.Dispatch("WbemScripting.SWbemLocator")
    objSWbemServices = objWMIService.ConnectServer(".", "root\cimv2")
    items = objSWbemServices.ExecQuery("SELECT * FROM Win32_USBControllerDevice")
    ids = (item.Dependent.strip('"')[-8:] for item in items)
    return [e for e in ids if e.startswith(serial_matcher)]
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
1217505
def available_modes(self):
        """"""
        if not self._available_modes:
            modes = self.available_modes_with_ids
            if not modes:
                return None
            self._available_modes = list(modes.keys())
        return self._available_modes
1319759
def _get_mounts(fs_type=None):
    '''
    
    '''
    mounts = {}
    with salt.utils.files.fopen('/proc/mounts') as fhr:
        for line in fhr.readlines():
            line = salt.utils.stringutils.to_unicode(line)
            device, mntpnt, fstype, options, fs_freq, fs_passno = line.strip().split(" ")
            if fs_type and fstype != fs_type:
                continue
            if mounts.get(device) is None:
                mounts[device] = []

            data = {
                'mount_point': mntpnt,
                'options': options.split(",")
            }
            if not fs_type:
                data['type'] = fstype
            mounts[device].append(data)
    return mounts
875195
def get_formats(self):
        
        formats = []
        for key in (self.FORMAT_DC, self.FORMAT_FGDC, self.FORMAT_ISO):
            if hasattr(self, key):
                formats.append(key)
        return formats
2080
public static List<UsbDevice> getKnxDevices()
	{
		final List<UsbDevice> knx = new ArrayList<>();
		for (final UsbDevice d : getDevices()) {
			final int vendor = d.getUsbDeviceDescriptor().idVendor() & 0xffff;
			for (final int v : vendorIds)
				if (v == vendor)
					knx.add(d);
		}
		return knx;
	}
899506
def get_modes(self, zone):
        """"""
        self._populate_full_data()
        device = self._get_device(zone)
        return device['thermostat']['allowedModes']