Skip to content

Commit

Permalink
Test for real whether home is writable (Github issue #226)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelzwiers committed Feb 14, 2024
1 parent 0672aaa commit 20b906c
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions bidscoin/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import urllib.request, urllib.parse, urllib.error
import json
import getpass
import os
import platform
import hashlib
import shelve
Expand Down Expand Up @@ -60,11 +61,11 @@
pluginfolder = bidscoinroot/'plugins'

# Get the BIDSCOIN_DEBUG environment variable to set the log-messages and logging level, etc
DEBUG = platform.os.getenv('BIDSCOIN_DEBUG','').upper() in ('1', 'TRUE', 'Y', 'YES')
DEBUG = 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() if Path.home().exists() else Path(tempfile.gettempdir()))/'.bidscoin'/__version__/'config.toml')
configfile = Path(os.getenv('BIDSCOIN_CONFIG') or
(Path.home() if os.access(Path.home(),os.W_OK) else Path(tempfile.gettempdir()))/'.bidscoin'/__version__/'config.toml')
templatefolder = configfile.parent/'templates'
templatefolder.mkdir(parents=True, exist_ok=True)
if not configfile.is_file():
Expand Down Expand Up @@ -149,7 +150,7 @@ def trackusage(event: str, dryrun: bool=False) -> dict:
'hostid': hashlib.md5(platform.node().encode('utf8')).hexdigest()}

# Check if the user allows tracking or if it is a dry/test run
if not config['bidscoin'].get('trackusage', 'yes') == 'yes' or dryrun or "PYTEST_CURRENT_TEST" in platform.os.environ:
if not config['bidscoin'].get('trackusage', 'yes') == 'yes' or dryrun or "PYTEST_CURRENT_TEST" in os.environ:
return data

# Check if we are not asleep
Expand Down

0 comments on commit 20b906c

Please sign in to comment.