• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python authorize.is_charged_transaction函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中r2.lib.authorize.is_charged_transaction函数的典型用法代码示例。如果您正苦于以下问题:Python is_charged_transaction函数的具体用法?Python is_charged_transaction怎么用?Python is_charged_transaction使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: scheduled_campaigns_by_link

def scheduled_campaigns_by_link(l, date=None):
    # A promotion/campaign is scheduled/live if it's in
    # PromotionWeights.get_campaigns(now) and
    # authorize.is_charged_transaction()

    date = date or promo_datetime_now()

    if not is_accepted(l):
        return []
    if not l.campaigns:
        return []

    scheduled = PromotionWeights.get_campaigns(date)
    campaigns = [c.promo_idx for c in scheduled if c.thing_name == l._fullname]

    # Check authorize
    accepted = []
    for index in campaigns:
        if not index in l.campaigns:
            continue

        sd, ed, bid, sr, trans_id = l.campaigns[index]
        if authorize.is_charged_transaction(trans_id, index):
            accepted.append(index)

    return accepted
开发者ID:freekrai,项目名称:reddit,代码行数:26,代码来源:promote.py


示例2: get_scheduled

def get_scheduled(offset=0):
    by_sr = {}
    for l, index, camp in accepted_campaigns(offset=offset):
        sd, ed, bid, sr, trans_id = camp
        if authorize.is_charged_transaction(trans_id, index):
            by_sr.setdefault(sr, []).append((l, bid))
    return by_sr
开发者ID:freekrai,项目名称:reddit,代码行数:7,代码来源:promote.py


示例3: scheduled_campaigns_by_link

def scheduled_campaigns_by_link(l, date=None):
    # A promotion/campaign is scheduled/live if it's in
    # PromotionWeights.get_campaigns(now) and
    # authorize.is_charged_transaction()

    date = date or promo_datetime_now()

    if not is_accepted(l):
        return []

    scheduled = PromotionWeights.get_campaigns(date)
    campaigns = [c.promo_idx for c in scheduled if c.thing_name == l._fullname]

    # Check authorize
    accepted = []
    for campaign_id in campaigns:
        try:
            campaign = PromoCampaign._byID(campaign_id, data=True)
            if authorize.is_charged_transaction(campaign.trans_id, campaign_id):
                accepted.append(campaign_id)
        except NotFound:
            g.log.error("PromoCampaign %d scheduled to run on %s not found." %
                          (campaign_id, date.strftime("%Y-%m-%d")))

    return accepted
开发者ID:vinnydiehl,项目名称:reddit,代码行数:25,代码来源:promote.py


示例4: charge_pending

def charge_pending(offset=1):
    for l, camp, weight in accepted_campaigns(offset=offset):
        user = Account._byID(l.author_id)
        try:
            if authorize.is_charged_transaction(camp.trans_id, camp._id):
                # already charged
                continue

            charge_succeeded = authorize.charge_transaction(user, camp.trans_id,
                                                            camp._id)

            if not charge_succeeded:
                continue

            hooks.get_hook('promote.new_charge').call(link=l, campaign=camp)

            if is_promoted(l):
                emailer.queue_promo(l, camp.bid, camp.trans_id)
            else:
                set_promote_status(l, PROMOTE_STATUS.pending)
                emailer.queue_promo(l, camp.bid, camp.trans_id)
            text = ('auth charge for campaign %s, trans_id: %d' %
                    (camp._id, camp.trans_id))
            PromotionLog.add(l, text)
        except:
            print "Error on %s, campaign %s" % (l, camp._id)
开发者ID:Alex-Quinn,项目名称:reddit,代码行数:26,代码来源:promote.py


示例5: make_adzerk_promotions

def make_adzerk_promotions(offset=0):
    # make sure is_charged_transaction and is_accepted are the only criteria
    # for a campaign going live!

    for link, campaign, weight in promote.accepted_campaigns(offset=offset):
        if (authorize.is_charged_transaction(campaign.trans_id, campaign._id)
            and promote.is_accepted(link)):
            update_adzerk(link, campaign)
开发者ID:bsimpson63,项目名称:reddit-plugin-adzerkpromo,代码行数:8,代码来源:adzerkpromo.py


示例6: make_adzerk_promotions

def make_adzerk_promotions(offset=0):
    # campaign goes live if is_charged_transaction and is_accepted
    for link, campaign, weight in promote.accepted_campaigns(offset=offset):
        if (authorize.is_charged_transaction(campaign.trans_id, campaign._id)
            and promote.is_accepted(link)):
            if is_overdelivered(campaign):
                deactivate_campaign(link, campaign)
            else:
                update_adzerk(link, campaign)
开发者ID:bsimpson63,项目名称:reddit-plugin-adzerk,代码行数:9,代码来源:adzerkpromote.py


示例7: get_scheduled

def get_scheduled(offset=0):
    by_sr = {}
    failed = []
    for l, campaign, weight in accepted_campaigns(offset=offset):
        try:
            if authorize.is_charged_transaction(campaign.trans_id, campaign._id):
                by_sr.setdefault(campaign.sr_name, []).append((l, weight))
        except Exception, e: # could happen if campaign things have corrupt data
            failed.append((campaign._id, e))
开发者ID:SolveMedia,项目名称:reddit,代码行数:9,代码来源:promote.py


示例8: _charge

 def _charge(l, camp, indx, weight):
     user = Account._byID(l.author_id)
     sd, ed, bid, sr, trans_id = camp
     try:
         if (not authorize.is_charged_transaction(trans_id, indx) and
             authorize.charge_transaction(user, trans_id, indx)):
             # update the query queue
             if is_promoted(l):
                 emailer.queue_promo(l, bid, trans_id)
             else:
                 set_status(l, STATUS.pending,
                            onchange = lambda: emailer.queue_promo(l, bid, trans_id) )
             promotion_log(l, "auth charge for campaign %s, trans_id: %d" % (indx, trans_id), True)
     except:
         print "Error on %s, campaign %s" % (l, indx)
开发者ID:DanHoerst,项目名称:reddit,代码行数:15,代码来源:promote.py


示例9: _charge

 def _charge(l, camp, indx, weight):
     user = Account._byID(l.author_id)
     sd, ed, bid, sr, trans_id = camp
     try:
         if (not authorize.is_charged_transaction(trans_id, indx) and
             authorize.charge_transaction(user, trans_id, indx)):
             # TODO: probably not absolutely necessary
             promotion_log(l, "status update: pending")
             # update the query queue
             if is_promoted(l):
                 emailer.queue_promo(l, bid, trans_id)
             else:
                 set_status(l, STATUS.pending,
                            onchange = lambda: emailer.queue_promo(l, bid, trans_id) )
     except:
         print "Error on %s, campaign %s" % (l, indx)
开发者ID:JediWatchman,项目名称:reddit,代码行数:16,代码来源:promote.py


示例10: charge_pending

def charge_pending(offset=1):
    for l, camp, weight in accepted_campaigns(offset=offset):
        user = Account._byID(l.author_id)
        try:
            if authorize.is_charged_transaction(camp.trans_id, camp._id) or not authorize.charge_transaction(
                user, camp.trans_id, camp._id
            ):
                continue

            if is_promoted(l):
                emailer.queue_promo(l, camp.bid, camp.trans_id)
            else:
                set_status(l, STATUS.pending, onchange=lambda: emailer.queue_promo(l, camp.bid, camp.trans_id))
            promotion_log(l, "auth charge for campaign %s, trans_id: %d" % (camp._id, camp.trans_id), commit=True)
        except:
            print "Error on %s, campaign %s" % (l, camp._id)
开发者ID:jianbin91,项目名称:reddit,代码行数:16,代码来源:promote.py


示例11: charge_pending

def charge_pending(offset=1):
    for l, index, camp in accepted_campaigns(offset=offset):
        user = Account._byID(l.author_id)
        sd, ed, bid, sr, trans_id = camp
        try:
            if (authorize.is_charged_transaction(trans_id, index) or not
                authorize.charge_transaction(user, trans_id, index)):
                continue

            if is_promoted(l):
                emailer.queue_promo(l, bid, trans_id)
            else:
                set_status(l, STATUS.pending,
                    onchange=lambda: emailer.queue_promo(l, bid, trans_id))
            promotion_log(l, "auth charge for campaign %s, trans_id: %d" % (index, trans_id), True)
        except:
            print "Error on %s, campaign %s" % (l, index)
开发者ID:freekrai,项目名称:reddit,代码行数:17,代码来源:promote.py


示例12: charge_pending

def charge_pending(offset=1):
    for l, camp, weight in accepted_campaigns(offset=offset):
        user = Account._byID(l.author_id)
        try:
            if (authorize.is_charged_transaction(camp.trans_id, camp._id) or not 
                authorize.charge_transaction(user, camp.trans_id, camp._id)):
                continue

            if is_promoted(l):
                emailer.queue_promo(l, camp.bid, camp.trans_id)
            else:
                set_promote_status(l, PROMOTE_STATUS.pending)
                emailer.queue_promo(l, camp.bid, camp.trans_id)
            text = ('auth charge for campaign %s, trans_id: %d' % 
                    (camp._id, camp.trans_id))
            PromotionLog.add(l, text)
        except:
            print "Error on %s, campaign %s" % (l, camp._id)
开发者ID:vinnydiehl,项目名称:reddit,代码行数:18,代码来源:promote.py


示例13: get_scheduled

def get_scheduled(offset=0):
    """
    Arguments:
      offset - number of days after today you want the schedule for
    Returns:
      {'adweights':[], 'error_campaigns':[]}
      -adweights is a list of Adweight objects used in the schedule
      -error_campaigns is a list of (campaign_id, error_msg) tuples if any 
        exceptions were raised or an empty list if there were none
      Note: campaigns in error_campaigns will not be included in by_sr

    """
    adweights = []
    error_campaigns = []
    for l, campaign, weight in accepted_campaigns(offset=offset):
        try:
            if authorize.is_charged_transaction(campaign.trans_id, campaign._id):
                adweight = AdWeight(l._fullname, weight, campaign._fullname)
                adweights.append(adweight)
        except Exception, e: # could happen if campaign things have corrupt data
            error_campaigns.append((campaign._id, e))
开发者ID:Alex-Quinn,项目名称:reddit,代码行数:21,代码来源:promote.py


示例14: get_scheduled

def get_scheduled(offset=0):
    """  
    Arguments:
      offset - number of days after today you want the schedule for
    Returns:
      {'by_sr': dict, 'links':set(), 'error_campaigns':[]}
      -by_sr maps sr names to lists of (Link, bid) tuples
      -links is the set of promoted Link objects used in the schedule
      -error_campaigns is a list of (campaign_id, error_msg) tuples if any 
        exceptions were raised or an empty list if there were none
      Note: campaigns in error_campaigns will not be included in by_sr
      """
    by_sr = {}
    error_campaigns = []
    links = set()
    for l, campaign, weight in accepted_campaigns(offset=offset):
        try:
            if authorize.is_charged_transaction(campaign.trans_id, campaign._id):
                by_sr.setdefault(campaign.sr_name, []).append((l, weight))
                links.add(l)
        except Exception, e:  # could happen if campaign things have corrupt data
            error_campaigns.append((campaign._id, e))
开发者ID:jianbin91,项目名称:reddit,代码行数:22,代码来源:promote.py


示例15: _promote

 def _promote(l, camp, indx, weight):
     sd, ed, bid, sr, trans_id = camp
     if authorize.is_charged_transaction(trans_id, indx):
         by_sr.setdefault(sr, []).append((l, weight))
开发者ID:JediWatchman,项目名称:reddit,代码行数:4,代码来源:promote.py


示例16: charged_or_not_needed

def charged_or_not_needed(campaign):
    # True if a campaign has a charged transaction or doesn't need one
    charged = authorize.is_charged_transaction(campaign.trans_id, campaign._id)
    needs_charge = campaign.priority.cpm
    return charged or not needs_charge
开发者ID:AD42,项目名称:reddit,代码行数:5,代码来源:promote.py


示例17: get_scheduled

def get_scheduled(offset=0):
    by_sr = {}
    for l, campaign, weight in accepted_campaigns(offset=offset):
        if authorize.is_charged_transaction(campaign.trans_id, campaign._id):
            by_sr.setdefault(campaign.sr_name, []).append((l, weight))
    return by_sr
开发者ID:LDot,项目名称:reddit,代码行数:6,代码来源:promote.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python authorize.void_transaction函数代码示例发布时间:2022-05-26
下一篇:
Python authorize.get_account_info函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap