def run(files, temp_folder):
try:<EOL><INDENT>import flake8  <EOL><DEDENT>except ImportError:<EOL><INDENT>return NO_FLAKE_MSG<EOL><DEDENT>try:<EOL><INDENT>from flake8.engine import get_style_guide<EOL><DEDENT>except ImportError:<EOL><INDENT>from flake8.api.legacy import get_style_guide<EOL><DEDENT>py_files = filter_python_files(files)<EOL>if not py_files:<EOL><INDENT>return<EOL><DEDENT>DEFAULT_CONFIG = join(temp_folder, get_config_file())<EOL>with change_folder(temp_folder):<EOL><INDENT>flake8_style = get_style_guide(config_file=DEFAULT_CONFIG)<EOL>out, err = StringIO(), StringIO()<EOL>with redirected(out, err):<EOL><INDENT>flake8_style.check_files(py_files)<EOL><DEDENT><DEDENT>return out.getvalue().strip() + err.getvalue().strip()<EOL>
Check flake8 errors in the code base.