<s> """<STR_LIT>""" <EOL> import os <EOL> import os . path <EOL> import re <EOL> import shutil <EOL> import subprocess <EOL> import sys <EOL> import time <EOL> BUILD_PDF = True <EOL> BUILD_HTML = False <EOL> PATH_TO_VISTRAILS_GIT = os . path . realpath ( os . path . join ( os . path . dirname ( os . path . abspath ( __file__ ) ) , '<STR_LIT:..>' ) ) <EOL> HTML_FOLDER = None <EOL> PDF_FILE = os . path . join ( PATH_TO_VISTRAILS_GIT , "<STR_LIT>" , "<STR_LIT>" ) <EOL> PERFORM_GIT_PULL = False <EOL> USERSGUIDE_SUBPATH = [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> GIT_PULL_CMD = [ "<STR_LIT>" , "<STR_LIT>" ] <EOL> BUILD_HTML_SUBPATH = [ "<STR_LIT>" , "<STR_LIT:html>" ] <EOL> BUILD_LATEX_SUBPATH = [ "<STR_LIT>" , "<STR_LIT>" ] <EOL> PDF_BUILD_NAME = "<STR_LIT>" <EOL> if len ( sys . argv ) > <NUM_LIT:1> : <EOL> PDF_FILE = os . path . abspath ( sys . argv [ <NUM_LIT:1> ] ) <EOL> if PDF_FILE [ - <NUM_LIT:4> : ] != '<STR_LIT>' : <EOL> PDF_FILE = os . path . join ( PDF_FILE , PDF_BUILD_NAME ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> if ( PATH_TO_VISTRAILS_GIT is not None and <EOL> os . path . exists ( PATH_TO_VISTRAILS_GIT ) ) : <EOL> current_folder = os . getcwd ( ) <EOL> if PERFORM_GIT_PULL : <EOL> print "<STR_LIT>" % PATH_TO_VISTRAILS_GIT <EOL> os . chdir ( PATH_TO_VISTRAILS_GIT ) <EOL> proc = subprocess . Popen ( GIT_PULL_CMD , <EOL> stdin = subprocess . PIPE , <EOL> stdout = subprocess . PIPE , <EOL> stderr = subprocess . STDOUT ) <EOL> proc . wait ( ) <EOL> if proc . returncode != <NUM_LIT:0> : <EOL> print "<STR_LIT>" <EOL> if proc . stdout : <EOL> print proc . stdout . readlines ( ) <EOL> env = os . environ . copy ( ) <EOL> env [ '<STR_LIT>' ] = PATH_TO_VISTRAILS_GIT <EOL> os . chdir ( os . path . join ( PATH_TO_VISTRAILS_GIT , <EOL> * USERSGUIDE_SUBPATH ) ) <EOL> print "<STR_LIT>" % os . getcwd ( ) <EOL> if BUILD_HTML : <EOL> print "<STR_LIT>" <EOL> proc = subprocess . Popen ( [ "<STR_LIT>" , "<STR_LIT:html>" ] , <EOL> stdin = subprocess . PIPE , <EOL> stdout = subprocess . PIPE , <EOL> stderr = subprocess . STDOUT , <EOL> env = env ) <EOL> proc . wait ( ) <EOL> if proc . returncode != <NUM_LIT:0> : <EOL> print "<STR_LIT>" <EOL> if proc . stdout : <EOL> print proc . stdout . readlines ( ) <EOL> else : <EOL> if HTML_FOLDER is not None : <EOL> if os . path . exists ( HTML_FOLDER ) : <EOL> shutil . rmtree ( HTML_FOLDER ) <EOL> html_build = os . path . join ( os . getcwd ( ) , <EOL> * BUILD_HTML_SUBPATH ) <EOL> shutil . move ( html_build , HTML_FOLDER ) <EOL> if BUILD_PDF : <EOL> print "<STR_LIT>" , PDF_FILE <EOL> print "<STR_LIT>" <EOL> latex_path = os . path . join ( "<STR_LIT:.>" , <EOL> * BUILD_LATEX_SUBPATH ) <EOL> if os . path . exists ( latex_path ) : <EOL> print "<STR_LIT>" % latex_path <EOL> proc = subprocess . Popen ( [ "<STR_LIT>" , "<STR_LIT>" , latex_path ] , <EOL> stdin = subprocess . PIPE , <EOL> stdout = subprocess . PIPE , <EOL> stderr = subprocess . STDOUT ) <EOL> proc . wait ( ) <EOL> print "<STR_LIT>" <EOL> proc = subprocess . Popen ( [ "<STR_LIT>" , "<STR_LIT>" ] , <EOL> stdin = subprocess . PIPE , <EOL> stdout = subprocess . PIPE , <EOL> stderr = subprocess . STDOUT , <EOL> env = env ) <EOL> proc . wait ( ) <EOL> if proc . returncode != <NUM_LIT:0> : <EOL> print "<STR_LIT>" <EOL> if proc . stdout : <EOL> print proc . stdout . readlines ( ) <EOL> else : <EOL> print "<STR_LIT>" <EOL> os . chdir ( os . path . join ( os . getcwd ( ) , <EOL> * BUILD_LATEX_SUBPATH ) ) <EOL> proc = subprocess . Popen ( [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] , <EOL> stdin = subprocess . PIPE , <EOL> stdout = subprocess . PIPE , <EOL> stderr = subprocess . STDOUT , <EOL> env = env ) <EOL> output , error = proc . communicate ( ) <EOL> if proc . returncode != <NUM_LIT:0> : <EOL> print "<STR_LIT>" <EOL> print output , error <EOL> else : <EOL> if PDF_FILE is not None : <EOL> if os . path . exists ( PDF_FILE ) : <EOL> os . unlink ( PDF_FILE ) <EOL> pdf_build = os . path . join ( os . getcwd ( ) , <EOL> PDF_BUILD_NAME ) <EOL> shutil . move ( pdf_build , PDF_FILE ) <EOL> os . chdir ( current_folder ) <EOL> print "<STR_LIT>" <EOL> else : <EOL> print "<STR_LIT>" </s>
