Exemplo n.º 1
0
import config
from dokos_connector import DokosConnector
from authentication import Authentication
import json

connector = DokosConnector(config.api_url, config.dokos_client,
                           config.dokos_token)
print("Connection reussi")

auth = Authentication("a3:a0:bb:3b")

print(auth.get_user_and_customer_for_rfid())
auth.add_passage_to_log()
Exemplo n.º 2
0
            exit()
    AuthError = ""
    StateOfCardReader = 0
    Window.fill(gray)
    Window.blit(tuxImage, [10, 10])
    pygame.display.flip()
    textShell = os.popen(cmd).read().strip()
    #Read the card
    if (textShell.startswith("UID")):
        UIDWithSpace = textShell.split(":")[1]
        UIDWithoutSpace = UIDWithSpace.replace("  ", ":").strip()
        print(UIDWithoutSpace)
        StateOfCardReader = 1
        try:
            auth = Authentication(rfid=UIDWithoutSpace)
            user, customer = auth.get_user_and_customer_for_rfid()
            auth.add_passage_to_log()
        except authentication.RfidNotFound:
            StateOfCardReader = 2
        except:
            AuthError = "Attention le serveur est innacesible sauvegarde des passages en local"
            StateOfCardReader = 1
            SendOldLog = True
            MomentOfNonSent = time.time()
            writeToFile(UIDWithoutSpace)

    # Send the oldlog if the Dokos Server had problem
    if SendOldLog and (time.time() - MomentOfNonSent > 300):
        Window.fill(gray)
        Window.blit(DLImage, [10, 10])
        pygame.display.flip()