changeset 3739:0a87cae85746

tools (utils): fix `getRepositoryData` crash: - use `hg_path` to be sure to use the right executable - better exception handling
author Goffi <goffi@goffi.org>
date Tue, 22 Mar 2022 17:00:42 +0100
parents ffa8c8c78115
children ea6fda69bb9f
files sat/tools/utils.py
diffstat 1 files changed, 8 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/sat/tools/utils.py	Tue Mar 22 17:00:42 2022 +0100
+++ b/sat/tools/utils.py	Tue Mar 22 17:00:42 2022 +0100
@@ -227,7 +227,8 @@
         try:
             hg_data_raw = subprocess.check_output(
                 [
-                    "hg",
+                    "python3",
+                    hg_path,
                     "log",
                     "-r",
                     "-1",
@@ -241,12 +242,16 @@
                 ],
                 text=True
             )
-        except subprocess.CalledProcessError:
+        except subprocess.CalledProcessError as e:
+            log.error(f"Can't get repository data: {e}")
+            hg_data = {}
+        except Exception as e:
+            log.error(f"Unexpected error, can't get repository data : [{type(e)}] {e}")
             hg_data = {}
         else:
             hg_data = dict(list(zip(KEYS, hg_data_raw.split("\n"))))
             try:
-                hg_data["modified"] = "+" in subprocess.check_output(["hg", "id", "-i"], text=True)
+                hg_data["modified"] = "+" in subprocess.check_output(["python3", hg_path, "id", "-i"], text=True)
             except subprocess.CalledProcessError:
                 pass
     else: