def check_specs_against_mirrors(mirrors, specs, output_file=None, rebuild_on_errors=False):
    "Check all the given specs against buildcaches on the given mirrors and\n    determine if any of the specs need to be rebuilt.  Reasons for needing to\n    rebuild include binary cache for spec isn't present on a mirror, or it is\n    present but the full_hash has changed since last time spec was built.\n\n    Arguments:\n        mirrors (dict): Mirrors to check against\n        specs (iterable): Specs to check against mirrors\n        output_file (string): Path to output file to be written.  If provided,\n            mirrors with missing or out-of-date specs will be formatted as a\n            JSON object and written to this file.\n        rebuild_on_errors (boolean): Treat any errors encountered while\n            checking specs as a signal to rebuild package.\n\n    Returns: 1 if any spec was out-of-date on any mirror, 0 otherwise.\n\n    "
    rebuilds = {}
    for mirror in spack.mirror.MirrorCollection(mirrors).values():
        tty.msg(('Checking for built specs at %s' % mirror.fetch_url))
        rebuild_list = []
        for spec in specs:
            if needs_rebuild(spec, mirror.fetch_url, rebuild_on_errors):
                rebuild_list.append({'short_spec': spec.short_spec, 'hash': spec.dag_hash()})
        if rebuild_list:
            rebuilds[mirror.fetch_url] = {'mirrorName': mirror.name, 'mirrorUrl': mirror.fetch_url, 'rebuildSpecs': rebuild_list}
    if output_file:
        with open(output_file, 'w') as outf:
            outf.write(json.dumps(rebuilds))
    return (1 if rebuilds else 0)
Check all the given specs against buildcaches on the given mirrors and
determine if any of the specs need to be rebuilt.  Reasons for needing to
rebuild include binary cache for spec isn't present on a mirror, or it is
present but the full_hash has changed since last time spec was built.

Arguments:
    mirrors (dict): Mirrors to check against
    specs (iterable): Specs to check against mirrors
    output_file (string): Path to output file to be written.  If provided,
        mirrors with missing or out-of-date specs will be formatted as a
        JSON object and written to this file.
    rebuild_on_errors (boolean): Treat any errors encountered while
        checking specs as a signal to rebuild package.

Returns: 1 if any spec was out-of-date on any mirror, 0 otherwise.
def check_specs_against_mirrors(mirrors, specs, output_file=None, rebuild_on_errors=False):
    "Check all the given specs against buildcaches on the given mirrors and\n    determine if any of the specs need to be rebuilt.  Reasons for needing to\n    rebuild include binary cache for spec isn't present on a mirror, or it is\n    present but the full_hash has changed since last time spec was built.\n\n    Arguments:\n        mirrors (dict): Mirrors to check against\n        specs (iterable): Specs to check against mirrors\n        output_file (string): Path to output file to be written.  If provided,\n            mirrors with missing or out-of-date specs will be formatted as a\n            JSON object and written to this file.\n        rebuild_on_errors (boolean): Treat any errors encountered while\n            checking specs as a signal to rebuild package.\n\n    Returns: 1 if any spec was out-of-date on any mirror, 0 otherwise.\n\n    "
    rebuilds = {}
    for mirror in spack.mirror.MirrorCollection(mirrors).values():
        tty.msg(('Checking for built specs at %s' % mirror.fetch_url))
        rebuild_list = []
        for spec in specs:
            if needs_rebuild(spec, mirror.fetch_url, rebuild_on_errors):
                rebuild_list.append({'short_spec': spec.short_spec, 'hash': spec.dag_hash()})
        if rebuild_list:
            rebuilds[mirror.fetch_url] = {'mirrorName': mirror.name, 'mirrorUrl': mirror.fetch_url, 'rebuildSpecs': rebuild_list}
    if output_file:
        with open(output_file, 'w') as outf:
            outf.write(json.dumps(rebuilds))
    return (1 if rebuilds else 0)