main.py 1.1 KB

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