def _lint(session, rcfile, flags, paths, tee_output=True):
    if _upgrade_pip_setuptools_and_wheel(session):
        _install_requirements(session, 'zeromq')
        requirements_file = os.path.join('requirements', 'static', 'ci', _get_pydir(session), 'lint.txt')
        install_command = ['--progress-bar=off', '-r', requirements_file]
        session.install(*install_command, silent=PIP_INSTALL_SILENT)
    if tee_output:
        session.run('pylint', '--version')
        pylint_report_path = os.environ.get('PYLINT_REPORT')
    cmd_args = ((['pylint', '--rcfile={}'.format(rcfile)] + list(flags)) + list(paths))
    cmd_kwargs = {'env': {'PYTHONUNBUFFERED': '1'}}
    if tee_output:
        stdout = tempfile.TemporaryFile(mode='w+b')
        cmd_kwargs['stdout'] = Tee(stdout, sys.__stdout__)
    lint_failed = False
    try:
        session.run(*cmd_args, **cmd_kwargs)
    except CommandFailed:
        lint_failed = True
        raise
    finally:
        if tee_output:
            stdout.seek(0)
            contents = stdout.read()
            if contents:
                if IS_PY3:
                    contents = contents.decode('utf-8')
                else:
                    contents = contents.encode('utf-8')
                sys.stdout.write(contents)
                sys.stdout.flush()
                if pylint_report_path:
                    with open(pylint_report_path, 'w') as wfh:
                        wfh.write(contents)
                    session.log('Report file written to %r', pylint_report_path)
            stdout.close()
def _lint(session, rcfile, flags, paths, tee_output=True):
    if _upgrade_pip_setuptools_and_wheel(session):
        _install_requirements(session, 'zeromq')
        requirements_file = os.path.join('requirements', 'static', 'ci', _get_pydir(session), 'lint.txt')
        install_command = ['--progress-bar=off', '-r', requirements_file]
        session.install(*install_command, silent=PIP_INSTALL_SILENT)
    if tee_output:
        session.run('pylint', '--version')
        pylint_report_path = os.environ.get('PYLINT_REPORT')
    cmd_args = ((['pylint', '--rcfile={}'.format(rcfile)] + list(flags)) + list(paths))
    cmd_kwargs = {'env': {'PYTHONUNBUFFERED': '1'}}
    if tee_output:
        stdout = tempfile.TemporaryFile(mode='w+b')
        cmd_kwargs['stdout'] = Tee(stdout, sys.__stdout__)
    lint_failed = False
    try:
        session.run(*cmd_args, **cmd_kwargs)
    except CommandFailed:
        lint_failed = True
        raise
    finally:
        if tee_output:
            stdout.seek(0)
            contents = stdout.read()
            if contents:
                if IS_PY3:
                    contents = contents.decode('utf-8')
                else:
                    contents = contents.encode('utf-8')
                sys.stdout.write(contents)
                sys.stdout.flush()
                if pylint_report_path:
                    with open(pylint_report_path, 'w') as wfh:
                        wfh.write(contents)
                    session.log('Report file written to %r', pylint_report_path)
            stdout.close()