From 8624fe6e55e1bce903ab7d04a3ef28fd93f0f796 Mon Sep 17 00:00:00 2001 From: "Mike C. Fletcher" Date: Wed, 8 Jan 2020 09:36:05 -0500 Subject: [PATCH] FIX do not return ${APPDATA}/.config when looking for appdata Also, if the config directory doesn't exist, try to create it, for systems where .config isn't automatically created. --- runsnakerun/homedirectory.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/runsnakerun/homedirectory.py b/runsnakerun/homedirectory.py index e8efc59..a778b8c 100644 --- a/runsnakerun/homedirectory.py +++ b/runsnakerun/homedirectory.py @@ -67,13 +67,21 @@ def appdatadirectory(): ## default case, look for name in environ... for name in ['APPDATA', 'HOME']: if name in os.environ: + if name == 'APPDATA': + return os.environ[name] return os.path.join(os.environ[name], RELATIVE_CONFIG) # well, someone's being naughty, see if we can get ~ to expand to a directory... possible = os.path.abspath(os.path.expanduser('~/%s'%(RELATIVE_CONFIG,))) if os.path.exists(possible): return possible + try: + os.makedirs(possible) + except Exception: + pass raise OSError( - """Unable to determine user's application-data directory, no ${HOME} or ${APPDATA} in environment""" + """Unable to determine user's application-data directory, no ${HOME} or ${APPDATA} in environment, unable to create %s"""%( + possible, + ) )