<s> """<STR_LIT>""" <EOL> import posixpath <EOL> from fabric . api import run , local , env , settings , cd , task <EOL> from fabric . contrib . files import exists <EOL> from fabric . operations import _prefix_commands , _prefix_env_vars <EOL> env . hosts = [ '<STR_LIT>' ] <EOL> env . code_dir = '<STR_LIT>' <EOL> env . project_dir = '<STR_LIT>' <EOL> env . static_root = '<STR_LIT>' <EOL> env . virtualenv = '<STR_LIT>' <EOL> env . code_repo = '<STR_LIT>' <EOL> env . django_settings_module = '<STR_LIT>' <EOL> PYTHON_BIN = "<STR_LIT>" <EOL> PYTHON_PREFIX = "<STR_LIT>" <EOL> PYTHON_FULL_PATH = "<STR_LIT>" % ( PYTHON_PREFIX , PYTHON_BIN ) if PYTHON_PREFIX else PYTHON_BIN <EOL> DJANGO_SERVER_RESTART = False <EOL> def virtualenv ( venv_dir ) : <EOL> """<STR_LIT>""" <EOL> return settings ( venv = venv_dir ) <EOL> def run_venv ( command , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> run ( "<STR_LIT>" % env . virtualenv + "<STR_LIT>" + command , ** kwargs ) <EOL> def install_dependencies ( ) : <EOL> ensure_virtualenv ( ) <EOL> with virtualenv ( env . virtualenv ) : <EOL> with cd ( env . code_dir ) : <EOL> run_venv ( "<STR_LIT>" ) <EOL> def ensure_virtualenv ( ) : <EOL> if exists ( env . virtualenv ) : <EOL> return <EOL> with cd ( env . code_dir ) : <EOL> run ( "<STR_LIT>" % <EOL> ( PYTHON_BIN , env . virtualenv ) ) <EOL> run ( "<STR_LIT>" % <EOL> ( env . project_dir , env . virtualenv , PYTHON_BIN ) ) <EOL> def ensure_src_dir ( ) : <EOL> if not exists ( env . code_dir ) : <EOL> run ( "<STR_LIT>" % env . code_dir ) <EOL> with cd ( env . code_dir ) : <EOL> if not exists ( posixpath . join ( env . code_dir , '<STR_LIT>' ) ) : <EOL> run ( '<STR_LIT>' % ( env . code_repo ) ) <EOL> def push_sources ( ) : <EOL> """<STR_LIT>""" <EOL> ensure_src_dir ( ) <EOL> local ( '<STR_LIT>' ) <EOL> with cd ( env . code_dir ) : <EOL> run ( '<STR_LIT>' ) <EOL> @ task <EOL> def run_tests ( ) : <EOL> """<STR_LIT>""" <EOL> local ( "<STR_LIT>" ) <EOL> @ task <EOL> def version ( ) : <EOL> """<STR_LIT>""" <EOL> with cd ( env . code_dir ) : <EOL> run ( '<STR_LIT>' ) <EOL> @ task <EOL> def uname ( ) : <EOL> """<STR_LIT>""" <EOL> run ( "<STR_LIT>" ) <EOL> @ task <EOL> def webserver_stop ( ) : <EOL> """<STR_LIT>""" <EOL> run ( "<STR_LIT>" ) <EOL> @ task <EOL> def webserver_start ( ) : <EOL> """<STR_LIT>""" <EOL> run ( "<STR_LIT>" ) <EOL> @ task <EOL> def webserver_restart ( ) : <EOL> """<STR_LIT>""" <EOL> if DJANGO_SERVER_RESTART : <EOL> with cd ( env . code_dir ) : <EOL> run ( "<STR_LIT>" % env . project_dir ) <EOL> else : <EOL> with settings ( warn_only = True ) : <EOL> webserver_stop ( ) <EOL> webserver_start ( ) <EOL> def restart ( ) : <EOL> """<STR_LIT>""" <EOL> with cd ( env . code_dir ) : <EOL> run ( "<STR_LIT>" % env . code_dir ) <EOL> def build_static ( ) : <EOL> assert env . static_root . strip ( ) != '<STR_LIT>' and env . static_root . strip ( ) != '<STR_LIT:/>' <EOL> with virtualenv ( env . virtualenv ) : <EOL> with cd ( env . code_dir ) : <EOL> run_venv ( "<STR_LIT>" ) <EOL> run ( "<STR_LIT>" % env . static_root ) <EOL> @ task <EOL> def first_deployment_mode ( ) : <EOL> """<STR_LIT>""" <EOL> env . initial_deploy = True <EOL> @ task <EOL> def update_database ( app = None ) : <EOL> """<STR_LIT>""" <EOL> with virtualenv ( env . virtualenv ) : <EOL> with cd ( env . code_dir ) : <EOL> if getattr ( env , '<STR_LIT>' , False ) : <EOL> run_venv ( "<STR_LIT>" ) <EOL> run_venv ( "<STR_LIT>" ) <EOL> else : <EOL> run_venv ( "<STR_LIT>" ) <EOL> if app : <EOL> run_venv ( "<STR_LIT>" % app ) <EOL> else : <EOL> run_venv ( "<STR_LIT>" ) <EOL> @ task <EOL> def sshagent_run ( cmd ) : <EOL> """<STR_LIT>""" <EOL> wrapped_cmd = _prefix_commands ( _prefix_env_vars ( cmd ) , '<STR_LIT>' ) <EOL> try : <EOL> host , port = env . host_string . split ( '<STR_LIT::>' ) <EOL> return local ( <EOL> "<STR_LIT>" % ( port , env . user , host , wrapped_cmd ) <EOL> ) <EOL> except ValueError : <EOL> return local ( <EOL> "<STR_LIT>" % ( env . user , env . host_string , wrapped_cmd ) <EOL> ) <EOL> @ task <EOL> def deploy ( ) : <EOL> """<STR_LIT>""" <EOL> with settings ( warn_only = True ) : <EOL> webserver_stop ( ) <EOL> push_sources ( ) <EOL> install_dependencies ( ) <EOL> update_database ( ) <EOL> build_static ( ) <EOL> webserver_start ( ) </s>
