1 """Management utilities."""
4 from contextlib import contextmanager as _contextmanager
6 from fabric.api import cd, env, prefix, run, settings, task
10 env.proj_repo = 'git@github.com:FinalsClub/karmaworld.git'
11 env.virtualenv = 'venv-kw'
12 env.activate = 'workon %s' % env.virtualenv
13 ########## END GLOBALS
20 Changes to the proj_dir and activates the virtualenv
22 with cd(env.proj_dir):
23 with prefix(env.activate):
26 ########## END HELPERS
28 ########## ENVIRONMENTS
32 Beta connection information
35 env.hosts = ['beta.karmanotes.org']
36 env.proj_root = '/var/www/karmaworld'
37 env.proj_dir = os.path.join(env.proj_root, 'karmaworld')
43 Production connection information
46 env.hosts = ['karmanotes.org']
47 env.proj_root = '/var/www/karmaworld'
48 env.proj_dir = os.path.join(env.proj_root, 'karmaworld')
49 ########## END ENVIRONMENTS
52 ########## DATABASE MANAGEMENT
55 """Runs syncdb (along with any pending South migrations)"""
56 run('python manage.py syncdb --noinput --migrate')
57 ########## END DATABASE MANAGEMENT
60 ########## FILE MANAGEMENT
63 """Collect all static files, and copy them to S3 for production usage."""
64 run('python manage.py collectstatic --noinput')
65 ########## END FILE MANAGEMENT
71 def make_virtualenv():
73 Creates a virtualenv on the remote host
75 run('mkvirtualenv %s' % env.virtualenv)
81 Makes sure all packages listed in requirements are installed
84 with cd(env.proj_dir):
85 run('pip install -r requirements/production.pip')
91 Clones the project from the central repository
93 run('git clone %s %s' % (env.proj_repo, env.proj_dir))
99 Pulls the latest changes from the central repository
101 with cd(env.proj_dir):
108 Creates or updates the project, runs migrations, installs dependencies.
111 with settings(warn_only=True):
112 if run('test -d %s' % env.proj_dir).failed:
113 # first_deploy var is for initial deploy information
116 if run('test -d $WORKON_HOME/%s' % env.virtualenv).failed:
124 ########## END COMMANDS