@app.route('/node/<node_name>', defaults={'env': app.config['DEFAULT_ENVIRONMENT']})
@app.route('/<env>/node/<node_name>')
def node(env, node_name):
    """Display a dashboard for a node showing as much data as we have on that
    node. This includes facts and reports but not Resources as that is too
    heavy to do within a single request.

    :param env: Ensure that the node, facts and reports are in this environment
    :type env: :obj:`string`
    """
    envs = environments()
    check_env(env, envs)

    if env == '*':
        query = '["=", "certname", "{0}"]]'.format(node_name)
    else:
        query='["and", ["=", "environment", "{0}"],' \
            '["=", "certname", "{1}"]]'.format(env, node_name),

    node = get_or_abort(puppetdb.node, node_name)
    facts = node.facts()
    reports = get_or_abort(puppetdb.reports,
        query=query,
        limit=app.config['REPORTS_COUNT'],
        order_by='[{"field": "start_time", "order": "desc"}]')
    reports, reports_events = tee(reports)
    report_event_counts = {}

    for report in reports_events:
        counts = get_or_abort(puppetdb.event_counts,
            query='["and", ["=", "environment", "{0}"],' \
                '["=", "certname", "{1}"], ["=", "report", "{2}"]]'.format(
                    env,
                    node_name,
                    report.hash_),
            summarize_by="certname")
        try:
            report_event_counts[report.hash_] = counts[0]
        except __HOLE__:
            report_event_counts[report.hash_] = {}
    return render_template(
        'node.html',
        node=node,
        facts=yield_or_stop(facts),
        reports=yield_or_stop(reports),
        reports_count=app.config['REPORTS_COUNT'],
        report_event_counts=report_event_counts,
        envs=envs,
        current_env=env)
dataset/ETHPy150Open voxpupuli/puppetboard/puppetboard/app.py/node