Skip to content

wonderpl/dolly-web

Repository files navigation

Flask app for rockpack web services and content admin.

Development

Run dev server with:

python2.7 manage.py runserver

Step-by-step env setup

  1. cd mainsite
  2. virtualenv --system-site-packages env (see virtualenv usage)
  3. . env/bin/activate
  4. pip install -r requirements.txt -r requirements-dev.txt (see pip usage)
  5. Create local configuration file: echo -e "DEBUG = True\nDATABASE_URL = 'sqlite:///rockpack.db'" >rockpack/mainsite/settings/local.py
  6. python2.7 manage.py syncdb
  7. python2.7 manage.py runserver
  8. curl http://127.0.0.1:5000/ws/

Troubleshooting

Cryptography package installation error: raise ffiplatform.VerificationError(error)

Possible fix: http://chriskief.com/2014/03/25/installing-cryptography-via-pip-with-macports-or-homebrew/

sudo env ARCHFLAGS="-arch x86_64" LDFLAGS="-L/opt/local/lib" CFLAGS="-I/opt/local/include" pip install cryptography

Syncdb Response error: ImportError: cannot import name Response

Possible fix: joelverhagen/flask-rauth#4

easy_install rauth==0.4.17

File not found error: flask OSError: [Errno 2] No such file or directory

Possible fix: install less and coffeescript via npm

sudo npm install -g less
sudo npm install -g coffee-script

Database setup

  1. Install & start postgres server (version 9)

  2. sudo -u postgres createdb rockpack

  3. Load db dump from s3: s3cmd get s3://backup.dev.rockpack.com/postgres/rockpack/2013-09-03T15:42:30.792652.sql.gz - | zcat | psql rockpack

  4. echo "DATABASE_URL = 'postgresql:///rockpack'" >>rockpack/mainsite/settings/local.py

  5. Update schema: alembic upgrade head

  6. Install & start ElasticSearch (version 0.90)

  7. echo "ELASTICSEARCH_URL = 'http://localhost:9200'" >>rockpack/mainsite/settings/local.py

  8. python2.7 manage.py init_es

  9. python2.7 manage.py import_to_es Warning: will take a while!

Using database from dev

  1. Create ssh tunnels: ssh -L 45432:localhost:5432 -L 49200:es1:9200 -N dev.rockpack.com
  2. Update config: echo -e "DATABASE_URL = 'postgresql://mainsite:mainsite@localhost:45432/rockpack'\nELASTICSEARCH_URL = 'http://localhost:49200'" >>rockpack/mainsite/settings/local.py

Test

Run unit tests with pytest

py.test -x

Build

To build rpm:

python2.7 setup.py rpm