-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathfabfile.py
59 lines (43 loc) · 1.3 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import os
import random
import string
from fabric.api import env, local
from fabric.colors import cyan
from fabric.context_managers import shell_env
current_dir = os.getcwd()
env.project_name = 'infoscience_exports'
env.branch = 'master'
env.environments = ['dev',
'qa',
'prod']
def migrate():
with shell_env(DATABASE_PASSWORD='django'):
local('python {}/manage.py migrate'.format(env.project_name))
def serve():
with shell_env(DATABASE_PASSWORD='django'):
local('python {}/manage.py runserver'.format(env.project_name))
def test():
"""
Runs nose test suite
"""
with shell_env(DATABASE_PASSWORD='django'):
local('flake8 {}'.format(env.project_name))
print(cyan('flake8 passed!', bold=True))
local('python {}/manage.py test'.format(env.project_name))
def create_secret_key():
"""
Creates a random string of letters and numbers
"""
return ''.join(random.choice(string.ascii_letters + string.digits) for i in range(30))
def dev():
"""fab dev [command]"""
env.environment = 'dev'
env.branch = 'master'
def qa():
"""fab staging [command]"""
env.environment = 'qa'
env.branch = 'qa'
def prod():
"""fab prod [command]"""
env.environment = 'prod'
env.branch = 'prod'