forked from openstates/openstates-scrapers
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fabfile.py
44 lines (35 loc) · 1.49 KB
/
fabfile.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
from fabric.api import run, env, cd, sudo, get
def staging():
env.hosts = ['[email protected]']
def production():
env.hosts = ['[email protected]']
def update():
sudo('cd ~openstates/src/openstates && git pull', user='openstates')
def restart_uwsgi():
sudo('restart uwsgi')
def restart_nginx():
sudo('/etc/init.d/nginx restart')
def _venv(cmd):
sudo('source ~openstates/site-venv/bin/activate && ' + cmd)
def get_legislator_csv(state):
with cd('/tmp/'):
_venv('~openstates/src/openstates/billy/bin/dump_legislator_csv.py ' +
state)
get('/tmp/%s_legislators.csv' % state, '%s_legislators.csv' % state)
def get_leg_ids_csv(state):
with cd('/tmp/'):
_venv('~openstates/src/openstates/billy/bin/dump_missing_leg_ids.py ' +
state)
get('/tmp/%s_missing_leg_ids.csv' % state,
'%s_missing_leg_ids.csv' % state)
def dump_json(state):
with cd('/tmp/'):
cmd = '~openstates/src/openstates/billy/bin/dump_json.py --upload '
# special case those known to have reasons not to pass validation
# la: missing dates on votes sometimes
# ca: version URLs missing
schemas = {'la': '--schema_dir=/projects/openstates/src/openstates/openstates/la/schemas/api/ ',
'ca': '--schema_dir=/projects/openstates/src/openstates/openstates/ca/schemas/api/ ',}
if state in schemas:
cmd += schemas[state]
_venv(cmd + state)