mirror of https://gitlab.com/pamhyr/pamhyr2
pamhyr: Fix execution without argument.
parent
b35be16268
commit
d0ea629c10
|
|
@ -72,39 +72,37 @@ def main():
|
|||
legal_info()
|
||||
|
||||
if len(sys.argv) > 1:
|
||||
# Run a script
|
||||
script = sys.argv[1]
|
||||
|
||||
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()
|
||||
else:
|
||||
# No args, run Pamhyr2 interface
|
||||
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)
|
||||
|
|
|
|||
Loading…
Reference in New Issue