2 """ Karmaworld Fabric management script
3 Finals Club (c) 2013"""
7 from fabric.api import cd, env, lcd, prefix, run, task, local, settings
8 from fabvenv import virtualenv
11 env.proj_repo = 'git@github.com:FinalsClub/karmaworld.git'
14 ######## Define host(s)
18 Connection information for the local machine
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)
25 env.reqs = 'reqs/dev.txt'
26 env.confs = 'confs/stag/'
28 env.run = virtenv_exec
33 env.hosts = ['beta.karmanotes.org']
34 env.proj_root = '/var/www/karmaworld'
35 env.proj_dir = '/var/www/karmaworld'
36 env.reqs = 'reqs/prod.txt'
37 env.confs = 'confs/beta/'
39 env.run = virtenv_exec
41 ######## Run Commands in Virutal Environment
42 def virtenv_exec(command):
43 with virtualenv('%s/%s' % (env.proj_dir, env.branch)):
48 ######## Sync database
51 env.run('%s/manage.py syncdb --noinput --migrate' % env.proj_dir )
54 ####### Collect Static Files
57 env.run('%s/manage.py collectstatic --noinput' % env.proj_dir )
59 ####### Run Dev Server
62 env.run('%s/manage.py runserver' % env.proj_dir )
64 ####### Create Virtual Environment
66 def make_virtualenv():
67 run('virtualenv %s/%s' % (env.proj_dir, env.branch))
68 env.run('pip install -r %s/reqs/dev.txt' % env.proj_dir )
72 def start_supervisord():
73 config_file = '%s/%ssupervisord.conf' % (env.proj_dir,env.confs)
74 env.run('supervisord -c %s' % config_file)
78 env.run('cd %s; git pull' % env.proj_dir)