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

SPF-OST / pytrnsys_gui / 11576810878

29 Oct 2024 03:09PM UTC coverage: 67.508% (-0.08%) from 67.591%
11576810878

push

github

web-flow
Merge pull request #564 from SPF-OST/560-black-change-line-length-to-pep8-standard-of-79-and-check-ci-reaction

changed line length in black to 79

1054 of 1475 new or added lines in 174 files covered. (71.46%)

150 existing lines in 74 files now uncovered.

10399 of 15404 relevant lines covered (67.51%)

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()
×
NEW
18
    logger = _ulog.getOrCreateCustomLogger(
×
19
        "root", arguments.logLevel, logFilePath
20
    )
21

22
    _registerExceptionHook(logger)
×
23

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

29
    app = _qtw.QApplication(_sys.argv)
×
30
    app.setApplicationName("Diagram Creator")
×
31

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

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

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

44
    import trnsysGUI.mainWindow as _mw  # pylint: disable=import-outside-toplevel
×
45

46
    mainWindow = _mw.MainWindow(logger, project)
×
47
    mainWindow.start()
×
48

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

53
    app.aboutToQuit.connect(_shutdownMainWindowIfRunning)
×
54

55
    try:
×
56
        mainWindow.showMaximized()
×
57
        mainWindow.ensureSettingsExist()
×
58
        mainWindow.loadTrnsysPath()
×
59

60
        import trnsysGUI.tracing as trc  # pylint: disable=import-outside-toplevel
×
61

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

67

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

71

72
def _registerExceptionHook(logger: _log.Logger) -> None:
×
73
    def exceptionHook(exceptionType, value, traceback):
×
NEW
74
        logger.critical(
×
75
            "Uncaught exception", exc_info=(exceptionType, value, traceback)
76
        )
77

78
        for handler in logger.handlers:
×
79
            handler.flush()
×
80

81
        _sys.exit(-1)
×
82

83
    _sys.excepthook = exceptionHook
×
84

85

86
if __name__ == "__main__":
×
87
    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