@defer.inlineCallbacks
def getPath(netstatus, guard_manager, exit_request=None, fast=True,
            stable=True, internal=False):
    # Raises:
    #   - NoUsableGuardsException (i.e. we need to find a new guard)
    #   - PathSelectionFailedException
    consensus = yield netstatus.getMicroconsensus()
    descriptors = yield netstatus.getMicrodescriptorsForCircuit()
    guards = yield guard_manager.getUsableGuards()
    cons_rel_stats = consensus.routers
    cons_bw_weights = consensus.bandwidth_weights
    port = exit_request.port if exit_request else None
    cons_bwweightscale = DEFAULT_BWWEIGHTSCALE

    try:
        exit_fprint = selectExitNode(cons_bw_weights, cons_bwweightscale,
                                     cons_rel_stats, descriptors, fast, stable,
                                     internal, port)
        exit_status_entry = consensus.routers[exit_fprint]
        exit_desc = descriptors[exit_status_entry.digest]

        guard_fprint = selectGuardNode(cons_rel_stats, descriptors, guards,
                                       fast, stable, exit_desc,
                                       exit_status_entry)
        guard_status_entry = consensus.routers[guard_fprint]
        guard_desc = descriptors[guard_status_entry.digest]

        middle_fprint = selectMiddleNode(cons_bw_weights, cons_bwweightscale,
                                         cons_rel_stats, descriptors, fast,
                                         stable, exit_desc, exit_status_entry,
                                         guard_desc, guard_status_entry)
        middle_status_entry = consensus.routers[middle_fprint]
        middle_desc = descriptors[middle_status_entry.digest]

        path = Path(PathNode(guard_desc, guard_status_entry),
                    PathNode(middle_desc, middle_status_entry),
                    PathNode(exit_desc, exit_status_entry))
        defer.returnValue(path)
    except __HOLE__ as e:
        raise PathSelectionFailedException("Unable to select a valid path. "
                                           "Reason: {}".format(e))
dataset/ETHPy150Open nskinkel/oppy/oppy/path/path.py/getPath