<s> """<STR_LIT>""" <EOL> import argparse <EOL> import datetime <EOL> import os <EOL> import shutil <EOL> import subprocess <EOL> import common <EOL> _PARSER = argparse . ArgumentParser ( ) <EOL> _PARSER . add_argument ( <EOL> '<STR_LIT>' , help = '<STR_LIT>' , type = str ) <EOL> PARSED_ARGS = _PARSER . parse_args ( ) <EOL> if PARSED_ARGS . app_name : <EOL> APP_NAME = PARSED_ARGS . app_name <EOL> else : <EOL> raise Exception ( '<STR_LIT>' ) <EOL> CURRENT_DATETIME = datetime . datetime . utcnow ( ) <EOL> RELEASE_DIR_NAME = '<STR_LIT>' % ( <EOL> '<STR_LIT:->' . join ( '<STR_LIT:->' . join ( APP_NAME . split ( '<STR_LIT:.>' ) ) . split ( '<STR_LIT::>' ) ) , <EOL> CURRENT_DATETIME . strftime ( '<STR_LIT>' ) ) <EOL> RELEASE_DIR_PATH = os . path . join ( os . getcwd ( ) , '<STR_LIT:..>' , RELEASE_DIR_NAME ) <EOL> APPCFG_PATH = os . path . join ( <EOL> '<STR_LIT:..>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' ) <EOL> LOG_FILE_PATH = os . path . join ( '<STR_LIT:..>' , '<STR_LIT>' ) <EOL> THIRD_PARTY_DIR = os . path . join ( '<STR_LIT:.>' , '<STR_LIT>' ) <EOL> DEPLOY_DATA_PATH = os . path . join ( os . getcwd ( ) , '<STR_LIT:..>' , '<STR_LIT>' , APP_NAME ) <EOL> SPLASH_PAGE_FILES = [ '<STR_LIT>' ] <EOL> IMAGE_DIRS = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> def preprocess_release ( ) : <EOL> """<STR_LIT>""" <EOL> f = open ( '<STR_LIT>' , '<STR_LIT:r>' ) <EOL> content = f . read ( ) <EOL> os . remove ( '<STR_LIT>' ) <EOL> content = content . replace ( '<STR_LIT>' , APP_NAME ) <EOL> d = open ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> d . write ( content ) <EOL> if not os . path . exists ( DEPLOY_DATA_PATH ) : <EOL> raise Exception ( <EOL> '<STR_LIT>' % DEPLOY_DATA_PATH ) <EOL> for filename in SPLASH_PAGE_FILES : <EOL> src = os . path . join ( DEPLOY_DATA_PATH , '<STR_LIT>' , filename ) <EOL> dst = os . path . join ( os . getcwd ( ) , '<STR_LIT>' , '<STR_LIT>' , filename ) <EOL> if not os . path . exists ( src ) : <EOL> raise Exception ( <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' % src ) <EOL> if not os . path . exists ( dst ) : <EOL> raise Exception ( <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' % dst ) <EOL> shutil . copyfile ( src , dst ) <EOL> for dir_name in IMAGE_DIRS : <EOL> src_dir = os . path . join ( DEPLOY_DATA_PATH , '<STR_LIT>' , dir_name ) <EOL> dst_dir = os . path . join ( os . getcwd ( ) , '<STR_LIT>' , '<STR_LIT>' , dir_name ) <EOL> if not os . path . exists ( src_dir ) : <EOL> raise Exception ( <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' % src_dir ) <EOL> common . ensure_directory_exists ( dst_dir ) <EOL> for filename in os . listdir ( src_dir ) : <EOL> src = os . path . join ( src_dir , filename ) <EOL> dst = os . path . join ( dst_dir , filename ) <EOL> shutil . copyfile ( src , dst ) <EOL> def _execute_deployment ( ) : <EOL> common . require_cwd_to_be_oppia ( ) <EOL> current_git_revision = subprocess . check_output ( <EOL> [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ) . strip ( ) <EOL> print '<STR_LIT>' <EOL> print '<STR_LIT>' <EOL> if not os . path . exists ( THIRD_PARTY_DIR ) : <EOL> raise Exception ( <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' % THIRD_PARTY_DIR ) <EOL> print '<STR_LIT>' <EOL> common . ensure_directory_exists ( os . path . dirname ( RELEASE_DIR_PATH ) ) <EOL> print '<STR_LIT>' <EOL> shutil . copytree ( <EOL> os . getcwd ( ) , RELEASE_DIR_PATH , ignore = shutil . ignore_patterns ( '<STR_LIT>' ) ) <EOL> with common . CD ( RELEASE_DIR_PATH ) : <EOL> if not os . getcwd ( ) . endswith ( RELEASE_DIR_NAME ) : <EOL> raise Exception ( <EOL> '<STR_LIT>' <EOL> % os . getcwd ( ) ) <EOL> print '<STR_LIT>' % os . getcwd ( ) <EOL> print '<STR_LIT>' <EOL> preprocess_release ( ) <EOL> print '<STR_LIT>' <EOL> subprocess . check_output ( [ '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> print '<STR_LIT>' <EOL> tests_proc = subprocess . Popen ( [ <EOL> '<STR_LIT>' , os . path . join ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> ] , stdout = subprocess . PIPE ) <EOL> tests_stdout , tests_stderr = tests_proc . communicate ( ) <EOL> print tests_stdout <EOL> print tests_stderr <EOL> if tests_proc . returncode != <NUM_LIT:0> : <EOL> raise Exception ( '<STR_LIT>' ) <EOL> subprocess . check_output ( [ APPCFG_PATH , '<STR_LIT>' , '<STR_LIT:.>' , '<STR_LIT>' ] ) <EOL> common . ensure_directory_exists ( os . path . dirname ( LOG_FILE_PATH ) ) <EOL> with open ( LOG_FILE_PATH , '<STR_LIT:a>' ) as log_file : <EOL> log_file . write ( <EOL> '<STR_LIT>' % ( <EOL> APP_NAME , CURRENT_DATETIME . strftime ( '<STR_LIT>' ) , <EOL> current_git_revision ) ) <EOL> print '<STR_LIT>' <EOL> print '<STR_LIT>' <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> _execute_deployment ( ) </s>
