From 7b23fe7b94f34d45081dbb6c1c6d229e4c75f9b9 Mon Sep 17 00:00:00 2001 From: Jordan ERNST Date: Tue, 17 Apr 2018 14:31:11 +0200 Subject: [PATCH] .gitignore updated, little fixes --- .gitignore | 3 +++ Clients_IFPass.csv | 2 ++ IFPass.py | 38 ++++++++------------------------------ 3 files changed, 13 insertions(+), 30 deletions(-) diff --git a/.gitignore b/.gitignore index 702ebda..b8df4aa 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,4 @@ .ropeproject +Cartes +Clients_IFPass.csv +Clients_IFPass_backup.csv diff --git a/Clients_IFPass.csv b/Clients_IFPass.csv index a0c24fe..6720d28 100644 --- a/Clients_IFPass.csv +++ b/Clients_IFPass.csv @@ -1 +1,3 @@ Titre;Prénom;Nom;Numéro de client;Date d'inscripton;Date d'expiration +;Fdshg;SDFHG;0000000001;16/04/2018;16/04/2019 +;Vcxwb;FHD;0000000002;16/04/2018;16/04/2019 diff --git a/IFPass.py b/IFPass.py index d39a16f..f164412 100644 --- a/IFPass.py +++ b/IFPass.py @@ -2,14 +2,10 @@ # Written by Jordan ERNST Q1 2018. # Contact : pro.ernst@gmail.com -# v1.0 : 23/03/2018 - -# https://www.pyimagesearch.com/2015/12/21/increasing-webcam-fps-with-python-and-opencv/ import sys import os import re -from contextlib import contextmanager # To hide output from datetime import date, timedelta import csv import code128 @@ -25,11 +21,11 @@ from colorama import init from termcolor import colored -version = '1.0' +version = 'dev' -computer = '' # 'test', 'mediatheque' or 'accueil' +computer = '' # 'mediatheque' or 'accueil' -if computer == 'test': +if version == 'dev': IFPassdir = '\\\\192.168.1.1\SSIC\\04-Projets\IFPass\\' elif computer == 'mediatheque': IFPassdir = '\\\\192.168.1.1\IFPass\\' @@ -42,31 +38,13 @@ else: sys.exit() clientsfile = IFPassdir + 'Clients_IFPass.csv' -clientsbkpfile = IFPassdir + 'Clients_IFPass_bakup.csv' +clientsbkpfile = IFPassdir + 'Clients_IFPass_backup.csv' imgdir = IFPassdir + 'Cartes\\' pdftemplate = IFPassdir + 'Templates\IFPass_PDF_Template.pdf' pngtemplate = IFPassdir + 'Templates\IFPass_PNG_Template.png' fonttemplate = IFPassdir + 'Templates\Roboto-Bold.ttf' -@contextmanager -def HideOutput(to=os.devnull): - fd = sys.stdout.fileno() - - def _redirect_stdout(to): - sys.stdout.close() # + implicit flush() - os.dup2(to.fileno(), fd) # fd writes to 'to' file - sys.stdout = os.fdopen(fd, 'w') # Python writes to fd - - with os.fdopen(os.dup(fd), 'w') as old_stdout: - with open(to, 'w') as file: - _redirect_stdout(to=file) - try: - yield # allow code to be run with the redirected stdout - finally: - _redirect_stdout(to=old_stdout) # restore stdout. # cv2.selectROI - - def get_fullname(): firstname = input("Prénom : ").strip() firstname = firstname[0].upper() + firstname[1:].lower() @@ -127,12 +105,11 @@ def getpic(): try: ret, frame = cap.read() cv2.rectangle(frame, (170, 73), (470, 407), (0, 255, 0), 2) - cv2.imshow('IFCamera - Touche Espace pour prendre la photo, Echap pour une carte sans photo, Q pour quitter.', - frame) + cv2.imshow('IFCamera - Touche Espace pour prendre la photo, Echap pour une carte sans photo, Q pour quitter.', frame) except cv2.error: - print('\nLa webcam est débranchée. Branchez-la, puis relancez le programme.') + print(colored('\nLa webcam est débranchée. Branchez-la, puis relancez le programme.', 'red')) os.system("pause") - sys.exit(0) + sys.exit() SetForegroundWindow(find_window(title='IFCamera - Touche Espace ' 'pour prendre la photo, Echap pour une carte sans photo, Q pour quitter.')) k = cv2.waitKey(1) @@ -281,3 +258,4 @@ while "the informations are incorrect": # Loop Filling informations bkpdb() if computer == 'mediatheque' or computer == 'accueil': printcard(cartefilename) + sys.exit()