<s> """<STR_LIT>""" <EOL> from __future__ import division <EOL> import os <EOL> import subprocess <EOL> __all__ = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> def executable_is_in_path ( filename ) : <EOL> """<STR_LIT>""" <EOL> pathlist = os . environ [ '<STR_LIT>' ] . split ( os . pathsep ) + [ "<STR_LIT:.>" ] <EOL> for path in pathlist : <EOL> fullpath = os . path . join ( path , filename ) <EOL> if os . path . isfile ( fullpath ) : <EOL> return True <EOL> return False <EOL> def list2cmdline ( lst ) : <EOL> for el in lst : <EOL> assert isinstance ( el , basestring ) <EOL> return subprocess . list2cmdline ( lst ) <EOL> def execute_cmdline ( lst , output ) : <EOL> """<STR_LIT>""" <EOL> process = subprocess . Popen ( lst , shell = False , <EOL> stdin = subprocess . PIPE , <EOL> stdout = subprocess . PIPE , <EOL> stderr = subprocess . STDOUT , <EOL> close_fds = True ) <EOL> result = process . wait ( ) <EOL> output . extend ( process . stdout . readlines ( ) ) <EOL> return result <EOL> def get_executable_path ( executable_name ) : <EOL> """<STR_LIT>""" <EOL> pathlist = os . environ [ '<STR_LIT>' ] . split ( os . pathsep ) <EOL> for path in pathlist : <EOL> fullpath = os . path . join ( path , executable_name ) <EOL> if os . path . isfile ( fullpath ) : <EOL> return os . path . abspath ( fullpath ) <EOL> def execute_piped_cmdlines ( cmd_list_list ) : <EOL> stdin = subprocess . PIPE <EOL> for cmd_list in cmd_list_list : <EOL> cmd_line = list2cmdline ( cmd_list ) <EOL> process = subprocess . Popen ( cmd_line , shell = True , <EOL> stdin = stdin , <EOL> stdout = subprocess . PIPE , <EOL> stderr = subprocess . PIPE , <EOL> close_fds = True ) <EOL> stdin = process . stdout <EOL> ( output , errs ) = process . communicate ( ) <EOL> result = process . returncode <EOL> return ( result , output , errs ) <EOL> def execute_cmdline2 ( cmd_list ) : <EOL> return execute_piped_cmdlines ( [ cmd_list ] ) </s>
