This repository was archived by the owner on Mar 22, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathfabfile.py
More file actions
127 lines (93 loc) · 2.36 KB
/
Copy pathfabfile.py
File metadata and controls
127 lines (93 loc) · 2.36 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# -*- coding: utf-8 -*-
# http://docs.fabfile.org/en/1.5/tutorial.html
from fabric.api import *
from fabric.network import ssh
from flask.ext.script import Manager
project = "gastosabertos"
remote_project_dir = '/home/gastosabertos/gastos_abertos'
remote_prefix = "source /home/gastosabertos/.virtualenvs/ga/bin/activate"
env.user = 'gastosabertos'
env.hosts = ['gastosabertos.org']
# env.key_filename = '~/.ssh/ga_id_rsa'
env.place = "remote"
def smart_run(command, inside_env=False):
if env.place == "local":
local(command)
elif env.place == "remote":
if inside_env:
with cd(remote_project_dir):
with prefix(remote_prefix):
run(command)
else:
run(command)
env.run_in = smart_run
@task
def run_local():
env.place = "local"
@task
def reset():
"""
Reset local debug env.
"""
env.run_in("""
rm -rf /tmp/instance
mkdir /tmp/instance
""")
@task
def setup():
"""
Setup virtual env.
"""
env.run_in("virtualenv env")
activate_this = "env/bin/activate_this.py"
execfile(activate_this, dict(__file__=activate_this))
env.run_in("python setup.py install")
reset()
@task
def deploy():
"""
Deploy project to Gastos Abertos server
"""
env.run_in("""
git pull
python setup.py develop
touch wsgi.py
""", inside_env=True)
@task
def initdb():
"""
Init or reset database
"""
env.run_in("python manage.py initdb", inside_env=True)
@task
def importdata(lines_per_insert=100):
"""
Import data to the local DB
"""
# env.run_in("""
# python utils/import_revenue_codes.py
# python utils/import_revenue.py data/receitas_min.csv {lines_per_insert}
# python utils/import_contrato.py
# """.format(lines_per_insert=lines_per_insert), inside_env=True)
env.run_in("python manage.py importdata", inside_env=True)
@task
def generate_jsons(year=''):
"""
Generate Jsons for Highcharts
"""
env.run_in("""
python utils/generate_total_json.py -o data/total_by_year_by_code {year}
""".format(year=year), inside_env=True)
@task
def d():
"""
Debug.
"""
reset()
local("python manage.py run")
@task
def babel():
"""
Babel compile.
"""
env.run_in("python setup.py compile_catalog --directory `find -name translations` -f")