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

pamhyr: Allow Pamhyr2 script run on tty mode.

Showing with 15 additions and 9 deletions
+15 -9
...@@ -68,10 +68,6 @@ def gui(app:QApplication, conf:Config): ...@@ -68,10 +68,6 @@ def gui(app:QApplication, conf:Config):
def main(): def main():
conf = Config.load() conf = Config.load()
app = QApplication(sys.argv)
tr = setup_lang(app, conf)
app.installTranslator(tr)
legal_info() legal_info()
...@@ -81,17 +77,27 @@ def main(): ...@@ -81,17 +77,27 @@ def main():
if script == "help": if script == "help":
ret = usage(sys.argv) ret = usage(sys.argv)
elif script == "gui": elif script == "gui" or script == "debug":
ret = gui(app, conf) if script == "debug":
elif script == "debug": conf.debug = True
conf.debug = True
app = QApplication(sys.argv)
tr = setup_lang(app, conf)
app.installTranslator(tr)
ret = gui(app, conf) ret = gui(app, conf)
else: else:
if script not in scripts: if script not in scripts:
logger.error(f"{logger_color_red()}Invalid script name '{sys.argv[1]}'{logger_color_reset()}") logger.error(
f"{logger_color_red()}Invalid script name " +
f"'{sys.argv[1]}'{logger_color_reset()}"
)
usage(sys.argv) usage(sys.argv)
sys.exit(-1) sys.exit(-1)
# By default script as no QApplication (allow run script
# in tty mode)
app = None
application = scripts[script](app, conf, sys.argv) application = scripts[script](app, conf, sys.argv)
ret = application.run() ret = application.run()
if ret != 0: if ret != 0:
......
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