forked from bokeh/bokeh
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfabfile.py
48 lines (38 loc) · 1.31 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
from fabric.api import run, env, roles
from fabric.contrib.files import exists
from fabric.contrib.project import rsync_project
import sys
sys.path.append("source")
import conf
env.roledefs = {
'web': ['172.99.67.225']
}
env.user = "bokeh"
@roles('web')
def deploy(v=None):
if v is None:
v = conf.version
elif v == "latest":
raise RuntimeError("You can not pass 'latest' as fab argument. Use fab latest:x.x.x instead.")
# make a backup of the old directory
run("rm -rf /www/bokeh/en/%s.bak" % v)
run("mkdir -p /www/bokeh/en/%s" % v)
run("cp -ar /www/bokeh/en/%s /www/bokeh/en/%s.bak" % (v, v))
rsync_project(
local_dir="build/html/",
remote_dir="/www/bokeh/en/%s" % v,
delete=True
)
# set permissions
run("chmod -R g+w /www/bokeh/en/%s" % v)
@roles('web')
def latest(v=None):
if v is None:
raise RuntimeError("You need to specify a version number: fab latest:x.x.x")
if exists("/www/bokeh/en/%s" % v):
# switch the current symlink to new docs
run("rm /www/bokeh/en/latest")
run("ln -s /www/bokeh/en/%s /www/bokeh/en/latest" % v)
run("echo %s > /www/bokeh/en/latest/version.txt" % v)
else:
raise RuntimeError("We did not detect a %s docs version, please use fab deploy:%s first." % (v, v))