From e4b8b1dbdc06f781bccbbdd396824088a095827d Mon Sep 17 00:00:00 2001 From: Eric Flumerfelt Date: Fri, 16 Jun 2023 09:37:35 -0400 Subject: [PATCH 1/2] Call expandvars on data_file when it is not a URI (i.e. is a path to a file), so that "default_data_file": "$PWD/frames.bin" works as expected. --- python/daqconf/core/assets.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/python/daqconf/core/assets.py b/python/daqconf/core/assets.py index cac11a2c..a43a6b26 100755 --- a/python/daqconf/core/assets.py +++ b/python/daqconf/core/assets.py @@ -48,10 +48,11 @@ def resolve_asset_file(data_file, verbose): return filename - if data_file != '' and not exists(data_file): + resolved_data_file = Path(os.path.expandvars(data_file)).expanduser().absolute() + if resolved_data_file != '' and not exists(resolved_data_file): raise RuntimeError(f'Cannot find the frames.bin file {data_file}') if verbose: - console.log(f"Found asset in {dirname(abspath(data_file))}") + console.log(f"Found asset in {dirname(resolved_data_file)}") - return abspath(data_file) + return resolved_data_file From 35b41e31f823d2e88ec595192ab0859e3c34bcc3 Mon Sep 17 00:00:00 2001 From: Eric Flumerfelt Date: Fri, 16 Jun 2023 08:45:47 -0500 Subject: [PATCH 2/2] Fix import, remove pathlib.Path --- python/daqconf/core/assets.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/python/daqconf/core/assets.py b/python/daqconf/core/assets.py index a43a6b26..fc52c2a4 100755 --- a/python/daqconf/core/assets.py +++ b/python/daqconf/core/assets.py @@ -1,5 +1,5 @@ -from os.path import exists,abspath,dirname +from os.path import exists,abspath,dirname,expandvars from rich.console import Console console = Console() @@ -48,7 +48,7 @@ def resolve_asset_file(data_file, verbose): return filename - resolved_data_file = Path(os.path.expandvars(data_file)).expanduser().absolute() + resolved_data_file = abspath(expandvars(data_file)) if resolved_data_file != '' and not exists(resolved_data_file): raise RuntimeError(f'Cannot find the frames.bin file {data_file}')