From fac7b51d4ceb1fb59c409becb2ed520cb11421db Mon Sep 17 00:00:00 2001 From: Quentin De Coninck Date: Tue, 26 Oct 2021 09:16:08 +0200 Subject: [PATCH] fix crash when running minitopo outside of its directory --- runner.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/runner.py b/runner.py index f20a9a9..4721558 100644 --- a/runner.py +++ b/runner.py @@ -10,11 +10,18 @@ from experiments import EXPERIMENTS from topos import TOPO_CONFIGS, TOPOS import logging +import os import subprocess import traceback def get_git_revision_short_hash(): - return subprocess.check_output(['git', 'rev-parse', '--short', 'HEAD']).decode("unicode_escape").strip() + # Because we might run Minitopo from elsewhere. + curr_dir = os.getcwd() + ROOT_DIR = os.path.dirname(os.path.abspath(__file__)) + os.chdir(ROOT_DIR) + ret = subprocess.check_output(['git', 'rev-parse', '--short', 'HEAD']).decode("unicode_escape").strip() + os.chdir(curr_dir) + return ret class Runner(object): """