From bff7ac2e1266a74d14234b7288fa2024edd93381 Mon Sep 17 00:00:00 2001 From: Thomas E Lackey Date: Wed, 21 Feb 2024 18:43:16 -0600 Subject: [PATCH 1/2] Even more logging fixes --- stack_orchestrator/deploy/webapp/util.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/stack_orchestrator/deploy/webapp/util.py b/stack_orchestrator/deploy/webapp/util.py index 6cfdb118..e1b3c968 100644 --- a/stack_orchestrator/deploy/webapp/util.py +++ b/stack_orchestrator/deploy/webapp/util.py @@ -41,12 +41,16 @@ class AttrDict(dict): def logged_cmd(log_file, *vargs): try: - print(" ".join(vargs), file=log_file) - result = subprocess.run(vargs, capture_output=True, stdout=log_file, stderr=log_file) + if log_file: + print(" ".join(vargs), file=log_file) + result = subprocess.run(vargs, capture_output=True) result.check_returncode() return result.stdout.decode() except Exception as err: - print(str(err), file=log_file) + if result: + print(result.stderr.decode(), file=log_file) + else: + print(str(err), file=log_file) raise err @@ -184,7 +188,7 @@ class LaconicRegistryClient: self.set_name(name, new_record_id) return new_record_id finally: - logged_cmd("rm", "-rf", tmpdir) + logged_cmd(self.log_file, "rm", "-rf", tmpdir) def set_name(self, name, record_id): logged_cmd(self.log_file, "laconic", "-c", self.config_file, "cns", "name", "set", name, record_id) -- 2.45.2 From 70bd480fb4445f3e3f9494a82b1a3b434d52fde5 Mon Sep 17 00:00:00 2001 From: Thomas E Lackey Date: Wed, 21 Feb 2024 18:53:11 -0600 Subject: [PATCH 2/2] define at top --- stack_orchestrator/deploy/webapp/util.py | 1 + 1 file changed, 1 insertion(+) diff --git a/stack_orchestrator/deploy/webapp/util.py b/stack_orchestrator/deploy/webapp/util.py index e1b3c968..959d5d31 100644 --- a/stack_orchestrator/deploy/webapp/util.py +++ b/stack_orchestrator/deploy/webapp/util.py @@ -40,6 +40,7 @@ class AttrDict(dict): def logged_cmd(log_file, *vargs): + result = None try: if log_file: print(" ".join(vargs), file=log_file) -- 2.45.2