-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathfabfile.py
More file actions
85 lines (73 loc) · 1.89 KB
/
fabfile.py
File metadata and controls
85 lines (73 loc) · 1.89 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
from fabric.api import local, env, task
from fabric.operations import put, run
from fabric.utils import abort
import platform
import os
#this shit doesn't work on windows for obvious reasons need to check this later
# Do use this if you want to perform an action in virtualenv.
def detect_os():
return platform.system()
def run_in_venv(cmd):
if (detect_os() != "Windows"):
local('source .venv/bin/activate && ' + cmd, shell='/bin/bash')
else:
local('.\.venv\Scripts\activate.bat & ' + cmd, capture=False)
@task
def setup(aliased=False):
"""
Setups virtualenv folder and dependencies...
"""
if (detect_os() != "Windows"):
# set up virtualenv
if not ("venv" in os.listdir('.')):
local('sudo pip install virtualenv')
local('virtualenv .venv')
run_in_venv('pip install -r requirements.txt')
print "Setup successfully done"
@task(alias='update')
def update_requirements():
"""
Install all requirements in the file requirements.txt
"""
run_in_venv('pip install -r requirements.txt')
@task
def freeze():
"""
Updates the file requirements.txt with the installed packages in .venv
"""
run_in_venv('pip freeze > requirements.txt')
@task
def pull_r():
"""
Runs git pull with rebase
Usage: fab pull_r
"""
local('git pull --rebase')
@task
def commit(msg):
"""
Adds all modifications on the repository and commits with a message
Usage: fab commit:\"msg\"
"""
if msg[0] == '"':
msg = msg[1:]
if msg[-1] == '"':
msg = msg[:-1]
local('git add --all')
local('git commit -m \"' + msg + '\"')
@task
def push():
"""
Pushes the modifications to the git repository
Usage: fab push
"""
local('git push origin master')
@task
def git_all(msg):
"""
Performs a commit, pull and a push in one command
Usage: fab git_all:\"msg\"
"""
commit(msg)
pull_r()
push()