def _find_python_traceback(lines):
 all_tb_lines = []
 tb_lines = []
 non_tb_lines = []
 in_traceback = False
 for line in lines:
  line = to_string(line)
  if in_traceback:
   tb_lines.append(line)
   if (line.lstrip() == line):
    in_traceback = False
    if line.startswith('subprocess.CalledProcessError'):
     all_tb_lines += non_tb_lines
    all_tb_lines += tb_lines
    tb_lines = []
    non_tb_lines = []
  elif line.startswith('Traceback (most recent call last):'):
   tb_lines.append(line)
   in_traceback = True
  else:
   non_tb_lines.append(line)
 if all_tb_lines:
  return all_tb_lines
 else:
  return None

def _find_python_traceback ( lines ) : all_tb_lines = [ ] tb_lines = [ ] non_tb_lines = [ ] in_traceback = False for line in lines : line = to_string ( line ) if in_traceback : tb_lines . append ( line ) if ( line . lstrip ( ) == line ) : in_traceback = False if line . startswith ( 'subprocess.CalledProcessError' ) : all_tb_lines += non_tb_lines all_tb_lines += tb_lines tb_lines = [ ] non_tb_lines = [ ] elif line . startswith ( 'Traceback (most recent call last):' ) : tb_lines . append ( line ) in_traceback = True else : non_tb_lines . append ( line ) if all_tb_lines : return all_tb_lines else : return None
scan subprocess stderr for python traceback .