From 5db82558437fe3fb416c4192e2581f4e42ffbcfb Mon Sep 17 00:00:00 2001 From: Jordan ERNST Date: Fri, 8 Feb 2019 11:36:48 +0100 Subject: [PATCH] Moved conf in ProgramData and auto-detection Acrobat Reader. --- IFPass.py | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/IFPass.py b/IFPass.py index e858c20..9ddc9f4 100644 --- a/IFPass.py +++ b/IFPass.py @@ -24,7 +24,8 @@ from termcolor import colored version = 'dev' # dev/devnocam -config = 'IFPass.conf' +configdir = os.path.join(os.getenv('PROGRAMDATA'), 'IFPass') +config = os.path.join(configdir, 'IFPass.conf') def initialisation(): @@ -35,8 +36,22 @@ def initialisation(): print('Fichier de configuration introuvable.') IFPassDBdir = input(r'Quel est le répertoire de la base de données IFPass ? (Ex : \\192.168.1.1\IFPass) : ') printername = input("Quel est le nom de l'imprimante à cartes ? : ") - AcrobatReader = input(r"Quel est le chemain vers Acrobat Reader ? ( Ex : C:\Program Files (x86)\Adobe\Acrobat Reader DC\Reader\AcroRd32.exe) : ") + adobex86 = os.path.join(os.getenv('PROGRAMFILES(x86)'), 'Adobe', "Acrobat Reader DC", "Reader", "AcroRd32.exe") + adobex64 = os.path.join(os.getenv('PROGRAMFILES'), 'Adobe', "Acrobat Reader DC", "Reader", "AcroRd32.exe") + if os.path.exists(adobex86): + AcrobatReader = adobex86 + elif os.path.exists(adobex64): + AcrobatReader = adobex64 + else: + acrinstalled = yes_or_no("Acrobat Reader est nécessaire pour imprimer les cartes. Est il installé ?") + if acrinstalled: + AcrobatReader = input(r"Quel est le chemin vers Acrobat Reader ? ( Ex : C:\Program Files (x86)\Adobe\Acrobat Reader DC\Reader\AcroRd32.exe) : ") + else: + print(colored('\nInstallez Acrobat Reader, puis relancez IFPass.', 'red')) + os.system("pause") + sys.exit() conf['DEFAULT'] = {'IFPassDBdir': IFPassDBdir, 'printername': printername, 'AcrobatReader': AcrobatReader} + os.makedirs(configdir, 0o777) with open(config, 'w') as configfile: conf.write(configfile) else: @@ -54,7 +69,7 @@ def initialisation(): fonttemplate = os.path.join(templatesdir, 'Templates', 'Roboto-Bold.ttf') if not os.path.exists(imgdir): # Cartes dir creation if it doesn't exist - os.makedirs(imgdir) + os.makedirs(imgdir, 0o777) if not os.path.exists(clientsfile): # Creation Clients_File if it doesn't exist with open(clientsfile, 'w', newline='', encoding='utf-8') as csvfile: writer = csv.writer(csvfile, delimiter=';')