comparison sat/tools/utils.py @ 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 aa58451b77ba
children e417c478b488
comparison
equal deleted inserted replaced
3738:ffa8c8c78115 3739:0a87cae85746
225 if hg_path is not None: 225 if hg_path is not None:
226 os.chdir(repos_root) 226 os.chdir(repos_root)
227 try: 227 try:
228 hg_data_raw = subprocess.check_output( 228 hg_data_raw = subprocess.check_output(
229 [ 229 [
230 "hg", 230 "python3",
231 hg_path,
231 "log", 232 "log",
232 "-r", 233 "-r",
233 "-1", 234 "-1",
234 "--template", 235 "--template",
235 "{node}\n" 236 "{node}\n"
239 "{latesttag}\n" 240 "{latesttag}\n"
240 "{latesttagdistance}", 241 "{latesttagdistance}",
241 ], 242 ],
242 text=True 243 text=True
243 ) 244 )
244 except subprocess.CalledProcessError: 245 except subprocess.CalledProcessError as e:
246 log.error(f"Can't get repository data: {e}")
245 hg_data = {} 247 hg_data = {}
248 except Exception as e:
249 log.error(f"Unexpected error, can't get repository data : [{type(e)}] {e}")
250 hg_data = {}
246 else: 251 else:
247 hg_data = dict(list(zip(KEYS, hg_data_raw.split("\n")))) 252 hg_data = dict(list(zip(KEYS, hg_data_raw.split("\n"))))
248 try: 253 try:
249 hg_data["modified"] = "+" in subprocess.check_output(["hg", "id", "-i"], text=True) 254 hg_data["modified"] = "+" in subprocess.check_output(["python3", hg_path, "id", "-i"], text=True)
250 except subprocess.CalledProcessError: 255 except subprocess.CalledProcessError:
251 pass 256 pass
252 else: 257 else:
253 hg_data = {} 258 hg_data = {}
254 259