コード例 #1
0
def get_detail_response(endpoint,
                        ivorn,
                        host):
    if host is None:
        host = voeventdb.remote.default_host
    ep_url = host + endpoint
    url = ep_url + urllib.quote_plus(ivorn)
    with helpful_requests_error_log():
        r = requests.get(url)
    r.raise_for_status()
    return r
コード例 #2
0
def get_summary_response(endpoint,
                         filters,
                         host,
                         ):
    if host is None:
        host = voeventdb.remote.default_host
    params = format_filters(filters)
    with helpful_requests_error_log():
        r = requests.get(host + endpoint,
                         params=params
                         )
    r.raise_for_status()
    return r
コード例 #3
0
def get_paginated(url, params, n_to_fetch, pagesize):
    offset = 0
    results = []
    localpars = params.copy()
    localpars[PaginationKeys.limit] = pagesize
    if n_to_fetch < pagesize:
        localpars[PaginationKeys.limit] = n_to_fetch
    while offset < n_to_fetch:
        localpars[PaginationKeys.offset] = offset
        with helpful_requests_error_log():
            r = requests.get(url,
                             params=localpars
                             )
        r.raise_for_status()
        results.extend(r.json()[ResultKeys.result])
        offset += pagesize
    # Snip any excess results caused by n_to_fetch not being
    # a multiple of pagesize
    results = results[:n_to_fetch]
    return results