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


Python Team.all方法代码示例

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


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

示例1: ls

# 需要导入模块: from models import Team [as 别名]
# 或者: from models.Team import all [as 别名]
 def ls(self):
     current_user = self.get_current_user()
     if self.get_argument('data').lower() == 'accounts':
         data = {}
         for team in Team.all():
             if team == current_user.team:
                 continue
             else:
                 data[team.name] = {
                     'money': team.money, 
                     'flags': len(team.flags),
                     'bots': team.bot_count,
                 }
         self.write({'accounts': data})
     elif self.get_argument('data').lower() == 'users':
         data = {}
         target_users = User.not_team(current_user.team.id)
         for user in target_users:
             data[user.handle] = {
                 'account': user.team.name,
                 'algorithm': user.algorithm,
                 'password': user.bank_password,
             }
         self.write({'users': data})
     else:
         self.write({'Error': 'Invalid data type'})
     self.finish()
开发者ID:CRYPTOlab,项目名称:RootTheBox,代码行数:29,代码来源:UpgradeHandlers.py

示例2: get

# 需要导入模块: from models import Team [as 别名]
# 或者: from models.Team import all [as 别名]
 def get(self, user_token):
   team = Team.all().filter('user_token =', user_token).get()
   if team is None:
     user_info = config_NOCOMMIT.pledge_service.loadPledgeInfo(user_token)
     if user_info is None:
       return self.notfound()
     user_pledge_dollars = int(user_info["pledge_amount_cents"]) / 100
     goal_dollars = user_pledge_dollars * 10
     if user_info["name"]:
       signature = "_Thank you,_\n\n_%s_" % user_info["name"]
     else:
       signature = "Thank you!"
     title = user_info["name"] or DEFAULT_TITLE
     form = TeamForm(data={
         "goal_dollars": str(goal_dollars),
         "title": title,
         "zip_code": str(user_info["zip_code"] or ""),
         "description": PREVIOUS_PLEDGE_DESC.format(
             pledge_dollars=user_pledge_dollars,
             signature=signature,
             title=title)})
   else:
     self.add_to_user(team)
     form = TeamForm(obj=team)
   self.render_template("new_from_pledge.html", form=form)
开发者ID:Lessig2016,项目名称:teams,代码行数:27,代码来源:main.py

示例3: score_bots

# 需要导入模块: from models import Team [as 别名]
# 或者: from models.Team import all [as 别名]
def score_bots():
    ''' Award money for botnets '''
    logging.info("Scoring botnets, please wait ...")
    bot_manager = BotManager.Instance()
    config = ConfigManager.Instance()
    for team in Team.all():
        bots = bot_manager.by_team(team.name)
        reward = 0
        for bot in bots:
            try:
                reward += config.bot_reward
                bot.write_message({
                    'opcode': 'status',
                    'message': 'Collected $%d reward' % config.bot_reward
                })
            except:
                logging.info(
                    "Bot at %s failed to respond to score ping" % bot.remote_ip
                )
        if 0 < len(bots):
            logging.debug("%s was awarded $%d for controlling %s bot(s)" % (
                team.name, reward, len(bots),
            ))
            bot_manager.add_rewards(team.name, config.bot_reward)
            bot_manager.notify_monitors(team.name)
            team.money += reward
            dbsession.add(team)
            dbsession.flush()
开发者ID:lavalamp-,项目名称:RootTheBox,代码行数:30,代码来源:Scoreboard.py

示例4: post

# 需要导入模块: from models import Team [as 别名]
# 或者: from models.Team import all [as 别名]
 def post(self, user_token):
   team = Team.all().filter('user_token =', user_token).get()
   if team is None:
     # just make sure this pledge exists
     user_info = config_NOCOMMIT.pledge_service.loadPledgeInfo(user_token)
     if user_info is None:
       return self.notfound()
   form = TeamForm(self.request.POST, team)
   if not form.validate():
     return self.render_template("new_from_pledge.html", form=form)
   if team is None:
     gravatar = "https://secure.gravatar.com/avatar/%s?%s" % (
       hashlib.md5(user_info['email'].lower()).hexdigest(),
       urllib.urlencode({'s': str('120')}))
     team = Team.create(title=form.title.data,
                        description=form.description.data,
                        zip_code=form.zip_code.data,
                        user_token=user_token,
                        gravatar=gravatar)
   else:
     form.populate_obj(team)
   self.add_to_user(team)
   team.primary_slug = Slug.new(team)  
   try:
     result = config_NOCOMMIT.pledge_service.updateMailchimp(team) 
   except Exception as e:
     logging.error('Exception updating mailChimp: ' + str(e))
     logging.info(traceback.format_exc())
   team.put()
   if self.logged_in:
     return self.redirect("/t/%s" % team.primary_slug)
   return self.redirect("/dashboard/add_admin_from_pledge/%s" % user_token)
开发者ID:Lessig2016,项目名称:teams,代码行数:34,代码来源:main.py

示例5: get

# 需要导入模块: from models import Team [as 别名]
# 或者: from models.Team import all [as 别名]
 def get(self):
     df = DatafeedUsfirstTeams()
     df.flushTeams()
     
     team_count = Team.all().count()
     
     self.response.out.write("Teams flushed. " + str(team_count) + " teams remain. What have we done?!")
开发者ID:Apple101Review,项目名称:the-blue-alliance,代码行数:9,代码来源:datafeed_controller.py

示例6: bots

# 需要导入模块: from models import Team [as 别名]
# 或者: from models.Team import all [as 别名]
 def bots(self):
     game_history = GameHistory.Instance()
     history = {}
     for team in Team.all():
         history[team.name] = game_history.get_bot_history_by_name(
             team.name, -30
         )
     self.render('scoreboard/history/bots.html', history=history)
开发者ID:lavalamp-,项目名称:RootTheBox,代码行数:10,代码来源:ScoreboardHandlers.py

示例7: now

# 需要导入模块: from models import Team [as 别名]
# 或者: from models.Team import all [as 别名]
 def now(self):
     ''' Returns the current game state '''
     game_state = {}
     for team in Team.all():
         game_state[team.name] = {
             'money': team.money,
             'flags': [str(flag) for flag in team.flags],
             'game_levels': [str(lvl) for lvl in team.game_levels],
         }
     return json.dumps(game_state)
开发者ID:brutalhonesty,项目名称:RootTheBox,代码行数:12,代码来源:Scoreboard.py

示例8: get

# 需要导入模块: from models import Team [as 别名]
# 或者: from models.Team import all [as 别名]
 def get(self):
     
     teams = Team.all().order('team_number').fetch(10000)
     
     template_values = {
         "teams": teams,
     }
     
     path = os.path.join(os.path.dirname(__file__), '../../templates/admin/teams/list.html')
     self.response.out.write(template.render(path, template_values))
开发者ID:Apple101Review,项目名称:the-blue-alliance,代码行数:12,代码来源:admin_team_controller.py

示例9: flushTeams

# 需要导入模块: from models import Team [as 别名]
# 或者: from models.Team import all [as 别名]
 def flushTeams(self):
     """
     Delete Teams from the datastore. May take a few calls.
     NOTE: This breaks all relations such as EventTeams and Alliances.
     NEVER CALL THIS FUNCTION UNLESS YOU ARE ABSOLUTELY SERIOUS.
     """
     
     #TODO: This doesn't belong here. Move it to Controller? -gregmarra 7/31/2010
     
     teams = Team.all().fetch(500) #500 is max delete at once limit.
     db.delete(teams)
开发者ID:Apple101Review,项目名称:the-blue-alliance,代码行数:13,代码来源:datafeed_usfirst_teams.py

示例10: get

# 需要导入模块: from models import Team [as 别名]
# 或者: from models.Team import all [as 别名]
  def get(self):
    logging.debug("checking team retirement....")

    sixteen_weeks_ago = datetime.date.today() - datetime.timedelta(weeks=16)

    for team in Team.all().filter("retired =", False):
      if not team.last_active:
        assert team.matches == 0
        continue

      if team.last_active < sixteen_weeks_ago:
        logging.debug("retiring %s" % team.key().name())
        misc.retire_team(team)
开发者ID:krewlogic,项目名称:bb-oftl,代码行数:15,代码来源:__init__.py

示例11: ls

# 需要导入模块: from models import Team [as 别名]
# 或者: from models.Team import all [as 别名]
 def ls(self):
     if self.get_argument('data').lower() == 'accounts':
         self.write({'accounts': [team.name for team in Team.all()]})
     elif self.get_argument('data').lower() == 'users':
         data = {}
         for user in User.all_users():
             data[user.handle] = {
                 'account': user.team.name,
                 'algorithm': user.algorithm,
                 'password': user.password,
             }
         self.write({'users': data})
     else:
         self.write({'Error': 'Invalid data type'})
     self.finish()
开发者ID:brutalhonesty,项目名称:RootTheBox,代码行数:17,代码来源:UpgradeHandlers.py

示例12: __now__

# 需要导入模块: from models import Team [as 别名]
# 或者: from models.Team import all [as 别名]
 def __now__(self):
     ''' Returns snapshot object it as a dict '''
     snapshot = Snapshot()
     for team in Team.all():
         snapshot_team = SnapshotTeam(
             team_id=team.id,
             money=team.money,
         )
         snapshot_team.game_levels = team.game_levels
         snapshot_team.flags = team.flags
         dbsession.add(snapshot_team)
         dbsession.flush()
         snapshot.teams.append(snapshot_team)
     dbsession.add(snapshot)
     dbsession.flush()
     return snapshot
开发者ID:mach327,项目名称:RootTheBox,代码行数:18,代码来源:GameHistory.py

示例13: get

# 需要导入模块: from models import Team [as 别名]
# 或者: from models.Team import all [as 别名]
 def get(self):
     
     memcache_key = "team_list"
     html = memcache.get(memcache_key)
     
     if html is None:
         teams = Team.all().order('team_number').fetch(10000)        
     
         template_values = {
             "teams": teams,
         }
     
         path = os.path.join(os.path.dirname(__file__), '../templates/teams/list.html')
         html = template.render(path, template_values)
         memcache.set(memcache_key, html, 3600)
     
     self.response.out.write(html)
开发者ID:Apple101Review,项目名称:the-blue-alliance,代码行数:19,代码来源:team_controller.py

示例14: __now__

# 需要导入模块: from models import Team [as 别名]
# 或者: from models.Team import all [as 别名]
 def __now__(self):
     ''' Returns snapshot object it as a dict '''
     snapshot = Snapshot()
     bot_manager = BotManager.Instance()
     for team in Team.all():
         snapshot_team = SnapshotTeam(
             team_id=team.id,
             money=team.money,
             bots=bot_manager.count_by_team(team)
         )
         snapshot_team.game_levels = team.game_levels
         snapshot_team.flags = team.flags
         dbsession.add(snapshot_team)
         dbsession.flush()
         snapshot.teams.append(snapshot_team)
     dbsession.add(snapshot)
     dbsession.flush()
     return snapshot
开发者ID:CRYPTOlab,项目名称:RootTheBox,代码行数:20,代码来源:GameHistory.py

示例15: createOrUpdate

# 需要导入模块: from models import Team [as 别名]
# 或者: from models.Team import all [as 别名]
    def createOrUpdate(self, new_team):
        """
        Check if a team currently exists in the database based on team_number
        If it does, update the team.
        If it does not, create the team.
        """
        query = Team.all()

        # First, do the easy thing and look for an eid collision. 
        # This will only work on USFIRST teams.
        query.filter('team_number =', new_team.team_number)

        if query.count() > 0:
            old_team = query.get()
            new_team = self.updateMerge(new_team, old_team)

        new_team.put()
        return new_team
开发者ID:Apple101Review,项目名称:the-blue-alliance,代码行数:20,代码来源:team_helper.py


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