Tools: use path relative to current directory to load parameters

This commit is contained in:
Willian Galvani 2022-02-01 21:27:03 -03:00 committed by Tom Pittenger
parent b3e78e1e8d
commit 5cb1444b1d
2 changed files with 4 additions and 1 deletions

View File

@ -57,6 +57,9 @@ def topdir():
d = os.path.dirname(d)
return d
def relcurdir(path):
"""Return a path relative to current dir"""
return os.path.relpath(path, os.getcwd())
def reltopdir(path):
"""Return a path relative to topdir()."""

View File

@ -684,7 +684,7 @@ def start_vehicle(binary, opts, stuff, spawns=None):
paths = stuff["default_params_filename"]
if not isinstance(paths, list):
paths = [paths]
paths = [util.reltopdir(os.path.join(autotest_dir, x)) for x in paths]
paths = [util.relcurdir(os.path.join(autotest_dir, x)) for x in paths]
for x in paths:
if not os.path.isfile(x):
print("The parameter file (%s) does not exist" % (x,))