u2flib_host/authenticate.py
def authenticate(devices, params, facet, check_only):
    """
    Interactively authenticates a AuthenticateRequest using an attached U2F
    device.
    """
    for device in devices[:]:
        try:
            device.open()
        except:
            devices.remove(device)

    try:
        prompted = False
        while devices:
            removed = []
            for device in devices:
                try:
                    return u2f.authenticate(device, params, facet, check_only)
                except exc.APDUError as e:
                    if e.code == APDU_USE_NOT_SATISFIED:
                        if check_only:
                            sys.stderr.write('\nCorrect U2F device present!\n')
                            sys.exit(0)
                        if not prompted:
                            sys.stderr.write('\nTouch the flashing U2F device '
                                             'to authenticate...\n')
                            prompted = True
                    else:
                        removed.append(device)
                except exc.DeviceError:
                    removed.append(device)
            devices = [d for d in devices if d not in removed]
            for d in removed:
                d.close()
            time.sleep(0.25)
    finally:
        for device in devices:
            device.close()
    sys.stderr.write('\nThe required U2F device is not present!\n')
    sys.exit(1)
def authenticate(devices, params, facet, check_only):
    for device in devices[:]:
        try:
            device.open()
        except:
            devices.remove(device)

    try:
        prompted = False
        while devices:
            removed = []
            for device in devices:
                try:
                    return u2f.authenticate(device, params, facet, check_only)
                except exc.APDUError as e:
                    if e.code == APDU_USE_NOT_SATISFIED:
                        if check_only:
                            sys.stderr.write('\nCorrect U2F device present!\n')
                            sys.exit(0)
                        if not prompted:
                            sys.stderr.write('\nTouch the flashing U2F device '
                                             'to authenticate...\n')
                            prompted = True
                    else:
                        removed.append(device)
                except exc.DeviceError:
                    removed.append(device)
            devices = [d for d in devices if d not in removed]
            for d in removed:
                d.close()
            time.sleep(0.25)
    finally:
        for device in devices:
            device.close()
    sys.stderr.write('\nThe required U2F device is not present!\n')
    sys.exit(1)
def authenticate ( devices , params , facet , check_only ) : for device in devices [ : ] : try : device . open ( ) except : devices . remove ( device ) try : prompted = False while devices : removed = [ ] for device in devices : try : return u2f . authenticate ( device , params , facet , check_only ) except exc . APDUError as e : if e . code == APDU_USE_NOT_SATISFIED : if check_only : sys . stderr . write ( '\nCorrect U2F device present!\n' ) sys . exit ( 0 ) if not prompted : sys . stderr . write ( '\nTouch the flashing U2F device ' 'to authenticate...\n' ) prompted = True else : removed . append ( device ) except exc . DeviceError : removed . append ( device ) devices = [ d for d in devices if d not in removed ] for d in removed : d . close ( ) time . sleep ( 0.25 ) finally : for device in devices : device . close ( ) sys . stderr . write ( '\nThe required U2F device is not present!\n' ) sys . exit ( 1 )
Interactively authenticates a AuthenticateRequest using an attached U2F
    device.
Interactively authenticates a AuthenticateRequest using an attached U2F device .