<commit_before>import time

import fingerpi as fp


def enroll():
    f = fp.FingerPi()
    f.Open(extra_info=True, check_baudrate=True)
    f.ChangeBaudrate(115200)
    print "Put your fingerprint on the scanner"
    f.CmosLed(True)

    while not isFingerPressed(f):
        time.sleep(1)
    id = int(f.GetEnrollCount()[0]["Parameter"]) + 1
    f.DeleteId(id)

    #Enroll Start
    enrollStart = f.EnrollStart(id)
    print "Using ID: " + str(id)
    print "Enroll Start done " + str(enrollStart)

    #Capture Finger
    f.CaptureFinger(best_image=True)
    time.sleep(1)

    #Enroll 1
    enroll1 = f.Enroll1()
    print "Enroll 1 done " + str(enroll1)

    #Wait using fingerPressed
    while not isFingerPressed(f):
        time.sleep(1)

    #Capture Finger
    f.CaptureFinger(best_image=True)
    time.sleep(1)

    #Enroll 2
    enroll2 = f.Enroll2()
    print "Enroll 2 done " + str(enroll2)

    #Wait using fingerPressed
    while not isFingerPressed(f):
        time.sleep(1)

    #Capture Finger
    f.CaptureFinger(best_image=True)
    time.sleep(1)

    #Enroll 3
    enroll3 = f.Enroll3_()
    print "Enroll 3 done " + str(enroll3)

    f.CmosLed(False)
    print "Enrolled :" + str(f.GetEnrollCount()[0]["Parameter"])
    f.Close()

    if enroll3 and enroll3[0] and enroll3[0]["ACK"]:
        return bool(enroll3[0]["ACK"]), id
    else:
        return False, -100


def identify():
    f = fp.FingerPi()
    f.Open(extra_info=True, check_baudrate=True)
    #f.ChangeBaudrate(115200)
    print "Put your fingerprint on the scanner"
    f.CmosLed(True)

    times = 0
    while not isFingerPressed(f):
        time.sleep(1)
        times += 1

        if times > 10:
            break
    if times > 5:
        f.CmosLed(False)
        return False, -1000

    f.CaptureFinger(best_image=False)
    f.CmosLed(False)
    ide = f.Identify()

    if ide and ide[0] and ide[0]["ACK"]:
        print bool(ide[0]["ACK"]), int(ide[0]["Parameter"])
        return bool(ide[0]["ACK"]), int(ide[0]["Parameter"])
    else:
        return False, -1000

def isFingerPressed(fp):
    return int(fp.IsPressFinger()[0]["Parameter"]) == 0<commit_msg>Slight changes to scanner<commit_after>import time

import fingerpi as fp


def enroll():
    f = fp.FingerPi()
    f.Open(extra_info=True, check_baudrate=True)
    f.ChangeBaudrate(115200)
    print "Put your fingerprint on the scanner"
    f.CmosLed(True)

    while not isFingerPressed(f):
        time.sleep(1)
    id = int(f.GetEnrollCount()[0]["Parameter"]) + 1
    f.DeleteId(id)

    #Enroll Start
    enrollStart = f.EnrollStart(id)
    print "Using ID: " + str(id)
    print "Enroll Start done " + str(enrollStart)

    #Capture Finger
    f.CaptureFinger(best_image=True)
    time.sleep(1)

    #Enroll 1
    enroll1 = f.Enroll1()
    print "Enroll 1 done " + str(enroll1)

    #Wait using fingerPressed
    while not isFingerPressed(f):
        time.sleep(1)

    #Capture Finger
    f.CaptureFinger(best_image=True)
    time.sleep(1)

    #Enroll 2
    enroll2 = f.Enroll2()
    print "Enroll 2 done " + str(enroll2)

    #Wait using fingerPressed
    while not isFingerPressed(f):
        time.sleep(1)

    #Capture Finger
    f.CaptureFinger(best_image=True)
    time.sleep(1)

    #Enroll 3
    enroll3 = f.Enroll3_()
    print "Enroll 3 done " + str(enroll3)

    f.CmosLed(False)
    print "Enrolled: " + str(f.GetEnrollCount()[0]["Parameter"])
    f.Close()

    if enroll3 and enroll3[0] and enroll3[0]["ACK"]:
        return bool(enroll3[0]["ACK"]), id
    else:
        return False, -100


def identify():
    f = fp.FingerPi()
    f.Open(extra_info=True, check_baudrate=True)
    #f.ChangeBaudrate(115200)
    print "Put your fingerprint on the scanner"
    f.CmosLed(True)

    times = 0
    while not isFingerPressed(f):
        time.sleep(1)
        times += 1

        if times > 5:
            break
    if times > 5:
        f.CmosLed(False)
        return False, -1000

    f.CaptureFinger(best_image=False)
    f.CmosLed(False)
    ide = f.Identify()
    f.Close()

    if ide and ide[0] and ide[0]["ACK"]:
        print bool(ide[0]["ACK"]), int(ide[0]["Parameter"])
        return bool(ide[0]["ACK"]), int(ide[0]["Parameter"])
    else:
        return False, -1000

def isFingerPressed(fp):
    return int(fp.IsPressFinger()[0]["Parameter"]) == 0
{'fraction_non_alphanumeric': 0.13217993079584775, 'fraction_numerical': 0.031141868512110725, 'mean_word_length': 2.6933560477001706, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4722162', 'n_tokens_mistral': 1695, 'n_tokens_neox': 1584, 'n_words': 347}