def run_bandit(source_dir):
    # go through each source directory in the directory which contains source,
    # run Bandit with the established tox job, save results
    orig_dir = os.path.abspath(os.getcwd())

    try:
        fail_results_dir = os.path.abspath('fail_results')
        os.mkdir(fail_results_dir)
    except __HOLE__:
        print ("Unable to make results directory")

    os.chdir(source_dir)

    run_success = {}

    for d in os.listdir(os.getcwd()):
        os.chdir(d)

        print '=' * len(TITLE)
        print 'Running tox Bandit in directory {}'.format(d)

        try:
            subprocess.check_output(['tox', '-e', 'bandit'],
                                    stderr=subprocess.STDOUT)

        except subprocess.CalledProcessError as exc:
            run_success[d] = False

            # write log containing the process output
            fail_log_path = fail_results_dir + '/' + d
            with open(fail_log_path, 'w') as f:
                f.write(exc.output)
            print("Bandit tox failed, wrote failure log to {}".
                  format(fail_log_path))

        else:
            run_success[d] = True

        os.chdir(source_dir)

    os.chdir(orig_dir)

    return run_success
dataset/ETHPy150Open openstack/bandit/tools/openstack_coverage.py/run_bandit