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

data should be stored in a local place #41

Open
SwartzCr opened this issue Oct 27, 2016 · 4 comments
Open

data should be stored in a local place #41

SwartzCr opened this issue Oct 27, 2016 · 4 comments

Comments

@SwartzCr
Copy link
Owner

maybe remove the call to os.getcwd

@brianshumate
Copy link
Contributor

Heyo!

I am not quite sure what you mean by local place in this one, but am happy to fix it!

@brianshumate
Copy link
Contributor

brianshumate commented May 9, 2017

So currently we have:

data_file = os.getcwd() + '/var/data.json'

which for me translates to a data.json stored on this path:

/home/brian/nekoatsume/var/data.json

Do you think that we should instead store it somewhere completely outside of the codebase?

We could portably do so (so that it works even on Windows) using os.path.expanduser, and store the file in the user's home directory like this:

from os.path import expanduser

...

home = expanduser("~")
data_file = home + '/data.json'

@SwartzCr
Copy link
Owner Author

I think the problem I'm worried about is that os.getcwd() gets the returns the directory that you're invoking the script from, not the directory that they script is in.
See the response from Andrew Clark here: https://stackoverflow.com/questions/19322836/how-do-i-find-directory-of-the-python-running-script-from-inside-the-script
Which means if you cd into the nekoatsume directory and call it, everything is fine, but if you run it from a cron job, or run it from outside of that directory then your data file ends up somewhere kinda random

@brianshumate
Copy link
Contributor

Ahhh! Makes perfect sense, and nice observation!

Do you think storing data in the user's home dir is a good approach to resolve this?

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

No branches or pull requests

2 participants