Changeset 11547 for main/pyfprint/trunk


Ignore:
Timestamp:
27 Mar 2014, 11:17:08 (11 years ago)
Author:
uli
Message:

Ask two times for student id.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/pyfprint/trunk/enroll-script.py

    r11540 r11547  
    2828    return os.path.join(path, name)
    2929
     30
     31def get_stud_id():
     32    """Get a student id via input from keyboard.
     33
     34    We require the id two times (for safety). The id must not be
     35    empty.
     36    """
     37    while True:
     38        stud_id = raw_input("Please ENTER the STUDENT ID: ")
     39        ctrl_id = raw_input("Please repeat              : ")
     40        if not stud_id:
     41            print "Please enter a valid student ID!"
     42            stud_id = None
     43        if stud_id != ctrl_id:
     44            print "IDs do not match. We restart."
     45        if stud_id and stud_id == ctrl_id:
     46            return stud_id
     47
     48
    3049# create results dir if it does not exist already.
    3150if not os.path.exists(RESULTS_DIR):
     
    3352    os.mkdir(RESULTS_DIR)
    3453
    35 print "Hello Issoufou!"
    3654print
    37 print "After pressing a key, the fingerprint scanner GUI will"
    38 print "appear. Then, please do a scan of a finger via the GUI."
     55print "After entering a student ID, the fingerprint scanner GUI will"
     56print "appear. Then, please do a scan ('enroll') of a finger via the GUI."
    3957print
    4058print "After scanning, please close the scanner programme."
     
    4462    shutil.rmtree(PRINTS_DIR)
    4563
    46 stud_id = raw_input("Please ENTER the STUDENT ID: ")
     64stud_id = get_stud_id()
    4765
    4866os.system(CMD)
     
    6280
    6381print "COPYING fingerprint over..."
     82if os.path.isfile(fp_target):
     83    # such a fingerprint exists already (same finger, stud_id)
     84    os.unlink(fp_target)
    6485shutil.copy2(fp_file, fp_target)
    6586
Note: See TracChangeset for help on using the changeset viewer.