Пример #1
0
def change_session(change, list):
    session = change.session
    for ident in list:
        if ident.ip == change.ip and ident.user != change.user:
            # If the entries have the same IP address, and differs in user
            hex_dig = Identification.get_hash(change)
            identifications.remove(change)
            change.session = hex_dig
            identifications.remove(ident)
            identifications.append(change)
        elif ident.ip == change.ip and (compare_timestamp(ident.timestamp, change.timestamp) > session_time):
            # If the entries have the same IP address, and timestamp difference are "big" enough
            hex_dig = Identification.get_hash(change)
            identifications.remove(change)
            change.session = hex_dig
            identifications.remove(ident)
            identifications.append(change)
        elif ident.ip == change.ip and not ident == change:
            # If the entries have the same IP address, and they're not the same object
            session = ident.session
            identifications.remove(change)
            change.session = session
            identifications.remove(ident)
            identifications.append(change)
        elif compare_timestamp(last_timestamp, ident.timestamp) > session_time:
            # If IP has been out for a long time
            identifications.remove(ident)
    return session
Пример #2
0
 def __init__(self, rfid):
     '''
     Constructor
     @param self: The RFID object instance.
     @param rfid: The RFID identification string (Obligatory).
     '''
     Identification.__init__(self, rfid)
 def load (self, cpf):
     '''
     Get a Person from the database based on its cpf.
     @param self: The Person DAO object instance.
     @param cpf: The cpf.
     @return: The Person object instance or None if no Person with this CPF is found.
     '''
     if cpf in self.__db:
         person_data = self.__db[cpf]
         person_obj = Person (person_data[_NAME_KEY], person_data.id)
         [person_obj.addAllowedRoom(room) for room in person_data[_ALLOWED_ROOMS_KEY]]
         
         for id_data in person_data[_IDENTIFICATIONS_KEY]:
             id_obj = Identification.fromDict(id_data)
             person_obj.addID(id_obj)
             
         return person_obj
     
     return None