From b81bcb2c9fd8b5a81afe26109d156092859dcd67 Mon Sep 17 00:00:00 2001 From: DJ2LS Date: Fri, 27 Oct 2023 14:25:11 +0200 Subject: [PATCH] attempt with subprocess.run --- modem/daemon.py | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/modem/daemon.py b/modem/daemon.py index f8cc3889..033edf81 100755 --- a/modem/daemon.py +++ b/modem/daemon.py @@ -87,16 +87,30 @@ class DAEMON: """ while True: - threading.Event().wait(0.3) + threading.Event().wait(0.01) + try: + print(Daemon.rigctldprocess) + result = Daemon.rigctldprocess + print(f'Standard Output: {result.stdout}') + print(f'Standard Error: {result.stderr}') + except Exception: + pass + + # only continue, if we have a process object initialized if hasattr(Daemon.rigctldprocess, "returncode"): if Daemon.rigctldprocess.returncode in [None, "None"] or not Daemon.rigctldstarted: Daemon.rigctldstarted = True - outs, errs = Daemon.rigctldprocess.communicate(timeout=30) - print(f"outs: {outs}") - print(f"errs: {errs}") - #print(Daemon.rigctldprocess.stderr.read()) + #outs, errs = Daemon.rigctldprocess.communicate(timeout=10) + #print(f"outs: {outs}") + #print(f"errs: {errs}") + print(Daemon.rigctldprocess) + result = Daemon.rigctldprocess + print(f'Standard Output: {result.stdout}') + print(f'Standard Error: {result.stderr}') + + else: self.log.warning("[DMN] [RIGCTLD] [Watchdog] returncode detected",process=Daemon.rigctldprocess) Daemon.rigctldstarted = False @@ -105,8 +119,8 @@ class DAEMON: # erase process object Daemon.rigctldprocess = None else: - Daemon.rigctldstarted = False - + #Daemon.rigctldstarted = False + pass #try: # outs, errs = proc.communicate(timeout=15) #except TimeoutExpired: @@ -411,7 +425,11 @@ class DAEMON: self.log.info("[DMN] starting rigctld: ", param=command) if not isWin: - proc = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + #proc = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) + #proc = subprocess.Popen(command) + proc = subprocess.run(command, shell=False, check=True, text=True, capture_output=True) + print(f'Standard Output: {proc.stdout}') + print(f'Standard Error: {proc.stderr}') else: #On windows, open rigctld in new window for easier troubleshooting proc = subprocess.Popen(command, creationflags=subprocess.CREATE_NEW_CONSOLE,close_fds=True)