本文整理汇总了Python中models.Team.Team.all方法的典型用法代码示例。如果您正苦于以下问题:Python Team.all方法的具体用法?Python Team.all怎么用?Python Team.all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Team.Team
的用法示例。
在下文中一共展示了Team.all方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: score_bots
# 需要导入模块: from models.Team import Team [as 别名]
# 或者: from models.Team.Team import all [as 别名]
def score_bots():
''' Award money for botnets '''
logging.info("Scoring botnets, please wait ...")
bot_manager = BotManager.instance()
for team in Team.all():
bots = bot_manager.by_team(team.name)
reward = 0
for bot in bots:
try:
reward += options.bot_reward
bot.write_message({
'opcode': 'status',
'message': 'Collected $%d reward' % options.bot_reward
})
except:
logging.info(
"Bot at %s failed to respond to score ping" % bot.remote_ip
)
if 0 < len(bots):
logging.info("%s was awarded $%d for controlling %s bot(s)" % (
team.name, reward, len(bots),
))
bot_manager.add_rewards(team.name, options.bot_reward)
bot_manager.notify_monitors(team.name)
team.money += reward
dbsession.add(team)
dbsession.flush()
dbsession.commit()
示例2: ls
# 需要导入模块: from models.Team import Team [as 别名]
# 或者: from models.Team.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()
示例3: now
# 需要导入模块: from models.Team import Team [as 别名]
# 或者: from models.Team.Team import all [as 别名]
def now(self, app):
''' Returns the current game state '''
game_state = {}
for team in Team.all():
if len(team.members) > 0:
millis = int(round(time.time() * 1000))
game_state[team.name] = {
'uuid': team.uuid,
'flags': [str(flag) for flag in team.flags],
'game_levels': [str(lvl) for lvl in team.game_levels],
}
highlights = {'money': 0, 'flag': 0, 'bot': 0, 'hint': 0}
for item in highlights:
value = team.get_score(item)
game_state[team.name][item] = value
game_history = app.settings['scoreboard_history']
if team.name in game_history:
prev = game_history[team.name][item]
if prev < value:
highlights[item] = millis
else:
highlights[item] = game_history[team.name]['highlights'][item]
highlights['now'] = millis
game_state[team.name]['highlights'] = highlights
app.settings['scoreboard_history'][team.name] = game_state.get(team.name)
return json.dumps(game_state)
示例4: now
# 需要导入模块: from models.Team import Team [as 别名]
# 或者: from models.Team.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)
示例5: now
# 需要导入模块: from models.Team import Team [as 别名]
# 或者: from models.Team.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)
示例6: existing_avatars
# 需要导入模块: from models.Team import Team [as 别名]
# 或者: from models.Team.Team import all [as 别名]
def existing_avatars(dir):
avatars = []
if dir == "team":
from models.Team import Team
teams = Team.all()
for team in teams:
if team.avatar is not None and len(team.members) > 0:
avatars.append(team.avatar)
else:
from models.User import User
users = User.all()
for user in users:
if user.avatar is not None:
avatars.append(user.avatar)
return avatars
示例7: __now__
# 需要导入模块: from models.Team import Team [as 别名]
# 或者: from models.Team.Team import all [as 别名]
def __now__(self):
''' Returns snapshot object it as a dict '''
snapshot = Snapshot()
bot_manager = BotManager.instance()
#self.dbsession = DBSession()
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
self.dbsession.add(snapshot_team)
self.dbsession.flush()
snapshot.teams.append(snapshot_team)
self.dbsession.add(snapshot)
self.dbsession.commit()
return snapshot
示例8: get_new_avatar
# 需要导入模块: from models.Team import Team [as 别名]
# 或者: from models.Team.Team import all [as 别名]
def get_new_avatar(dir, forceteam=False):
avatar = default_avatar(dir)
avatars = filter_avatars(dir)
if len(avatars) == 0:
return avatar
if dir == 'team' or forceteam:
from models.Team import Team
cmplist = Team.all()
elif dir == 'user':
from models.User import User
cmplist = User.all()
else:
from models.Box import Box
cmplist = Box.all()
dblist = []
for item in cmplist:
if item._avatar:
dblist.append(item._avatar)
for image in avatars:
if not image in dblist:
return image
return avatars[randint(0, len(avatars)-1)]
示例9: post
# 需要导入模块: from models.Team import Team [as 别名]
# 或者: from models.Team.Team import all [as 别名]
def post(self, *args, **kwargs):
try:
group = self.get_argument('team_uuid', 'all')
message = self.get_argument('message', '')
value = int(self.get_argument('money', 0))
if group == 'all':
teams = Team.all()
for team in teams:
team.money += value
self.dbsession.add(team)
self.event_manager.admin_score_update(team, message, value)
else:
team = Team.by_uuid(group)
team.money += value
self.dbsession.add(team)
self.event_manager.admin_score_update(team, message, value)
self.dbsession.commit()
self.redirect('/admin/users')
except ValidationError as error:
self.render('admin/view/users.html',
errors=[str(error), ]
)
示例10: score_bots
# 需要导入模块: from models.Team import Team [as 别名]
# 或者: from models.Team.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.info("%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()
dbsession.commit()
示例11: export_users
# 需要导入模块: from models.Team import Team [as 别名]
# 或者: from models.Team.Team import all [as 别名]
def export_users(self, root):
teams_elem = ET.SubElement(root, "teams")
teams_elem.set("count", str(Team.count()))
for team in Team.all():
team.to_xml(teams_elem)