CLI: prevent LOCAL:// runtime to use GUI (tray icon) when launch from CLI.
authorEdouard Tisserant <edouard.tisserant@gmail.com>
Fri, 15 Jul 2022 14:38:33 +0200
changeset 3539 c2eec6aae07e
parent 3538 d6c9da8d594e
child 3540 75a83cc07f27
CLI: prevent LOCAL:// runtime to use GUI (tray icon) when launch from CLI.
CLIController.py
LocalRuntimeMixin.py
--- a/CLIController.py	Mon Jul 11 23:18:14 2022 +0200
+++ b/CLIController.py	Fri Jul 15 14:38:33 2022 +0200
@@ -71,7 +71,7 @@
     def __init__(self, session):
         self.session = session
         log = Log()
-        LocalRuntimeMixin.__init__(self, log)
+        LocalRuntimeMixin.__init__(self, log, use_gui=False)
         ProjectController.__init__(self, None, log)
 
     def check_and_load_project(self):
--- a/LocalRuntimeMixin.py	Mon Jul 11 23:18:14 2022 +0200
+++ b/LocalRuntimeMixin.py	Fri Jul 15 14:38:33 2022 +0200
@@ -9,13 +9,14 @@
 
 class LocalRuntimeMixin():
 
-    def __init__(self, log):
+    def __init__(self, log, use_gui=True):
         self.local_runtime_log = log
         self.local_runtime = None
         self.runtime_port = None
         self.local_runtime_tmpdir = None
+        self.use_gui = use_gui
 
-    def StartLocalRuntime(self, taskbaricon=True):
+    def StartLocalRuntime(self):
         if (self.local_runtime is None) or (self.local_runtime.exitcode is not None):
             # create temporary directory for runtime working directory
             self.local_runtime_tmpdir = tempfile.mkdtemp()
@@ -29,7 +30,7 @@
                     sys.executable,
                     Bpath("Beremiz_service.py"),
                     self.runtime_port,
-                    {False: "-x 0", True: "-x 1"}[taskbaricon],
+                    {False: "-x 0", True: "-x 1"}[self.use_gui],
                     self.local_runtime_tmpdir),
                 no_gui=False,
                 timeout=500, keyword=self.local_runtime_tmpdir,