-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathfabfile.py
88 lines (58 loc) · 1.59 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
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
# from fabric.api import cd, env, local, run
from fabric import Connection, task
import invoke
host = 'kitarez'
def run(command):
Connection(host).run(command)
@task
def test(ctx, verbosity='1'):
invoke.run(f"python ./manage.py test rezepte -v {verbosity}")
@task
def makemigrations(ctx):
invoke.run("python ./manage.py makemigrations rezepte")
@task
def migrate_local(ctx):
invoke.run("python ./manage.py migrate rezepte")
@task
def serve(ctx):
invoke.run("./manage.py runserver")
@task
def sass(ctx):
invoke.run("sass rezepte/static/css/main.{scss,css}")
invoke.run("sass rezepte/static/css/print.{scss,css}")
@task
def commit(ctx):
invoke.run("git add -p && git commit")
@task
def push(ctx):
invoke.run("git push")
@task
def prepare_deploy(ctx):
test()
commit()
push()
code_dir = "~/kita-rezepte"
# call with: `fab server_pull:my_branch`
@task
def server_pull(ctx, branch='master'):
run(f"cd {code_dir} && git pull origin {branch}")
@task
def install_requirements(ctx):
run(f"cd {code_dir} && pip3.6 install -r requirements.txt --user")
@task
def staticfiles(ctx):
run(f"python3.6 {code_dir}/kitarezepte/manage.py collectstatic --noinput")
@task
def migrate(ctx):
run(f"python3.6 {code_dir}/kitarezepte/manage.py migrate")
@task
def restart_server(ctx):
run("touch ~/kita-rezepte/kitarezepte/kitarezepte/wsgi.py")
# # call with: `fab deploy:my_branch`
# def deploy(branch='master'):
# server_pull(branch)
# # install_requirements()
# migrate()
# staticfiles()
# # copy_htaccess()
# # restart_server()