<s> import logging <EOL> import os <EOL> import subprocess <EOL> import sys <EOL> def execute ( command , <EOL> env = None , <EOL> split_lines = False , <EOL> ignore_errors = False , <EOL> extra_ignore_errors = ( ) , <EOL> translate_newlines = True , <EOL> with_errors = True , <EOL> none_on_ignored_error = False ) : <EOL> """<STR_LIT>""" <EOL> if isinstance ( command , list ) : <EOL> logging . debug ( subprocess . list2cmdline ( command ) ) <EOL> else : <EOL> logging . debug ( command ) <EOL> if env : <EOL> env . update ( os . environ ) <EOL> else : <EOL> env = os . environ . copy ( ) <EOL> env [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> env [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> if with_errors : <EOL> errors_output = subprocess . STDOUT <EOL> else : <EOL> errors_output = subprocess . PIPE <EOL> if sys . platform . startswith ( '<STR_LIT>' ) : <EOL> p = subprocess . Popen ( command , <EOL> stdin = subprocess . PIPE , <EOL> stdout = subprocess . PIPE , <EOL> stderr = errors_output , <EOL> shell = False , <EOL> universal_newlines = translate_newlines , <EOL> env = env ) <EOL> else : <EOL> p = subprocess . Popen ( command , <EOL> stdin = subprocess . PIPE , <EOL> stdout = subprocess . PIPE , <EOL> stderr = errors_output , <EOL> shell = False , <EOL> close_fds = True , <EOL> universal_newlines = translate_newlines , <EOL> env = env ) <EOL> if split_lines : <EOL> data = p . stdout . readlines ( ) <EOL> else : <EOL> data = p . stdout . read ( ) <EOL> rc = p . wait ( ) <EOL> if rc and not ignore_errors and rc not in extra_ignore_errors : <EOL> raise Exception ( '<STR_LIT>' % ( command , data ) ) <EOL> if rc and none_on_ignored_error : <EOL> return None <EOL> return data </s>
