From 0c3077ae0b73fde455b53b603c55ef3c92afea77 Mon Sep 17 00:00:00 2001 From: Marcel Zwiers Date: Tue, 13 Feb 2024 22:05:39 +0100 Subject: [PATCH] Catch for setting the configfile to TMPDIR in homeless containers (Github issue #226) --- bidscoin/__init__.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bidscoin/__init__.py b/bidscoin/__init__.py index a16ed48c..9cbf61e1 100644 --- a/bidscoin/__init__.py +++ b/bidscoin/__init__.py @@ -22,6 +22,7 @@ import datetime import shutil import warnings +import tempfile from pathlib import Path from importlib import metadata from typing import Tuple, Union, List @@ -62,7 +63,8 @@ DEBUG = platform.os.getenv('BIDSCOIN_DEBUG','').upper() in ('1', 'TRUE', 'Y', 'YES') # Create a BIDScoin user configuration directory if needed and load the BIDScoin user settings -configfile = Path(platform.os.getenv('BIDSCOIN_CONFIG') or Path.home()/'.bidscoin'/__version__/'config.toml') +configfile = Path(platform.os.getenv('BIDSCOIN_CONFIG') or + (Path.home() if Path.home().exists() else Path(tempfile.gettempdir()))/'.bidscoin'/__version__/'config.toml') templatefolder = configfile.parent/'templates' templatefolder.mkdir(parents=True, exist_ok=True) if not configfile.is_file():