• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

SPF-OST / pytrnsys_gui / 11502254537

24 Oct 2024 03:13PM UTC coverage: 67.591%. Remained the same
11502254537

push

github

ahobeost
Merge branch 'master' of https://github.com/SPF-OST/pytrnsys_gui

10413 of 15406 relevant lines covered (67.59%)

0.68 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/trnsysGUI/gui.py
1
import logging as _log
×
2
import pathlib as _pl
×
3
import sys as _sys
×
4

5
import PyQt5.QtWidgets as _qtw
×
6

7
import pytrnsys.utils.log as _ulog
×
8
import pytrnsys.utils.result as _res
×
9
import trnsysGUI.arguments as _args
×
10
import trnsysGUI.setup as _setup
×
11
import trnsysGUI.warningsAndErrors as _werrors
×
12

13

14
def main():
×
15
    arguments = _args.getArgsOrExit()
×
16

17
    logFilePath = _getLogFilePath()
×
18
    logger = _ulog.getOrCreateCustomLogger("root", arguments.logLevel, logFilePath)
×
19

20
    _registerExceptionHook(logger)
×
21

22
    result = _setup.setup()
×
23
    errorMessage = _res.error(result).message if _res.isError(result) else None
×
24
    if errorMessage:
×
25
        logger.error(errorMessage)
×
26

27
    app = _qtw.QApplication(_sys.argv)
×
28
    app.setApplicationName("Diagram Creator")
×
29

30
    if errorMessage:
×
31
        _werrors.showMessageBox(errorMessage, title="Missing requirements")
×
32
        return
×
33

34
    import trnsysGUI.common.cancelled as _ccl  # pylint: disable=import-outside-toplevel
×
35
    import trnsysGUI.project as _prj  # pylint: disable=import-outside-toplevel
×
36

37
    maybeCancelled = _prj.getProject()
×
38
    if _ccl.isCancelled(maybeCancelled):
×
39
        return
×
40
    project = _ccl.value(maybeCancelled)
×
41

42
    import trnsysGUI.mainWindow as _mw  # pylint: disable=import-outside-toplevel
×
43

44
    mainWindow = _mw.MainWindow(logger, project)
×
45
    mainWindow.start()
×
46

47
    def _shutdownMainWindowIfRunning() -> None:
×
48
        if mainWindow.isRunning():
×
49
            mainWindow.shutdown()
×
50

51
    app.aboutToQuit.connect(_shutdownMainWindowIfRunning)
×
52

53
    try:
×
54
        mainWindow.showMaximized()
×
55
        mainWindow.ensureSettingsExist()
×
56
        mainWindow.loadTrnsysPath()
×
57

58
        import trnsysGUI.tracing as trc  # pylint: disable=import-outside-toplevel
×
59

60
        tracer = trc.createTracer(arguments.shallTrace)
×
61
        tracer.run(app.exec)
×
62
    finally:
63
        _shutdownMainWindowIfRunning()
×
64

65

66
def _getLogFilePath():
×
67
    return _pl.Path("pytrnsys-gui.log").absolute()
×
68

69

70
def _registerExceptionHook(logger: _log.Logger) -> None:
×
71
    def exceptionHook(exceptionType, value, traceback):
×
72
        logger.critical("Uncaught exception", exc_info=(exceptionType, value, traceback))
×
73

74
        for handler in logger.handlers:
×
75
            handler.flush()
×
76

77
        _sys.exit(-1)
×
78

79
    _sys.excepthook = exceptionHook
×
80

81

82
if __name__ == "__main__":
×
83
    main()
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc