def save(self):

        if not self.fingers_to_save:
            dlgAviso(self.ventana,
                     'Obten la huella antes de guardar un nuevo cliente.')
            return

        if not self.validar_formulario():
            return

        guardar_en_cache = False
        Session = orm.sessionmaker(self.padre.cnx)
        registrar_visita = True
        if not self.session or not self.cliente:
            self.session = Session()
            self.cliente = Clientes()
            registrar_visita = False
#            self.on_btnObtener_clicked(widget, {'save': True})
        try:
            if not registrar_visita:
                self.guardar_cliente()

                cache = sys.cache
                objeto = dict(id=self.cliente.id,
                              fingers=self.cliente.huella_digital)
                self.finger_cache.append(objeto)
                guardar_en_cache = True

            self.registrar_visita()

            if permisos.verifica_permiso(self.usuario,
                                         permisos.ASING_BENEFICIOS):
                #si tiene permiso para asignar beneficios
                beneficio_id = self.pecBeneficio.get_cod()

                if beneficio_id:
                    if self.cliente.beneficios_id != int(beneficio_id):
                        #Si es distinto al que ya poseia
                        self.asignar_beneficio(int(beneficio_id))

            self.session.commit()

            if guardar_en_cache:
                if cache.get('fingers'):
                    cache.replace('fingers', self.finger_cache)
                else:
                    cache.set('fingers', self.finger_cache)
                self.fingers_list.append(dict(id = objeto['id'], fingers \
                            = pyfprint.Fprint(serial_data = objeto['fingers']))
                            )

            dlgAviso(self.ventana, "El usuario se ha registrado")
            self.limpiar_formulario()
        except:
            self.session.rollback()
            dlgError(self.ventana, "Ocurrio un error al agregar al usuario")

        self.session.close()
Exemplo n.º 2
0
def verify_identity(huella):
    pyfprint.init()
    fp_reader = pyfprint.discover_devices()[0]
    finger = pyfprint.Fprint(huella)
    print('Deslice su dedo por el lector para verificar su identidad')
    fp_reader.open()
    is_verified = fp_reader.verify_finger(finger)[0]
    fp_reader.close()
    pyfprint.exit()
    return is_verified
Exemplo n.º 3
0
 def __enroll(self):
     finger_print = pyfprint.Fprint(
         data_ptr=pyf.fp_print_data_from_data(self.__finger_print))
     result = self.__dev.verify_finger(finger_print)
     if result[0]:
         self.close(None)
         self.__parent.record_attendance()
     elif not result[0]:
         gobject.idle_add(
             self.__update_label,
             _("The fingerprint does not match the user entered, try again")
         )
     else:
         gobject.idle_add(self.__update_label,
                          _("Failed to register fingerprint, try again"))
    def get_data(self):
        self.session = None
        self.cliente = None
        cache = sys.cache
        self.finger_cache = cache.get('fingers')
        if self.finger_cache is None:
            self.finger_cache = []
            Session = orm.sessionmaker(self.padre.cnx)
            self.data = Session()
            clientes = self.data.query(Clientes).all()
            for c in clientes:
                self.finger_cache.append(
                    dict(id=c.id, fingers=c.huella_digital))

            cache.set('fingers', self.finger_cache)

        self.fingers_list = []
        for finger in self.finger_cache:
            self.fingers_list.append(dict(id = finger['id'], fingers \
                            = pyfprint.Fprint(serial_data = finger['fingers'])))

        return self.fingers_list
Exemplo n.º 5
0
# -*- coding: utf-8 -*-

import pyfprint
import os.path
DIR = "/tmp/fps"

pyfprint.fp_init()
devs = pyfprint.discover_devices()
dev = devs[0]
dev.open()

names = []
fps = []

for name in os.listdir(DIR):
    fps.append(pyfprint.Fprint(open(DIR + "/" + name, 'br').read()))
    names.append(name)

print("ready to match fingers!")

while True:

    fp, img = dev.enroll_finger()
    i = pyfprint.identify(fp, fps)

    if i is None:
        print("no match found")

    else:
        print("identified " + names[i] + "!")
Exemplo n.º 6
0
def authenticate():
    pyfprint.fp_init()  # Initialize the fingerprint library
    devs = pyfprint.discover_devices()
    dev = devs[0]  # Select the first device detected
    dev.open()

    # Connect to the database database
    fdb = sqlite3.connect(DB_FILE)
    users = []
    gallery = []

    print(
        "To gain access, we have to verify you are authorized using the biometric system\n"
    )

    with fdb:
        cur = fdb.cursor()

        # Check that the table is already created. if not, it means no enrolment has been made so far
        # The function will return immediately
        cur.execute(
            "SELECT name FROM sqlite_master WHERE type='table' AND name='biometric'"
        )
        if not cur.fetchone():
            print("No data in database yet. Please enroll first")
            return

        # Query the database for all entries, storing them in a vector list (users and gallery)
        cur.execute("SELECT username, finger_p FROM biometric")
        for row in cur.fetchall():
            fp_str = row[1].decode(
                'utf8', 'surrogateescape')  # Decode binary data from db
            data = pyfprint.pyf.fp_print_data_from_data(fp_str)
            gallery.append(pyfprint.Fprint(data_ptr=data))
            users.append(row[0])

        # After querying the database, proceed to ask for users finger swipe
        print(
            "To proceed, please swipe your RIGHT INDEX finger on the sensor...\n"
        )

        # Verification is done here
        # Checks to see if the users fingerprint match any of those retrieved from database
        n, fprint, img = dev.identify_finger(gallery)
        print("Authenticating...")

    if fprint:
        print("Authenticated! {0}".format(users[n]))  # User is authenticated
        result = True
    else:
        print("Authentication Failed")  # User not authenticated
        result = False

    # verified, img = dev.verify_finger(fprint)
    # if verified:
    #     print("Welcome, {0}".format(username))
    # else:
    #     print("Sorry! You are not allowed here!")

    # if img is not None:
    dev.close()
    pyfprint.fp_exit()
    return result
Exemplo n.º 7
0
 def _loadPrint(self):
     """Load serialized print data.
     Returns a tuple containing the unserialized data and image."""
     (data, img) = self._comarCall('loadFPData', 'modifyfingerprintdata', (self.__uid))
     return (pyfprint.Fprint(b64dec(data)), self.toPixmap(b64dec(img)))
Exemplo n.º 8
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from __future__ import print_function
import pyfprint

pyfprint.fp_init()
devs = pyfprint.discover_devices()
dev = devs[0]
dev.open()
print("enroll, finger please")
fp, _ = dev.enroll_finger()

print("getting data")
b = fp.data()

print("got data buffer:")
print(b)

print("fp copied")
fp2 = pyfprint.Fprint(b)

print("verify original, finger please")
print(dev.verify_finger(fp))

print("verifying copy, finger please")
print(dev.verify_finger(fp2))

dev.close()
pyfprint.fp_exit()