def get_node_or_fail(conn, node_id, coroutine=None, cargs=(), ckwargs={}):
    """Shortcut to get a single node by its id. In case when 
    such node could not be found, coroutine could be called
    to handle such case. Typically coroutine will output an
    error message and exit from application.

    @param conn: libcloud connection handle
    @param node_id: id of the node to search for
    @param coroutine: a callable object to handle case
        when node cannot be found
    @param cargs: positional arguments for coroutine
    @param kwargs: keyword arguments for coroutine
    @return: node object if found, None otherwise"""

    try:
        node = [node for node in conn.list_nodes()
                if str(node.id) == str(node_id)][0]
        return node
    except __HOLE__:
        if callable(coroutine):
            coroutine(*cargs, **ckwargs)
        return None
dataset/ETHPy150Open novel/lc-tools/lctools/shortcuts.py/get_node_or_fail