Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use expanduser instead of looking for $HOME manually (fixes #97) #98

Merged
merged 1 commit into from
May 11, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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