Пример #1
0
def events(name):
    crawler = get_crawler(name)
    page = int(request.args.get("page", 1))
    start = (max(1, page) - 1) * PAGE_SIZE
    end = start + PAGE_SIZE
    run_id = request.args.get("run_id")
    level = request.args.get("level")
    stage_name = request.args.get("stage_name")

    if stage_name:
        events = Event.get_stage_events(crawler, stage_name, start, end, level)
    elif run_id:
        events = Event.get_run_events(crawler, run_id, start, end, level)
    else:
        events = Event.get_crawler_events(crawler, start, end, level)
    total = len(events)
    pages = int(math.ceil((float(total) / PAGE_SIZE)))
    return render_template("events.html",
                           crawler=crawler,
                           results=events,
                           page=page,
                           pages=pages)
Пример #2
0
def crawler_events(crawler,
                   level=None,
                   stage_name=None,
                   run_id=None,
                   page=1,
                   per_page=15):
    start = (max(1, page) - 1) * per_page
    end = start + per_page

    if stage_name:
        events = Event.get_stage_events(crawler, stage_name, start, end, level)
    elif run_id:
        events = Event.get_run_events(crawler, run_id, start, end, level)
    else:
        events = Event.get_crawler_events(crawler, start, end, level)
    total = len(events)

    return {
        'page': page,
        'per_page': per_page,
        'pages': int(math.ceil((float(total) / per_page))),
        'total': total,
        'results': events
    }