Fix various bugs

This commit is contained in:
Jordan ERNST 2019-03-01 15:19:40 +01:00
parent f3f86c43a6
commit a1beec5cd1

View File

@ -15,7 +15,7 @@ from pywinauto.findwindows import find_window
from pywinauto.win32functions import SetForegroundWindow from pywinauto.win32functions import SetForegroundWindow
from PIL import Image, ImageDraw, ImageFont from PIL import Image, ImageDraw, ImageFont
from PyPDF2 import PdfFileReader, PdfFileWriter from PyPDF2 import PdfFileReader, PdfFileWriter
import fitz import fitz # = PyMuPDF : To convert pdf to png
import subprocess import subprocess
from shutil import copyfile, move from shutil import copyfile, move
from pyfiglet import Figlet from pyfiglet import Figlet
@ -117,12 +117,13 @@ def get_fullname(**kwargs): # **kwargs => Optionnal arguments
surname = newsurname surname = newsurname
else: else:
while "Empty surname": while "Empty surname":
surname = input("Nom : ").upper().strip() surname = input("Nom : ").strip()
if len(surname) == 0: if len(surname) == 0:
os.system('cls') os.system('cls')
print(colored("\nLe Nom ne peut pas être vide.", 'red')) print(colored("\nLe Nom ne peut pas être vide.", 'red'))
else: else:
break break
surname = surname.upper()
docteur = yes_or_no('Est-ce un Docteur ?') docteur = yes_or_no('Est-ce un Docteur ?')
if docteur: if docteur:
titre = 'Dr.' titre = 'Dr.'
@ -384,7 +385,7 @@ def membersearch():
break break
except (IndexError, ValueError): except (IndexError, ValueError):
print(colored('Choix invalide ! Veillez bien à sélectionner le numéro de la colonne "Choix"', 'red', attrs=['bold'])) print(colored('Choix invalide ! Veillez bien à sélectionner le numéro de la colonne "Choix"', 'red', attrs=['bold']))
os.system('cls') os.system('cls')
while 'Choix incorect': while 'Choix incorect':
print("Titre : ", colored(member[0], 'green')) print("Titre : ", colored(member[0], 'green'))
@ -438,7 +439,8 @@ def memberdo(choix, member):
picture = getpic() picture = getpic()
else: else:
# We crop pic from the previous card # We crop pic from the previous card
pdf = fitz.open('PDF.pdf') cartefilename = os.path.join(imgdir, clientID + '.pdf')
pdf = fitz.open(cartefilename)
page = pdf.loadPage(0) page = pdf.loadPage(0)
mat = fitz.Matrix(4.165, 4.165) # To obtain good resolution mat = fitz.Matrix(4.165, 4.165) # To obtain good resolution
pix = page.getPixmap(matrix=mat) pix = page.getPixmap(matrix=mat)
@ -448,7 +450,7 @@ def memberdo(choix, member):
barcode = barcode_gen(clientID) barcode = barcode_gen(clientID)
fillcard(clientID, titrename, firstname, dateexp, barcode, picture) fillcard(clientID, titrename, firstname, dateexp, barcode, picture)
cartefilename = mergepdf() cartefilename = mergepdf(clientID)
if version not in ('dev', 'devnocam'): if version not in ('dev', 'devnocam'):
bkpdb() bkpdb()
printcard(cartefilename) printcard(cartefilename)