def scan_parserscrapers(directory):
    "Scan the specified directory for valid parser/scraper executables"
    found = []
    for root, dirs, files in os.walk(directory):
        for name in files:
            filename = os.path.join(root, name)
            is_ex = stat.S_IXUSR & os.stat(filename)[stat.ST_MODE]            
            if is_ex:
                # Try and call this executable with a -bibserver to get a config
                try:
                    output = subprocess.check_output(filename+' -bibserver', shell=True)
                    output_json = json.loads(output)
                    if output_json['bibserver_plugin']:
                        output_json['_path'] = filename
                        found.append(output_json)
                except subprocess.CalledProcessError:
                    sys.stderr.write(traceback.format_exc())
                except __HOLE__:
                    sys.stderr.write('Error parsing plugin output:\n')
                    sys.stderr.write(output)
    return found
dataset/ETHPy150Open okfn/bibserver/bibserver/ingest.py/scan_parserscrapers