Skip to content

Commit

Permalink
Merge pull request #98 from solvebio/fix-windows-auth
Browse files Browse the repository at this point in the history
use expanduser instead of looking for $HOME manually (fixes #97)
  • Loading branch information
davecap committed May 11, 2016
2 parents d1d2bc7 + 8a353ba commit 6de59cb
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions solvebio/cli/credentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,21 @@ class netrc(_netrc):
"""
@staticmethod
def path():
if os.name == 'nt':
# Windows
path = '~\\_solvebio\\credentials'
else:
# *nix
path = '~/.solvebio/credentials'

try:
path = os.path.join(os.environ['HOME'], '.solvebio', 'credentials')
path = os.path.expanduser(path)
except KeyError:
raise IOError("Could not find credentials file: $HOME is not set")
# os.path.expanduser can fail when $HOME is undefined and
# getpwuid fails. See http://bugs.python.org/issue20164
raise IOError(
"Could not find any home directory for '{0}'"
.format(path))

if not os.path.isdir(os.path.dirname(path)):
os.makedirs(os.path.dirname(path))
Expand Down

0 comments on commit 6de59cb

Please sign in to comment.