<s> from django . conf import settings <EOL> from django . core . management . base import CommandError <EOL> from fabric import state <EOL> from fabric . api import cd , env , run <EOL> from fabric . network import denormalize , disconnect_all <EOL> import os . path , time <EOL> DJANGO_DEPLOY_ROOT = os . path . abspath ( os . path . dirname ( __file__ ) ) <EOL> PROJECTS_PATH = "<STR_LIT>" <EOL> VIRTUALENVS_PATH = "<STR_LIT>" <EOL> def fab_task ( func ) : <EOL> """<STR_LIT>""" <EOL> def new_func ( * args , ** kwargs ) : <EOL> setup_env ( ) <EOL> val = func ( * args , ** kwargs ) <EOL> disconnect_all ( ) <EOL> return val <EOL> return new_func <EOL> def get_required_val ( dictionary , key , err_msg ) : <EOL> """<STR_LIT>""" <EOL> value = dictionary . get ( key , None ) <EOL> if value is None : <EOL> raise CommandError ( err_msg ) <EOL> return value <EOL> def manage ( command ) : <EOL> """<STR_LIT>""" <EOL> with cd ( env . project_root ) : <EOL> run ( "<STR_LIT>" % ( env . project_name , command ) ) <EOL> def setup_env ( ) : <EOL> deploys = getattr ( settings , "<STR_LIT>" , None ) <EOL> if not deploys : <EOL> raise CommandError ( "<STR_LIT>" ) <EOL> default = get_required_val ( deploys , "<STR_LIT:default>" , "<STR_LIT>" ) <EOL> domain = get_required_val ( default , "<STR_LIT>" , "<STR_LIT>" ) <EOL> host = get_required_val ( default , "<STR_LIT>" , "<STR_LIT>" ) <EOL> name = get_required_val ( default , "<STR_LIT>" , "<STR_LIT>" ) <EOL> user = get_required_val ( default , "<STR_LIT>" , "<STR_LIT>" ) <EOL> password = default . get ( "<STR_LIT>" , None ) <EOL> branch = default . get ( "<STR_LIT>" , None ) or "<STR_LIT>" <EOL> env . project_domain = domain <EOL> env . hosts = [ host ] <EOL> env . host_string = host <EOL> env . project_name = name <EOL> env . user = user <EOL> env . password = password <EOL> env . project_branch = branch <EOL> env . deploy_time = run ( "<STR_LIT>" ) <EOL> env . uses_south = "<STR_LIT>" in settings . INSTALLED_APPS <EOL> env . deploy_root = os . path . join ( PROJECTS_PATH , env . project_name ) <EOL> env . project_root = os . path . join ( PROJECTS_PATH , env . project_name , env . project_name ) <EOL> env . virtualenv_dir = os . path . join ( VIRTUALENVS_PATH , env . project_name ) <EOL> def script ( file_path ) : <EOL> return os . path . join ( DJANGO_DEPLOY_ROOT , "<STR_LIT>" , file_path ) <EOL> def template ( file_path ) : <EOL> return os . path . join ( DJANGO_DEPLOY_ROOT , "<STR_LIT>" , file_path ) </s>
