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


Python Account.find方法代码示例

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


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

示例1: draw

# 需要导入模块: from account import Account [as 别名]
# 或者: from account.Account import find [as 别名]
def draw(uid, currency):
    s = current_session()
    u = Account.find(uid)
    if not u:
        raise exceptions.UserNotFound

    helpers.require_free_backpack_slot(s, uid)

    if currency == 'ppoint':
        amount = constants.LOTTERY_PRICE
        Account.add_user_credit(u, [('ppoint', -amount)],
                                exceptions.InsufficientFunds)

    elif currency == 'jiecao':
        amount = constants.LOTTERY_JIECAO_PRICE
        Account.add_user_credit(u, [('jiecao', -amount)],
                                exceptions.InsufficientFunds)

    else:
        raise exceptions.InvalidCurrency

    reward = random.choice(constants.LOTTERY_REWARD_LIST)

    item = Item(owner_id=uid, sku=reward, status='backpack')
    s.add(item)
    s.flush()
    s.add(ItemActivity(
        uid=uid, action='lottery', item_id=item.id,
        extra=json.dumps({'currency': currency, 'amount': amount}),
        created=datetime.datetime.now(),
    ))
    return reward
开发者ID:feisuzhu,项目名称:thbattle,代码行数:34,代码来源:lottery.py

示例2: get_results

# 需要导入模块: from account import Account [as 别名]
# 或者: from account.Account import find [as 别名]
    def get_results(self, fp=sys.stdout, inline=True):
        """
        Fetches the result for the command represented by this object

        @param fp: a file object to write the results to directly
        """
        result_path = self.meta_data['results_resource']
        
        conn=Qubole.agent()
        
        r = conn.get(result_path , {'inline': inline})
        if r.get('inline'):
            fp.write(r['results'].encode('utf8'))
        else:    
            acc = Account.find()
            boto_conn = boto.connect_s3(aws_access_key_id=acc.storage_access_key,
                                        aws_secret_access_key=acc.storage_secret_key)

            log.info("Starting download from result locations: [%s]" % ",".join(r['result_location']))

            for s3_path in r['result_location']:
                _download_to_local(boto_conn, s3_path, fp)
开发者ID:PraveenSeluka,项目名称:qds-sdk-py,代码行数:24,代码来源:commands.py

示例3: buy

# 需要导入模块: from account import Account [as 别名]
# 或者: from account.Account import find [as 别名]
def buy(uid, entry_id):
    s = current_session()

    u = Account.find(uid)
    if not u:
        raise exceptions.UserNotFound

    entry = s.query(Exchange).filter(Exchange.id == entry_id).first()
    if not entry:
        raise exceptions.ItemNotFound

    seller = entry.seller

    if u.ppoint < entry.price:
        raise exceptions.InsufficientFunds

    helpers.require_free_backpack_slot(s, uid)

    u.ppoint -= entry.price
    seller.ppoint += entry.price

    item = entry.item

    s.add(
        ItemActivity(
            uid=uid,
            action="buy",
            item_id=entry.item.id,
            extra=json.dumps({"seller": seller.id, "price": entry.price}),
            created=datetime.datetime.now(),
        )
    )

    item.owner_id = u.id
    item.status = "backpack"

    s.delete(entry)
开发者ID:feisuzhu,项目名称:thbattle,代码行数:39,代码来源:exchange.py


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