main.py 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. """
  2. [App documentation here]
  3. @author:[author], [year]
  4. """
  5. import logging
  6. import sys
  7. import traceback
  8. from PyQt5.Qt import QApplication
  9. from PyQt5.QtWidgets import QMessageBox
  10. from log0 import logger
  11. from ui.window import MainWindow
  12. from updater import UpdateNeeded
  13. import updater
  14. try:
  15. # Necessary to ensure that stacktraces are printed when using PyQt5
  16. # Tough, could make pythonw.exe crash
  17. import ipdb # @UnusedImport
  18. except:
  19. pass
  20. with open("VERSION") as f:
  21. __VERSION__ = f.read()
  22. try:
  23. updater.autoupdate()
  24. except UpdateNeeded:
  25. print("Veuillez patienter pendant la mise à jour automatique")
  26. sys.exit(0)
  27. # Configure how errors are processed
  28. sys_err = sys.excepthook
  29. def gestionnaire_erreurs(typ, value, trace):
  30. QApplication.restoreOverrideCursor()
  31. logger.error("{}\n{}\n{}".format(typ.__name__, value, ''.join(traceback.format_tb(trace))))
  32. QMessageBox.critical(mainw, "Erreur: {}".format(typ.__name__), """{}""".format(value))
  33. sys_err(typ, value, trace)
  34. sys.excepthook = gestionnaire_erreurs
  35. # Start UI
  36. app = QApplication(sys.argv)
  37. mainw = MainWindow()
  38. mainw.show()
  39. r = app.exec_()