def provider_method_wrapper(tiid, provider, method_name):

    # logger.info(u"{:20}: in provider_method_wrapper with {tiid} {provider_name} {method_name} with {aliases}".format(
    #    "wrapper", tiid=tiid, provider_name=provider.provider_name, method_name=method_name, aliases=input_aliases_dict))


    product = Product.query.get(tiid)

    if not product:
        logger.warning(u"Empty product in provider_run for tiid {tiid}".format(
           tiid=tiid))
        return None

    input_alias_tuples = product.aliases_for_providers
    try:
        method = getattr(provider, method_name)
    except __HOLE__:
        provider = ProviderFactory.get_provider(provider)
        method = getattr(provider, method_name)

    provider_name = provider.provider_name
    worker_name = provider_name+"_worker"

    try:
        method_response = method(input_alias_tuples)
    except ProviderError, e:
        method_response = None

        logger.info(u"{:20}: **ProviderError {tiid} {method_name} {provider_name}, Exception type {exception_type} {exception_arguments}".format(
            worker_name, 
            tiid=tiid, 
            provider_name=provider_name.upper(), 
            method_name=method_name.upper(), 
            exception_type=type(e).__name__, 
            exception_arguments=e.args))

    ellipses = ""
    if method_response and len(method_response) >= 50:
        ellipses = "..."
    logger.info(u"{:20}: /biblio_print, RETURNED {tiid} {method_name} {provider_name} : {method_response:.50} {ellipses}".format(
        worker_name, tiid=tiid, method_name=method_name.upper(), 
        provider_name=provider_name.upper(), method_response=method_response, ellipses=ellipses))

    add_to_database_if_nonzero(product, method_response, method_name, provider_name)

    return tiid





# last variable is an artifact so it has same call signature as other callbacks
dataset/ETHPy150Open Impactstory/total-impact-webapp/core_tasks.py/provider_method_wrapper