Failed to fetch fork details. Try again later.
-
unknown authored6569e47f
Forked from
HYCAR-Hydro / airGR
Source project has a limited visibility.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#!/usr/bin/env python3
# pamhyr.py -- Pamhyr entrypoint
# Copyright (C) 2023 INRAE
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# -*- coding: utf-8 -*-
import sys
import os
import locale
import logging
from PyQt5.QtCore import QTranslator
from PyQt5.QtWidgets import QApplication
from config import Config
from tools import (
reset_timers, display_timers, timer,
logger_color_blue, logger_color_red, logger_color_green, logger_color_reset
)
from View.MainWindow import ApplicationWindow
from Model.Study import Study
from Scripts.P3DST import Script3DST
from Scripts.Hello import ScriptHello
from Scripts.Run import ScriptExport, ScriptRun
from init import legal_info, debug_info, setup_lang
logger = logging.getLogger()
scripts = {
"hello": ScriptHello,
"export": ScriptExport,
"run": ScriptRun,
"3DST": Script3DST,
}
def usage(argv):
logger.info("")
logger.info(f"Usage: {argv[0]} <script> <args...>")
logger.info("")
logger.info("Available scripts:")
logger.info("\thelp\t\tDisplay this message")
logger.info("\tgui\t\tRun Pamhyr graphics user interface (by default)")
logger.info(
"\tdebug\t\tRun Pamhyr graphics user interface " +
"as debug mode (for developers)"
)
for s in scripts:
logger.info(f"\t{s}\t\t{scripts[s].description}")
logger.info("")
def gui(app: QApplication, conf: Config):
application = ApplicationWindow(conf=conf)
application.show()
debug_info()
return app.exec_()
def main():
conf = Config.load()
legal_info()
if len(sys.argv) > 1:
script = sys.argv[1]
else:
script = "gui"
if script == "help":
ret = usage(sys.argv)
elif script == "gui" or script == "debug":
if script == "debug":
conf.debug = True
app = QApplication(sys.argv)
tr = setup_lang(app, conf)
app.installTranslator(tr)
ret = gui(app, conf)
else:
if script not in scripts:
logger.error(
f"{logger_color_red()}Invalid script name " +
f"'{sys.argv[1]}'{logger_color_reset()}"
)
usage(sys.argv)
sys.exit(-1)
# By default script as no QApplication (allow run script
# in tty mode)
app = None
application = scripts[script](app, conf, sys.argv)
ret = application.run()
if ret != 0:
application.usage()
display_timers()
sys.exit(ret)
if __name__ == "__main__":
main()