1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
|
commit b9d4df78db7aaeda1feb58c18b0071934de2361e
Author: Eric89GXL <larson.eric.d@gmail.com>
Date: Wed Nov 12 10:22:45 2014 -0800
ENH: Allow not writing home
--- a/mne/utils.py
+++ b/mne/utils.py
@@ -24,6 +24,8 @@ from math import log, ceil
import json
import ftplib
import hashlib
+from functools import partial
+import atexit
import numpy as np
import scipy
@@ -983,8 +985,12 @@ def get_subjects_dir(subjects_dir=None,
return subjects_dir
+_temp_home_dir = None
+
+
def _get_extra_data_path(home_dir=None):
"""Get path to extra data (config, tables, etc.)"""
+ global _temp_home_dir
if home_dir is None:
# this has been checked on OSX64, Linux64, and Win32
if 'nt' == os.name.lower():
@@ -996,7 +1002,14 @@ def _get_extra_data_path(home_dir=None):
# of script that isn't launched via the command line (e.g. a script
# launched via Upstart) then the HOME environment variable will
# not be set.
- home_dir = os.path.expanduser('~')
+ if os.getenv('MNE_DONTWRITE_HOME', '') == 'true':
+ if _temp_home_dir is None:
+ _temp_home_dir = tempfile.mkdtemp()
+ atexit.register(partial(shutil.rmtree, _temp_home_dir,
+ ignore_errors=True))
+ home_dir = _temp_home_dir
+ else:
+ home_dir = os.path.expanduser('~')
if home_dir is None:
raise ValueError('mne-python config file path could '
|