def run_3to2(args=None):
args = BASE_ARGS_3TO2 if args is None else BASE_ARGS_3TO2 + args<EOL>try:<EOL><INDENT>proc = subprocess.Popen(['<STR_LIT>'] + args, stderr=subprocess.PIPE)<EOL><DEDENT>except OSError:<EOL><INDENT>for path in glob.glob('<STR_LIT>'):<EOL><INDENT>if os.path.isdir(path) and path not in sys.path:<EOL><INDENT>sys.path.append(path)<EOL><DEDENT><DEDENT>try:<EOL><INDENT>from lib3to2.main import main as lib3to2_main<EOL><DEDENT>except ImportError:<EOL><INDENT>raise OSError('<STR_LIT>')<EOL><DEDENT>else:<EOL><INDENT>if lib3to2_main('<STR_LIT>', args):<EOL><INDENT>raise Exception('<STR_LIT>')<EOL><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>num_errors = <NUM_LIT:0><EOL>while proc.poll() is None:<EOL><INDENT>line = proc.stderr.readline()<EOL>sys.stderr.write(line)<EOL>num_errors += line.count('<STR_LIT>')<EOL><DEDENT>if proc.returncode or num_errors:<EOL><INDENT>raise Exception('<STR_LIT>')<EOL><DEDENT><DEDENT>
Convert Python files using lib3to2.