Esempio n. 1
0
def get_item_from_tiid(tiid, format=None, include_history=False, callback_name=None):
    try:
        item = item_module.get_item(tiid, myrefsets, myredis)
    except (LookupError, AttributeError):
        abort_custom(404, "item does not exist")

    if not item:
        abort_custom(404, "item does not exist")

    item["refresh_status"] = item_module.refresh_status(tiid, myredis)["short"]
    if not item["refresh_status"].startswith("SUCCESS"):
        response_code = 210 # not complete yet
    else:
        response_code = 200

    api_key = request.args.get("key", None)
    clean_item = item_module.clean_for_export(item, api_key, os.getenv("API_ADMIN_KEY"))
    clean_item["HTTP_status_code"] = response_code  # hack for clients who can't read real response codes

    resp_string = json.dumps(clean_item, sort_keys=True, indent=4)
    if callback_name is not None:
        resp_string = callback_name + '(' + resp_string + ')'

    resp = make_response(resp_string, response_code)

    return resp
Esempio n. 2
0
def get_item_from_tiid(tiid,
                       format=None,
                       include_history=False,
                       callback_name=None):
    try:
        item = item_module.get_item(tiid, myrefsets, myredis)
    except (LookupError, AttributeError):
        abort_custom(404, "item does not exist")

    if not item:
        abort_custom(404, "item does not exist")

    item["refresh_status"] = item_module.refresh_status(tiid, myredis)["short"]
    if not item["refresh_status"].startswith("SUCCESS"):
        response_code = 210  # not complete yet
    else:
        response_code = 200

    api_key = request.args.get("key", None)
    clean_item = item_module.clean_for_export(item, api_key,
                                              os.getenv("API_ADMIN_KEY"))
    clean_item[
        "HTTP_status_code"] = response_code  # hack for clients who can't read real response codes

    resp_string = json.dumps(clean_item, sort_keys=True, indent=4)
    if callback_name is not None:
        resp_string = callback_name + '(' + resp_string + ')'

    resp = make_response(resp_string, response_code)

    return resp
def is_all_done(tiids, myredis):
    statuses = [item_module.refresh_status(tiid, myredis) for tiid in tiids]
    all_done = all([refresh_status["short"].startswith(u"SUCCESS") for status in statuses])
    return all_done
def is_all_done(tiids, myredis):
    statuses = [item_module.refresh_status(tiid, myredis) for tiid in tiids]
    all_done = all([
        refresh_status["short"].startswith(u"SUCCESS") for status in statuses
    ])
    return all_done