Skip to content

Conversation

@mchestnut91
Copy link
Contributor

Found the solution in this SO post: https://stackoverflow.com/questions/4028904/how-to-get-the-home-directory-in-python

Should work with all operating systems now

CONFIG_DIR = ".predictivegrid"
CREDENTIALS_FILENAME = "credentials.yaml"
CREDENTIALS_PATH = os.path.join(os.environ["HOME"], CONFIG_DIR, CREDENTIALS_FILENAME)
CREDENTIALS_PATH = os.path.join(os.path.expanduser("~"), CONFIG_DIR, CREDENTIALS_FILENAME)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like your solution will work for the problem of no HOME env var. But what happens if they are using an account with no user directory at all?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just created a user with no home directory and it just gives back the root directory. If the credentials file doesnt exist, the code will just gracefully ignore this.

@immesys immesys merged commit c73c85b into develop Aug 12, 2020
@immesys immesys deleted the credentials_fix branch August 12, 2020 20:50
@immesys
Copy link
Member

immesys commented Aug 12, 2020

@looselycoupled can you release this on pypi?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants