|
|
|
|
@ -1,7 +1,7 @@ |
|
|
|
|
# -*- coding: utf-8 -*- |
|
|
|
|
from os.path import join, basename |
|
|
|
|
from collections import namedtuple, OrderedDict |
|
|
|
|
|
|
|
|
|
import re |
|
|
|
|
from fabric.api import * |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -24,7 +24,7 @@ services = ['nginx', 'apache2'] |
|
|
|
|
|
|
|
|
|
stages = {} |
|
|
|
|
tickets = {} |
|
|
|
|
|
|
|
|
|
commands = {} |
|
|
|
|
|
|
|
|
|
def stage(stage_num): |
|
|
|
|
def ticket(func): |
|
|
|
|
@ -35,19 +35,37 @@ def stage(stage_num): |
|
|
|
|
return func |
|
|
|
|
return ticket |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# command_pattern |
|
|
|
|
# cp = re.compile('^python manage.py (?P<command>\w+)$') |
|
|
|
|
cp = re.compile('^(?P<command>\w+)$') |
|
|
|
|
|
|
|
|
|
def register_command(command_string): |
|
|
|
|
command = cp.match(command_string).group('command') |
|
|
|
|
if not command: |
|
|
|
|
raise ValueError('Invalid command string {command_string}'.format(command_string=command_string)) |
|
|
|
|
def func(): |
|
|
|
|
with cd(REMOTE_HOME_DIR): |
|
|
|
|
run('python manage.py ' + command) |
|
|
|
|
commands.update({command: func}) |
|
|
|
|
|
|
|
|
|
# run command |
|
|
|
|
def rc(command): |
|
|
|
|
if command in commands and callable(commands[command]): |
|
|
|
|
commands[command]() |
|
|
|
|
else: |
|
|
|
|
raise ValueError('Command {command} is not callable'.format(command=command)) |
|
|
|
|
|
|
|
|
|
def set_host(host): |
|
|
|
|
env.hosts = env.roledefs.get(host) |
|
|
|
|
env.role = host |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def dev(): |
|
|
|
|
set_host('dev') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def prod(): |
|
|
|
|
set_host('prod') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_configs(): |
|
|
|
|
localdir = join(LOCAL_HOME_DIR, 'support/', env.role) |
|
|
|
|
get(nginx_conf, localdir) |
|
|
|
|
@ -109,9 +127,12 @@ def stage_init(stage_num): |
|
|
|
|
def t1451(): |
|
|
|
|
with cd(REMOTE_HOME_DIR): |
|
|
|
|
run('python manage.py migrate expobanner') |
|
|
|
|
run('python manage.py migrate banner_log_update_old') |
|
|
|
|
run('python manage.py migrate banner_log_update') |
|
|
|
|
|
|
|
|
|
rc('banner_log_update_old') |
|
|
|
|
rc('banner_log_update') |
|
|
|
|
|
|
|
|
|
register_command('banner_log_update_old') |
|
|
|
|
register_command('banner_log_update') |
|
|
|
|
|
|
|
|
|
# def stage3_pre_final(): |
|
|
|
|
# with cd(REMOTE_HOME_DIR): |
|
|
|
|
|