<s> import os <EOL> import sys <EOL> from fabric . api import * <EOL> from fabtastic import db <EOL> from fabtastic . fabric . util import _current_host_has_role <EOL> def get_remote_db ( roles = '<STR_LIT>' ) : <EOL> """<STR_LIT>""" <EOL> if _current_host_has_role ( roles ) : <EOL> dump_filename = db . util . get_db_dump_filename ( ) <EOL> dump_path = os . path . join ( env . REMOTE_CODEBASE_PATH , dump_filename ) <EOL> with cd ( env . REMOTE_CODEBASE_PATH ) : <EOL> run ( "<STR_LIT>" % ( <EOL> env . REMOTE_VIRTUALENV_NAME , <EOL> dump_filename ) ) <EOL> get ( dump_path , dump_filename ) <EOL> run ( "<STR_LIT>" % dump_filename ) <EOL> new_filename = '<STR_LIT>' % ( dump_filename , env [ '<STR_LIT:host>' ] ) <EOL> local ( '<STR_LIT>' % ( new_filename , dump_filename ) ) <EOL> sys . exit ( <NUM_LIT:0> ) <EOL> def sync_to_remote_db ( roles = '<STR_LIT>' ) : <EOL> """<STR_LIT>""" <EOL> if _current_host_has_role ( roles ) : <EOL> dump_filename = db . util . get_db_dump_filename ( ) <EOL> dump_path = os . path . join ( env . REMOTE_CODEBASE_PATH , dump_filename ) <EOL> with cd ( env . REMOTE_CODEBASE_PATH ) : <EOL> run ( "<STR_LIT>" % ( <EOL> env . REMOTE_VIRTUALENV_NAME , <EOL> dump_filename ) ) <EOL> get ( dump_path , dump_filename ) <EOL> run ( "<STR_LIT>" % dump_filename ) <EOL> filename_with_hostname = '<STR_LIT>' % ( dump_filename , env [ '<STR_LIT:host>' ] ) <EOL> if os . path . exists ( filename_with_hostname ) : <EOL> local ( '<STR_LIT>' % ( filename_with_hostname , dump_filename ) ) <EOL> local ( '<STR_LIT>' % dump_filename , capture = False ) <EOL> local ( '<STR_LIT>' % dump_filename ) <EOL> sys . exit ( <NUM_LIT:0> ) <EOL> def flush_cache ( roles = [ '<STR_LIT>' , '<STR_LIT>' ] ) : <EOL> """<STR_LIT>""" <EOL> if _current_host_has_role ( roles ) : <EOL> print ( "<STR_LIT>" ) <EOL> with cd ( env . REMOTE_CODEBASE_PATH ) : <EOL> run ( "<STR_LIT>" % env . REMOTE_VIRTUALENV_NAME ) <EOL> def pip_update_reqs ( roles = [ '<STR_LIT>' , '<STR_LIT>' ] ) : <EOL> """<STR_LIT>""" <EOL> if _current_host_has_role ( roles ) : <EOL> print ( "<STR_LIT>" ) <EOL> with cd ( env . REMOTE_CODEBASE_PATH ) : <EOL> run ( "<STR_LIT>" % env . REMOTE_VIRTUALENV_NAME ) <EOL> def fabtastic_update ( roles = [ '<STR_LIT>' , '<STR_LIT>' ] ) : <EOL> """<STR_LIT>""" <EOL> if _current_host_has_role ( roles ) : <EOL> print ( "<STR_LIT>" ) <EOL> with cd ( env . REMOTE_CODEBASE_PATH ) : <EOL> run ( "<STR_LIT>" % env . REMOTE_VIRTUALENV_NAME ) <EOL> def collectstatic ( roles = '<STR_LIT>' ) : <EOL> """<STR_LIT>""" <EOL> if _current_host_has_role ( roles ) and not env . already_media_synced : <EOL> print ( "<STR_LIT>" ) <EOL> with cd ( env . REMOTE_CODEBASE_PATH ) : <EOL> run ( "<STR_LIT>" % env . REMOTE_VIRTUALENV_NAME ) <EOL> env . already_media_synced = True </s>
