Skip to content

An implementation of the data sourcing efforts suggested by the Indivisible Guide, using the ProPublica Data APIs.

License

Notifications You must be signed in to change notification settings

jhurwitz/indivisible

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

indivisibleguide

A collection of tools to help realize the organizing principles from the Indivisible Guide. Data sources include:

  1. ProPublica Data APIs
  2. Event Registry
  3. U.S. Government Publishing Office
  4. GovTrack.us
  5. Politifact

Setup:

  • You have python installed on your computer (comes by default), as well as the following libraries: On Linux:
sudo apt-get install python-pip
sudo apt-get install python-virtualenv

On Mac OSX (with Homebrew):

brew install python-pip
sudo pip install virtualenv
  • You will need to create and activate a virtualenv for the project as follows:
virtualenv venv
. venv/bin/activate
  • Then install the dependencies:
pip install -r requirements.txt
PYTHONPATH=/path/to/repo/indivisible
  • Save the API keys to the same file:
PROPUBLICA_API_KEY="PASTE_API_KEY_HERE"
EVENT_REGISTRY_API_KEY="PASTE_API_KEY_HERE"
GOOGLE_CIVIC_INFORMATION_API="PASTE_API_KEY_HERE"
...
  • Install DB of choice.
sudo apt-get install mysql-server
sudo mysql_secure_installation
mysqld --initialize
  • Add database URI to configs:
DB_ADDR="mysql+pymysql://USER:PASSWORD@localhost/indivisible?charset=utf8"
  • Initialize DB (note SQLite doesn't allow key constraint changes, so you may have to delete those lines):
pushd indivisible
env $(cat ../indivisible.cfg | xargs) python manager.py db upgrade
popd

How to run:

export FLASK_DEBUG=1
env $(cat indivisible.cfg | xargs) python indivisible/indivisible.py

Hosting your own public server:

  • Set up an Ubuntu VPS ala Digital Ocean
  • Run the following to set up Apache:
sudo apt-get update
sudo apt-get install apache2 libapache2-mod-wsgi python-dev
sudo a2enmod wsgi
  • Clone your repo into /var/www:
cd /var/wwww
git clone [email protected]:danieltahara/indivisible.git
  • Repeat setup steps above.
  • Add an app.conf as per Digital Ocean instructions:
sudo vim /etc/apache2/sites-available/indivisible.conf
WSGIPythonHome /var/www/indivisible/venv/bin
WSGIPythonPath /var/www/indivisible/venv/lib/python2.7/site-packages

<VirtualHost *:80>
    ServerName YOUR_IP_ADDR_OR_DOMAIN
    ServerAdmin YOUR_EMAIL_ADDR
    WSGIScriptAlias / /var/www/indivisible/indivisible.wsgi
    WSGIScriptReloading On
    <Directory /var/www/indivisible/indivisible/>
        Order allow,deny
        Allow from all
    </Directory>
    Alias /static /var/www/indivisible/indivisible/static
    <Directory /var/www/indivisible/indivisible/static/>
        Order allow,deny
        Allow from all
    </Directory>
    ErrorLog
    ${APACHE_LOG_DIR}/error.log
    LogLevel warn
    CustomLog
    ${APACHE_LOG_DIR}/access.log
    combined
</VirtualHost>
  • Add a .wsgi file:
sudo vim /var/www/indivisible/indivisible.wsgi
import os
import sys
import logging

logging.basicConfig(stream=sys.stderr)
sys.path.insert(0,"/var/www/indivisible/")

# Add your keys here.
os.environ['PROPUBLICA_API_KEY'] = "XXXX"

from indivisible import app as application
from indivisible import initialize_app
initialize_app(application)
  • Enable Virtual Host:
sudo a2ensite indivisible
  • Restart apache
sudo service apache2 restart
sudo apt-get install python-letsencrypt-apache
letsencrypt apache

About

An implementation of the data sourcing efforts suggested by the Indivisible Guide, using the ProPublica Data APIs.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 67.6%
  • HTML 27.4%
  • JavaScript 2.3%
  • CSS 2.1%
  • Mako 0.6%