Catch exception when Templates not available.

This commit is contained in:
Jordan ERNST 2019-02-08 12:40:33 +01:00
parent 07ec96d33a
commit 831097aa75

View File

@ -82,7 +82,7 @@ def initialisation():
if not os.path.exists(templatesdir):
move('Templates', IFPassDBdir)
return IFPassDBdir, printername, AcrobatReader, clientsfile, clientsbkpfile, imgdir, pdftemplate, pngtemplate, fonttemplate
return IFPassDBdir, printername, AcrobatReader, clientsfile, clientsbkpfile, imgdir, templatesdir, pdftemplate, pngtemplate, fonttemplate
def get_fullname():
@ -216,7 +216,15 @@ def bkpdb():
def fillcard(barcode):
print("Création de la carte avec les informations...", end='')
im = Image.open(pngtemplate)
try:
im = Image.open(pngtemplate)
except FileNotFoundError:
os.system('cls')
print(colored('Vous avez besoin de 2 fichiers dans le dossier Templates pour générer des cartes :', 'red'))
print(templatesdir + '\\IFPass_PDF_Template.pdf : Modèle de la carte (recto et verso)')
print(templatesdir + '\\IFPass_PNG_Template.png : La face avant de la carte (celle à remplir)')
os.system("pause")
sys.exit()
draw = ImageDraw.Draw(im)
# Name embedding :
@ -324,10 +332,10 @@ def membersearch():
def main():
global titre, firstname, surname, fullname, dateinsc, dateexp, clientID, clientsfile, IFPassDBdir, clientsfile, imgdir, clientsbkpfile, pngtemplate, fonttemplate, picture, pdftemplate, printername, AcrobatReader
global titre, firstname, surname, fullname, dateinsc, dateexp, clientID, clientsfile, IFPassDBdir, clientsfile, imgdir, clientsbkpfile, templatesdir, pngtemplate, fonttemplate, picture, pdftemplate, printername, AcrobatReader
while "The program is running":
init() # Initialisation of colorama
IFPassDBdir, printername, AcrobatReader, clientsfile, clientsbkpfile, imgdir, pdftemplate, pngtemplate, fonttemplate = initialisation()
IFPassDBdir, printername, AcrobatReader, clientsfile, clientsbkpfile, imgdir, templatesdir, pdftemplate, pngtemplate, fonttemplate = initialisation()
os.system('cls')
f = Figlet(font='big')