Added new fabfile.py to branch fabric
[oweals/karmaworld.git] / fabfile.py
1
2 """ Karmaworld Fabric management script
3     Finals Club (c) 2013"""
4
5 import os
6
7 from fabric.api import cd, env, lcd, prefix, run, task, local, settings
8 from fabvenv import virtualenv
9
10 ######### GLOBAL
11 env.proj_repo = 'git@github.com:FinalsClub/karmaworld.git'
12
13
14 ######## Define host(s)
15 @task
16 def here():
17     """
18 Connection information for the local machine
19 """
20
21     # This is required for the same reason as above
22     env.proj_dir = os.getcwd()
23     env.proj_root = os.path.dirname(env.proj_dir)
24     env.cd = lcd
25     env.reqs = 'reqs/dev.txt'
26     env.confs = 'confs/stag/'
27     env.branch = 'beta'
28     env.run = virtenv_exec
29
30 ######## Run Commands in Virutal Environment
31 def virtenv_exec(command):
32         with virtualenv('%s/%s' % (env.proj_dir, env.branch)):
33                 run('%s' % (command))
34
35
36
37 ######## Sync database
38 @task
39 def syncdb():
40         env.run('%s/manage.py syncdb --noinput --migrate' % env.proj_dir )
41
42
43 ####### Collect Static Files
44 @task
45 def collect_static():
46         env.run('%s/manage.py collectstatic --noinput' % env.proj_dir ) 
47
48 ####### Run Dev Server
49 @task
50 def dev_server():
51         env.run('%s/manage.py runserver' % env.proj_dir )       
52
53 ####### Create Virtual Environment
54 @task
55 def make_virtualenv():
56         run('virtualenv %s/%s' % (env.proj_dir, env.branch))
57         env.run('pip install -r %s/reqs/dev.txt' % env.proj_dir )
58
59 ####### Supervisord
60 @task
61 def start_supervisord():
62         config_file = '%s/%ssupervisord.conf' % (env.proj_dir,env.confs)
63         env.run('supervisord -c %s' % config_file)
64