These are chat archives for CharlesGust/django-imagr

23rd
Nov 2014
Charlie
@charlieRode
Nov 23 2014 00:23
Are you guys going to be in tomorrow? I'm thinking ill try to get there early and stay all day
Ben Friedland
@BFriedland
Nov 23 2014 02:02
I'll probably be in tomorrow but I'm not sure. I've been working on building the fab file but I don't really know if I have anything to show for it yet, tiny steps take forever to debug since most of them have to do with updating a machine we're getting from Amazon (the AMI) and we have no idea what it's missing until it throws an error.
For example, 'sudo pip install -r requirements.txt' was a weird one, because I was getting IncompleteRead for a while and it seemed I'd need to reinstall it. I ended up finding https://bugs.launchpad.net/ubuntu/+source/python-pip/+bug/1306991/comments/24
Ben Friedland
@BFriedland
Nov 23 2014 02:08
which suggested I should uninstall pip and get it from another source -- that all works on my machines if I remove the '3' part of 'python3'.
So I commented 'apt-get -y install python-pip' in the apt-gets and inserted the two lines from that bug report comment I linked inside _install_pips() with the proper modification to make them not try python3.
Then 'pip install -r requirements.txt' worked without giving me an IncompleteRead -related traceback.
I noticed in pip's feedback at that point that it had somehow already gotten all of the requirements installed. I don't know how, since I was getting tracebacks before then. I haven't been able to test it yet since even the smallest things take a while to figure out and I'd have to make a new machine image and step through it on the command line to be sure (otherwise I'd be testing my fabfile, which I'll probably do first since it's faster).
Ben Friedland
@BFriedland
Nov 23 2014 03:02
I'm currently stuck on automating database creation. I can't figure out how to get the password into the os environment without putting it in the fabfile, since for some reason calling credentials.py with execfile() did not successfully put DATABASE_PASSWORD into the os environment, even when 'if "__name__" == "__main__": set_credentials()' was placed at the bottom of the file.
I then tried making set_credentials() return the value of the database password and tried to see if execfile() would push the results of any functions called while running it into a variable in my fabfile (using the syntax, "password_variable = execfile("./imagr_site/imagr_site/credentials.py") and the resulting value was simply 'None', which made the PSQL user on the AWS instance get created with 'None' as its password -- I was hoping I could make an automatic SQL query to delete the user and the database on the instance, but I couldn't remember how it was supposed to work and none of my google queries gave me useful StackOverflow results for some reason.
Ben Friedland
@BFriedland
Nov 23 2014 03:08
All the stuff requiring execfile() is probably a bad idea anyways, even if we know it's secure due to not having any holes.
Very hackish kind of solution.
Charlie
@charlieRode
Nov 23 2014 03:20
I don't know if this will help, but I have been reading through this tutorial, and finding it pretty good. http://rogueleaderr.com/post/65157477648/the-idiomatic-guide-to-deploying-django-in-production
Ben Friedland
@BFriedland
Nov 23 2014 03:27
Hm, can't believe I didn't think to check before, but apparently any changes made to os.environ seem to be reset when I exit and reenter IDLE, so setting them by running a file outside of the python file's scope probably won't work -- in the Django settings.py file, credentials.py is simply imported, so the os.environ dictionary is not discarded between the time set_credentials() is called and when the dictionary is pinged.
And thanks for the link, I'll look it over later. It's getting kind of late though, I think I'd better go soon.
Charles Gust
@CharlesGust
Nov 23 2014 05:49
Hi Ben, It's probably why you have to use "source" to set environment variables. I know when you exec a script, the variables are set only for that script, so I bet execfiles is somewhat similar.
Ben Friedland
@BFriedland
Nov 23 2014 23:05
Yeah, I hadn't played around with os.environ much before this assignment. Oops.
I also haven't made too many packages previously because I'd been using less expansive frameworks, so I'm not really sure how to turn the django-imagr directory into a package itself. That would get around a tiny inconvenience with my solution to getting the fabfile to work -- I put the credentials.py file in both the root directory of our site and in the same level as settings.py, so that both the fabfile and the settings file would be able to import set_credentials() and use the os.environ dictionary for that.
Ben Friedland
@BFriedland
Nov 23 2014 23:27
The server needs credentials.py in the settings.py-level folder, but the fabfile on our local machine needs it in the fabfile.py-level folder. If it was a package, we could simply copy it into one place and forget about it. I decided to make a fabric function to automate transferring the credentials file from one place into another, but strictly speaking it isn't necessary to do that if you'd rather have it in two places locally.
It's probably easy enough to make it into a package, but I've never done it before and it might be another 30-foot-deep puddle to step into...
Ben Friedland
@BFriedland
Nov 23 2014 23:48
I wish there was more time to clean up the fabfile and settings.py file. I also would like to alter the current github master file so I can test my fabfile (it needs to clone from github), but I don't want to overwrite your changes to the master branch without consulting with you first (Charles). I'm going to try and make a fork and get it working with that, and you can merge it into master some time tonight or tomorrow, or we can discuss the necessary changes.