Skip to content

Commit

Permalink
FIX do not return ${APPDATA}/.config when looking for appdata
Browse files Browse the repository at this point in the history
Also, if the config directory doesn't exist, try to create it,
for systems where .config isn't automatically created.
  • Loading branch information
mcfletch committed Jan 8, 2020
1 parent d41d63e commit 8624fe6
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion runsnakerun/homedirectory.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
)


Expand Down

0 comments on commit 8624fe6

Please sign in to comment.