main.py 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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 core import logging_
  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. logger = logging.getLogger("hello")
  21. logging_.start("hello", level=10)
  22. with open("VERSION") as f:
  23. __VERSION__ = f.read()
  24. try:
  25. updater.autoupdate()
  26. except UpdateNeeded:
  27. print("Veuillez patienter pendant la mise à jour automatique")
  28. sys.exit(0)
  29. # Configure how errors are processed
  30. sys_err = sys.excepthook
  31. def gestionnaire_erreurs(typ, value, trace):
  32. QApplication.restoreOverrideCursor()
  33. logger.error("{}\n{}\n{}".format(typ.__name__, value, ''.join(traceback.format_tb(trace))))
  34. QMessageBox.critical(mainw, "Erreur: {}".format(typ.__name__), """{}""".format(value))
  35. sys_err(typ, value, trace)
  36. sys.excepthook = gestionnaire_erreurs
  37. # Start UI
  38. app = QApplication(sys.argv)
  39. mainw = MainWindow()
  40. mainw.show()
  41. r = app.exec_()