tools (utils): fix getRepositoryData crash:

- use `hg_path` to be sure to use the right executable
- better exception handling
This commit is contained in:
Goffi 2022-03-22 17:00:42 +01:00
commit 3ee5e1bbba

View file

@ -227,7 +227,8 @@ def getRepositoryData(module, as_string=True, is_path=False):
try:
hg_data_raw = subprocess.check_output(
[
"hg",
"python3",
hg_path,
"log",
"-r",
"-1",
@ -241,12 +242,16 @@ def getRepositoryData(module, as_string=True, is_path=False):
],
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: