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


Python Account.tweet_creation方法代码示例

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


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

示例1: process_next_creation

# 需要导入模块: from models import Account [as 别名]
# 或者: from models.Account import tweet_creation [as 别名]
def process_next_creation():
    if len(nodes_recently_updated) == 0:
        return
    next_uid = nodes_recently_updated.popleft()
    logging.info("Processing uid: %s" % next_uid)
    account = Account(next_uid)
    if not account.node_created.get():
        if account.unconf_minutes.get() < MIN_TIME:
            account.add_msg('Node creation failed! A minimum of %d minutes need to be purchased at a time. You need %d more minutes.' % (MIN_TIME, MIN_TIME - account.unconf_minutes.get()))
            return
        if account.destroyed.get():
            account.add_msg('Node creation failed as it has already been destroyed, please use a new account and contact [email protected] to get your coins back.')
            return
        account.add_msg('Creating server now. ETA 10-20 minutes.')
        dcid = random.choice([1, 5, 7])  # NJ, LA, Amsterdam

        try:
            res = requests.post("https://api.vultr.com/v1/server/create?api_key=%s" % vultr_api_key.get(),
                                data={"DCID": dcid, "VPSPLANID": 87, "OSID": 192, "SSHKEYID": ssh_management_key.get(),
                                      "label": str(account.uid), "enable_private_network": 'yes',
                                      'enable_ipv6 string': 'yes'})
        except Exception as e:
            nodes_recently_updated.prepend(next_uid)
            logging.error('Attempted to create server / Exception: %s' % repr(e))

        if res.status_code == 200:  # accepted
            response = res.json()
            subid = response['SUBID']
            logging.info(response)
            account.creation_ts.set(int(time.time()))
            account.droplet_id.set(subid)
            account.node_created.set(True)
            account.dcid.set(dcid)
            droplets_to_configure.add(subid, account.creation_ts.get())
            droplet_to_uid[subid] = account.uid
            active_servers.add(subid)
            account.add_msg('Server created successfully! Server ID %s' % (account.droplet_id.get(),))
            account.tweet_creation()
            node_creation_issues.set(False)
        else:
            logging.error('Server creation failed! Status %d' % res.status_code)
            if res.status_code == 412 and res.content == NODE_CREATION_LIMIT_MSG:
                node_creation_issues.set(True)
            logging.error(res.content)
            nodes_recently_updated.append(next_uid)
            account.add_msg('Server creation failed... will keep retrying')
            return 'CREATION_FAILED'
            # import pdb; pdb.set_trace()
    else:
        logging.warning('Account already has a node created.')
        print(account.node_created.get())
开发者ID:XertroV,项目名称:nodeup-xk-io,代码行数:53,代码来源:monitor_nodes.py


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