Obtains a U2FInterface for the first valid local U2FHID device found.
436480
def GetLocalU2FInterface(origin=socket.gethostname()):
  """"""
  hid_transports = hidtransport.DiscoverLocalHIDU2FDevices()
  for t in hid_transports:
    try:
      return U2FInterface(security_key=hardware.SecurityKey(transport=t),
                          origin=origin)
    except errors.UnsupportedVersionException:
      # Skip over devices that don't speak the proper version of the protocol.
      pass

  # Unable to find a device
  raise errors.NoDeviceFoundError()
169681
private function getDeviceFingerprint()
    {
        $server = $this->httpRequest()->server();

        $did = '';
        //$did .= $server->httpAccept();
        //$did .= '|' . $server->httpAcceptCharset();
        //$did .= '|' . $server->httpAcceptEncoding();
        $did .= '|' . $server->httpAcceptLanguage();

        // append browser details
        if (empty($server->httpUserAgent())) {
            throw new LoginException('Unable to process the request without a user agent', 100);
        }

        $platform = 'unknown';
        $ub = 'unknown';

        // get the platform
        $ua = $server->httpUserAgent();
        if (preg_match('/linux/i', $ua)) {
            $platform = 'linux';
        } elseif (preg_match('/macintosh|mac os x/i', $ua)) {
            $platform = 'mac';
        } elseif (preg_match('/windows|win32/i', $ua)) {
            $platform = 'windows';
        }

        // get browser name
        if (preg_match('/MSIE/i', $ua) && !preg_match('/Opera/i', $ua)) {
            $ub = "MSIE";
        } elseif (preg_match('/Firefox/i', $ua)) {
            $ub = "Firefox";
        } elseif (preg_match('/Chrome/i', $ua)) {
            $ub = "Chrome";
        } elseif (preg_match('/Safari/i', $ua)) {
            $ub = "Safari";
        } elseif (preg_match('/Opera/i', $ua)) {
            $ub = "Opera";
        } elseif (preg_match('/Netscape/i', $ua)) {
            $ub = "Netscape";
        }

        $did .= '|' . $platform;
        $did .= '|' . $ub;

        return md5($did);
    }
1093532
def u2i(uint32):
    
    mask = (2 ** 32) - 1
    if uint32 & (1 << 31):
        v = uint32 | ~mask
    else:
        v = uint32 & mask
    return v
1314307
def _find_device(self, idVendor, idProduct):
        """"""
        for bus in usb.busses():
            for device in bus.devices:
                if (device.idVendor == idVendor and
                    device.idProduct == idProduct):
                    return device
        return None
585937
def verify_signature(self, signature):
        """"""

        devices   = [DeviceRegistration.wrap(device) for device in self.__get_u2f_devices()]
        challenge = session.pop('_u2f_challenge_')

        try:
            counter, touch = verify_authenticate(devices, challenge, signature, self.__facets_list)
        except Exception as e:
            if self.__call_fail_sign:
                self.__call_fail_sign(e)

            return {
                'status':'failed', 
                'error': 'Invalid signature!'
            }
        finally:
            pass

        if self.verify_counter(signature, counter):
            self.__call_success_sign()
            self.disable_sign()
            
            return {
                'status'  : 'ok',
                'counter' : counter,
                'message': 'Successfully verified your second factor!'
            }


        else:
            if self.__call_fail_sign:
                self.__call_fail_sign()

            return {
                'status':'failed', 
                'error': 'Device clone detected!'
            }
269679
def find_device(self):
        """"""
        for bdaddr, name in self.scan():
            if name == "Wireless Controller":
                self.logger.info("Found device {0}", bdaddr)
                return BluetoothDS4Device.connect(bdaddr)
328463
def _getdevicetuple(iobtdevice):
    
    addr = _macutil.formatdevaddr(iobtdevice.getAddressString())
    name = iobtdevice.getName()
    cod = iobtdevice.getClassOfDevice()
    return (addr, name, cod)
1244622
def get_interface(iface):
    '''
    
    '''
    path = os.path.join(_RH_NETWORK_SCRIPT_DIR, 'ifcfg-{0}'.format(iface))
    return _read_file(path)
361200
def enable_mfa_device(self,
                          user_name,
                          serial_number,
                          authentication_code_1,
                          authentication_code_2):
        """"""
        user = self.get_user(user_name)
        if serial_number in user.mfa_devices:
            raise IAMConflictException(
                "EntityAlreadyExists",
                "Device {0} already exists".format(serial_number)
            )

        user.enable_mfa_device(
            serial_number,
            authentication_code_1,
            authentication_code_2
        )
666307
def get_if_addr6(iff):
    
    return next((x[0] for x in in6_getifaddr()
                 if x[2] == iff and x[1] == IPV6_ADDR_GLOBAL), None)
415170
def _device_lookup(self, device_name):
        '''  '''
        device_found = {}
        response = requests.get(self._api_url + 'devices',
                                auth=(self._api_key, ''))
        if response.ok:
            for device in response.json()['devices']:
                if device_name == device['extras']['model']:
                    #TODO Check device['extras']['nickname'] as well
                    device_found = device
        return device_found
624538
def file_identifier(self):
        # type: () -> bytes
        '''
        
        '''
        if not self._initialized:
            raise pycdlibexception.PyCdlibInternalError('UDF File Entry not initialized')

        if self.file_ident is None:
            return b'/'

        return self.file_ident.fi
697594
def getDisplayIdentifier(self):
        
        if self.display_identifier is not None:
            return self.display_identifier
        if self.claimed_id is None:
            return None
        else:
            return urlparse.urldefrag(self.claimed_id)[0]
1044024
def find_device(vidpid):
    """"""
    for port in list_ports.comports():
        if re.search(vidpid, port[2], flags=re.IGNORECASE):
            return port[0]

    raise exceptions.RoasterLookupError
45552
def get_working_if():
    """"""
    try:
        # return the interface associated with the route with smallest
        # mask (route by default if it exists)
        iface = min(conf.route.routes, key=lambda x: x[1])[3]
    except ValueError:
        # no route
        iface = scapy.consts.LOOPBACK_INTERFACE
    if iface.is_invalid():
        # Backup mode: try them all
        for iface in six.itervalues(IFACES):
            if not iface.is_invalid():
                return iface
        return None
    return iface
939084
def InterfaceMatcher(clazz, subclass, protocol):
    """"""
    interface = (clazz, subclass, protocol)

    def Matcher(device):
        for setting in device.iterSettings():
            if GetInterface(setting) == interface:
                return setting

    return Matcher
1347293
def interface_by_ipaddr(self, ipaddr):
        '''
        
        '''
        ipaddr = IPAddr(ipaddr)
        for devname,iface in self._devinfo.items():
            if iface.ipaddr == ipaddr:
                return iface
        raise KeyError("No device has IP address {}".format(ipaddr))