Commit d0ea629c authored by Pierre-Antoine Rouby's avatar Pierre-Antoine Rouby
Browse files

pamhyr: Fix execution without argument.

Showing with 28 additions and 30 deletions
+28 -30
...@@ -72,39 +72,37 @@ def main(): ...@@ -72,39 +72,37 @@ def main():
legal_info() legal_info()
if len(sys.argv) > 1: if len(sys.argv) > 1:
# Run a script
script = sys.argv[1] 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: 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) 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() display_timers()
sys.exit(ret) sys.exit(ret)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment