def run_shell_cmd(exe, stdout=subprocess.PIPE, stderr=subprocess.PIPE):
 p = subprocess.Popen(exe, stdout=stdout, stderr=stderr)
 (last_stdout_str, last_stderr_str) = p.communicate()
 last_stdout = last_stdout_str.split('\n')
 if (LOG_LINE_PREFIX in last_stdout_str):
  log('')
  for line in last_stdout:
   if line.startswith(LOG_LINE_PREFIX):
    log(('INFO: %s' % line[len(LOG_LINE_PREFIX):]))
  log('')
 result = ('%s%s' % (last_stdout_str, last_stderr_str))
 if (p.returncode != 0):
  raise Exception(('Error %s\n%s' % (p.returncode, result)))
 return result

def run_shell_cmd ( exe , stdout = subprocess . PIPE , stderr = subprocess . PIPE ) : p = subprocess . Popen ( exe , stdout = stdout , stderr = stderr ) ( last_stdout_str , last_stderr_str ) = p . communicate ( ) last_stdout = last_stdout_str . split ( '\n' ) if ( LOG_LINE_PREFIX in last_stdout_str ) : log ( '' ) for line in last_stdout : if line . startswith ( LOG_LINE_PREFIX ) : log ( ( 'INFO: %s' % line [ len ( LOG_LINE_PREFIX ) : ] ) ) log ( '' ) result = ( '%s%s' % ( last_stdout_str , last_stderr_str ) ) if ( p . returncode != 0 ) : raise Exception ( ( 'Error %s\n%s' % ( p . returncode , result ) ) ) return result
runs a shell command and captures the stdout and stderr output .