forked from toolness/hackasaurus-puppet-data
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathhackpub.py
49 lines (38 loc) · 1.13 KB
/
hackpub.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
from StringIO import StringIO
from fabric.api import *
from fabric.contrib.files import exists
from secrets import load_secrets
PROJ_ROOT = '/var/hackpub.hackasaurus.org'
REPO_URL = "git://github.com/hackasaurus/hackpub.git"
LOCAL_SETTINGS = """\
from settings import *
ENABLE_PPX = True
AWS_ACCESS_KEY_ID = '%(hackpub_aws_access_key_id)s'
AWS_SECRET_ACCESS_KEY = '%(hackpub_aws_secret_access_key)s'
BUCKET_NAME = '%(hackpub_bucket_name)s'
PUBLISH_DOMAIN = '%(hackpub_publish_domain)s'
EXTRA_BUCKETS['lovebomb'] = subclass_settings(globals(),
BUCKET_NAME='cmon.lovebomb.me',
PUBLISH_DOMAIN='cmon.lovebomb.me'
)
"""
def run_manage_cmd(cmd):
with cd(PROJ_ROOT):
run('python manage.py %s' % cmd)
@task
def deploy():
if exists(PROJ_ROOT):
update()
else:
clone()
settings = StringIO(LOCAL_SETTINGS % load_secrets(env['host']))
put(settings, '%s/settings_local.py' % PROJ_ROOT)
run_manage_cmd('test')
run('touch %s/wsgi/hackpub.wsgi' % PROJ_ROOT)
@task
def update():
with cd(PROJ_ROOT):
run('git pull')
@task
def clone():
run('git clone %s %s' % (REPO_URL, PROJ_ROOT))