-
Notifications
You must be signed in to change notification settings - Fork 0
/
fabfile.py
executable file
·85 lines (59 loc) · 2.16 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#!/usr/bin/python
#
# Copyright 2011 Friday Film Club. All Rights Reserved.
"""Deploy the Friday Film Club application."""
from __future__ import with_statement
__author__ = '[email protected] (Adam McGrath)'
import logging
import os
import re
import sys
from fabric.api import *
APPENGINE_PATH = os.path.abspath(os.environ['APPENGINE_SRC'])
APPENGINE_DEV_APPSERVER = os.path.join(APPENGINE_PATH, 'dev_appserver.py')
APPENGINE_APP_CFG = os.path.join(APPENGINE_PATH, 'appcfg.py')
sys.path.append(APPENGINE_PATH)
import dev_appserver
dev_appserver.fix_sys_path()
env.gae_email = '[email protected]'
env.gae_src = './src'
def deploy(branch='dev', pull_request='false', tag=None):
if pull_request != 'false':
return
version = 'dev' if branch == 'master' else re.sub(r'[\W_]', '-', branch)
if tag:
logging.info('Deploying TAG:%s to prod', tag)
version = 'prod'
else:
logging.info('Deploying VERSION:%s', version)
local('python %s -V %s --oauth2 --oauth2_refresh_token=$OAUTH2_REFRESH_TOKEN update %s' %
(APPENGINE_APP_CFG, version, env.gae_src))
def shell():
with lcd(env.gae_src):
local('python %s/remote_api_shell.py -s ffcapp.appspot.com' %
APPENGINE_PATH)
def run_server(port='8080', clear_datastore=False, send_mail=True):
command = '%s --port %s'
if clear_datastore:
command += ' --clear_datastore'
if send_mail:
command += ' --enable_sendmail=yes'
command += ' %s'
local(command % (APPENGINE_DEV_APPSERVER, port, env.gae_src))
def symlink_requirements():
local('gaenv --lib src/pylib --no-import=true')
def compile_css():
logging.info('Compiling CSS')
local('mkdir -p src/static/css/')
local('lessc --compress src/stylesheets/main.less > src/static/css/main.css')
def compile_js(part=None):
parts = ['template', 'deps', 'quiz', 'leaderboard', 'settings', 'leagueform']
local('mkdir -p src/static/js/')
if part:
parts = [part]
for p in parts:
local('scripts/compilejs.sh %s' % p)
def run_tests():
local('nosetests --cover-html --nocapture --with-coverage --cover-inclusive '
'--with-gae --gae-application=src/ --where=src/tests/ --gae-lib-root=%s'
% APPENGINE_PATH)