当前位置: 首页>>代码示例>>Python>>正文


Python ProviderFactory.num_providers_with_metrics方法代码示例

本文整理汇总了Python中totalimpact.providers.provider.ProviderFactory.num_providers_with_metrics方法的典型用法代码示例。如果您正苦于以下问题:Python ProviderFactory.num_providers_with_metrics方法的具体用法?Python ProviderFactory.num_providers_with_metrics怎么用?Python ProviderFactory.num_providers_with_metrics使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在totalimpact.providers.provider.ProviderFactory的用法示例。


在下文中一共展示了ProviderFactory.num_providers_with_metrics方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: collection_update

# 需要导入模块: from totalimpact.providers.provider import ProviderFactory [as 别名]
# 或者: from totalimpact.providers.provider.ProviderFactory import num_providers_with_metrics [as 别名]
def collection_update(cid=""):

    # first, get the tiids in this collection:
    try:
        collection = mydao.get(cid)
        tiids = collection["alias_tiids"].values()
    except Exception:
        logger.exception("couldn't get tiids for collection '{cid}'".format(cid=cid))
        abort(404, "couldn't get tiids for this collection...maybe doesn't exist?")

    # put each of them on the update queue
    for tiid in tiids:
        logger.debug("In update_item with tiid " + tiid)

        # set this so we know when it's still updating later on
        myredis.set_num_providers_left(tiid, ProviderFactory.num_providers_with_metrics(default_settings.PROVIDERS))

        item_doc = mydao.get(tiid)
        try:
            myredis.add_to_alias_queue(item_doc["_id"], item_doc["aliases"])
        except (KeyError, TypeError):
            logger.debug("couldn't get item_doc for {tiid}. Skipping its update".format(tiid=tiid))
            pass

    resp = make_response("true", 200)
    resp.mimetype = "application/json"
    return resp
开发者ID:mymarkup,项目名称:total-impact-core,代码行数:29,代码来源:views.py

示例2: prep_collection_items

# 需要导入模块: from totalimpact.providers.provider import ProviderFactory [as 别名]
# 或者: from totalimpact.providers.provider.ProviderFactory import num_providers_with_metrics [as 别名]
def prep_collection_items(aliases):
    logger.info("got a list of aliases; creating new items for them.")
    try:
        # remove unprintable characters and change list to tuples
        clean_aliases = [(clean_id(namespace), clean_id(nid)) for [namespace, nid] in aliases]
    except ValueError:
        logger.error(
            "bad input to POST /collection (requires [namespace, id] pairs):{input}".format(input=str(clean_aliases))
        )
        abort(404, "POST /collection requires a list of [namespace, id] pairs.")

    logger.debug(
        "POST /collection got list of aliases; creating new items for {aliases}".format(aliases=str(clean_aliases))
    )

    (tiids, items) = create_or_find_items_from_aliases(clean_aliases)

    logger.debug("POST /collection saving a group of {num} new items: {items}".format(num=len(items), items=str(items)))

    # batch upload the new docs to the db
    # make sure they are there before the provider updates start happening
    for doc in mydao.db.update(items):
        pass

    # for each item, set the number of providers that need to run before the update is done
    # and put them on the update queue
    for item in items:
        myredis.set_num_providers_left(
            item["_id"], ProviderFactory.num_providers_with_metrics(default_settings.PROVIDERS)
        )
        myredis.add_to_alias_queue(item["_id"], item["aliases"])

    return tiids
开发者ID:mymarkup,项目名称:total-impact-core,代码行数:35,代码来源:views.py

示例3: create_item

# 需要导入模块: from totalimpact.providers.provider import ProviderFactory [as 别名]
# 或者: from totalimpact.providers.provider.ProviderFactory import num_providers_with_metrics [as 别名]
def create_item(namespace, nid, myredis, mydao):
    logger.debug("In create_item with alias" + str((namespace, nid)))
    item = make()
    namespace = clean_id(namespace)
    nid = clean_id(nid)
    item["aliases"][namespace] = [nid]
    item["aliases"] = canonical_aliases(item["aliases"])

    # set this so we know when it's still updating later on
    myredis.set_num_providers_left(
        item["_id"],
        ProviderFactory.num_providers_with_metrics(default_settings.PROVIDERS)
    )

    mydao.save(item)

    myredis.add_to_alias_queue(item["_id"], item["aliases"])

    logger.info("Created new item '{id}' with alias '{alias}'".format(
        id=item["_id"],
        alias=str((namespace, nid))
    ))

    mixpanel.track("Create:Item", {"Namespace":namespace})

    try:
        return item["_id"]
    except AttributeError:
        abort(500)
开发者ID:karthik,项目名称:total-impact-core,代码行数:31,代码来源:item.py

示例4: create_item

# 需要导入模块: from totalimpact.providers.provider import ProviderFactory [as 别名]
# 或者: from totalimpact.providers.provider.ProviderFactory import num_providers_with_metrics [as 别名]
def create_item(namespace, nid):
    logger.debug("In create_item with alias" + str((namespace, nid)))
    item = ItemFactory.make()

    # set this so we know when it's still updating later on
    myredis.set_num_providers_left(item["_id"], ProviderFactory.num_providers_with_metrics(default_settings.PROVIDERS))

    item["aliases"][namespace] = [nid]
    mydao.save(item)

    myredis.add_to_alias_queue(item["_id"], item["aliases"])

    logger.info("Created new item '{id}' with alias '{alias}'".format(id=item["_id"], alias=str((namespace, nid))))

    try:
        return item["_id"]
    except AttributeError:
        abort(500)
开发者ID:mymarkup,项目名称:total-impact-core,代码行数:20,代码来源:views.py

示例5: start_item_update

# 需要导入模块: from totalimpact.providers.provider import ProviderFactory [as 别名]
# 或者: from totalimpact.providers.provider.ProviderFactory import num_providers_with_metrics [as 别名]
def start_item_update(tiids, myredis, mydao, sleep_in_seconds=0):
    # put each of them on the update queue
    for tiid in tiids:
        logger.debug("In start_item_update with tiid " + tiid)

        # set this so we know when it's still updating later on
        myredis.set_num_providers_left(
            tiid,
            ProviderFactory.num_providers_with_metrics(default_settings.PROVIDERS)
        )

        item_doc = mydao.get(tiid)
        try:
            myredis.add_to_alias_queue(item_doc["_id"], item_doc["aliases"])
        except (KeyError, TypeError):
            logger.debug("couldn't get item_doc for {tiid}. Skipping its update".format(
                tiid=tiid))
            pass

        time.sleep(sleep_in_seconds)
开发者ID:karthik,项目名称:total-impact-core,代码行数:22,代码来源:item.py

示例6: start_item_update

# 需要导入模块: from totalimpact.providers.provider import ProviderFactory [as 别名]
# 或者: from totalimpact.providers.provider.ProviderFactory import num_providers_with_metrics [as 别名]
def start_item_update(tiid, aliases_dict, myredis):
    logger.debug(u"In start_item_update with {tiid}, /biblio_print {aliases_dict}".format(
        tiid=tiid, aliases_dict=aliases_dict))
    myredis.set_num_providers_left(tiid,
        ProviderFactory.num_providers_with_metrics(default_settings.PROVIDERS))
    myredis.add_to_alias_queue(tiid, aliases_dict)
开发者ID:dbeucke,项目名称:total-impact-core,代码行数:8,代码来源:item.py


注:本文中的totalimpact.providers.provider.ProviderFactory.num_providers_with_metrics方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。