""" Pardit - Production automatisée de réponse aux demandes d'intention de travaux Pour traiter automatiquement un fichier XML, utilisez l'argument optionnel '-file='. ex: pardit.py -file c:\...\fichier.xml @author: olivier.massot, 2017 """ import re import sys from PyQt5.Qt import QApplication from PyQt5.QtWidgets import QMessageBox from core import constants, config from ui.window import MainWindow import updater try: import ipdb # @UnusedImport Necessaire à l'affichage des stack traces except: pass # Look for a -file= argument args = sys.argv regex = re.compile(r"""^-file="?(.*)"?$""") filename = "" for arg in args: match = regex.match(arg) if match != None: filename = match.group(1) app = QApplication(sys.argv) mainw = MainWindow() sys_err = sys.excepthook def gestionnaire_erreurs(typ, value, traceback): QApplication.restoreOverrideCursor() sys_err(typ, value, traceback) QMessageBox.critical(mainw, "Erreur: {}".format(typ.__name__), """{}""".format(value)) mainw.cancel() sys.excepthook = gestionnaire_erreurs try: if updater.update_needed(): QMessageBox.information(mainw, "Mise à jour requise", """Une nouvelle version de Pardit est disponible, veuillez patienter pendant la mise à jour. Pardit sera relancé automatiqement une fois l'installation terminée.""", QMessageBox.Ok) updater.update() sys.exit(0) except updater.Unavailable: print("Request error: unable to fetch last version") # Charge la configuration config.load() mainw.show() if filename: mainw.process(filename) r = app.exec_() # Nettoyage constants.TMPDIR.rmdir_p()