-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathfabfile.py
67 lines (51 loc) · 1.79 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
#!/bin/env python
from fabric.api import local, run, env, cd
from ConfigParser import ConfigParser
usage = """
Usage (in the directory containing (%s) ...):
fab [stage|run_staged|deploy|run_deployed]
DO NOT RUN THIS FILE (%s) AS A SCRIPT ON ITS OWN!
e.g. $ fab run_stage
""" % (__file__, __file__)
# DON'T TOUCH THESE
env.MY_NAME = ""
env.WIN_SHARED_DRIVE = ""
env.STAGING_DIR = "staging/%s"
env.WIN_STAGING_DIR = "%s/%s"
env.HOST_STAGING_DIR = "/home/kushu/%s"
env.hosts = ["kushu@kushu"]
def get_user_settings():
conf = ConfigParser()
if (conf.read("fabconfig") == []):
while (env.MY_NAME == ""):
env.MY_NAME = raw_input("What is your caplin username? ")
env.WIN_SHARED_DRIVE = raw_input("What drive is the Kushu folder mounted on, e.g. E:, F:? [default: 'K:']")
if not env.WIN_SHARED_DRIVE:
env.WIN_SHARED_DRIVE = "K:"
else:
env.MY_NAME = conf.get("cred", "caplin_name")
env.WIN_SHARED_DRIVE = conf.get("fs", "kushu_drive")
env.STAGING_PORT = conf.get("cred", "staging_port")
env.STAGING_DIR = env.STAGING_DIR % env.MY_NAME
env.WIN_STAGING_DIR = env.WIN_STAGING_DIR % (env.WIN_SHARED_DRIVE, env.STAGING_DIR)
env.HOST_STAGING_DIR = env.HOST_STAGING_DIR % env.STAGING_DIR
def stage():
get_user_settings()
local("cp -rpvf models.js routes.js app.js leitner.js package.json test public views %s" % env.WIN_STAGING_DIR)
def run_staged(port=None):
get_user_settings()
if port:
env.STAGING_PORT = port
with cd("%s" % env.HOST_STAGING_DIR):
run("npm install")
run("forever -w app.js %s" % (env.STAGING_PORT))
def deploy():
print "NOTE: Only work submitted to Perforce is deployed to Kushu server!"
run("p4 sync")
run("cd ~/www && npm install")
def run_deployed():
run("cd ~/www && node app.js")
def test():
run("cd ~/www && nodeunit test")
if __name__ == "__main__":
print usage