本文整理汇总了Python中springgrid.lib.base.Session.query方法的典型用法代码示例。如果您正苦于以下问题:Python Session.query方法的具体用法?Python Session.query怎么用?Python Session.query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类springgrid.lib.base.Session
的用法示例。
在下文中一共展示了Session.query方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: addLeagueMatches
# 需要导入模块: from springgrid.lib.base import Session [as 别名]
# 或者: from springgrid.lib.base.Session import query [as 别名]
def addLeagueMatches(league, matchRequestQueue, matchResults):
ais = Session.query(AI).join(LeagueAI).filter(LeagueAI.league_id ==\
league.league_id).all()
map = Session.query(Map).filter(Map.map_id == league.map_id).first()
mod = Session.query(Mod).filter(Mod.mod_id == league.mod_id).first()
playAgainstSelf = league.play_against_self
if league.side_modes == "xvsy":
sides = [int(i) for i in league.sides.split("vs")]
else:
sides = [int(league.sides)]
matchRequests = []
for i, ai0 in enumerate(ais[:-1]):
for j, ai1 in enumerate(ais[i:]):
if not playAgainstSelf and ai0.ai_id == ai1.ai_id:
continue
first = Session.query(ModSide).filter(ModSide.mod_side_id == sides[0]).first()
if len(sides) == 2:
second = Session.query(ModSide).filter(ModSide.mod_side_id == sides[1]).first()
allSides = [(first, second), (second, first)]
else:
allSides = [(first, first)]
for firstSide, secondSide in allSides:
for k in xrange(league.matches_per_ai_pair):
matchRequest = MatchRequest(ai0, ai1, map, mod,\
league.speed, league.soft_timeout, league.hard_timeout,\
firstSide, secondSide, league.league_id)
matchRequests.append(matchRequest)
#save all matches to the database
Session.add_all(matchRequests)
Session.commit()
示例2: applydefaults
# 需要导入模块: from springgrid.lib.base import Session [as 别名]
# 或者: from springgrid.lib.base.Session import query [as 别名]
def applydefaults():
global defaults
for key_name in defaults.keys():
configrow = Session.query(Config).filter(Config.config_key == key_name).first()
if configrow == None:
setValue(key_name, defaults[key_name])
# purge extraneous values
for configrow in Session.query(Config):
if not defaults.has_key(configrow.config_key):
Session.delete(configrow)
Session.flush()
示例3: view
# 需要导入模块: from springgrid.lib.base import Session [as 别名]
# 或者: from springgrid.lib.base.Session import query [as 别名]
def view(self, id):
account = Session.query(Account).filter(
Account.account_id == id).first()
showform = roles.isInRole(roles.accountadmin)
potentialroles = [i[0] for i in Session.query(Role.role_name)]
for role in account.roles:
potentialroles.remove(role.role_name)
c.account = account
c.showForm = showform
return render('viewaccount.html')
示例4: results
# 需要导入模块: from springgrid.lib.base import Session [as 别名]
# 或者: from springgrid.lib.base.Session import query [as 别名]
def results(self):
c.requests = Session.query(MatchRequest).filter(
MatchRequest.matchresult != None)
try:
league_id = int(request.params['league'])
c.requests = c.requests.filter(MatchRequest.league_id == league_id)
except:
pass
page = 1
try:
page = int(request.params['page'])
except:
pass
c.requests = paginate.Page(
c.requests,
page=page,
items_per_page=20)
c.replayPaths = {}
c.infologPaths = {}
for req in c.requests:
replayPath = replaycontroller.getReplayPath(req.matchrequest_id)
if os.path.isfile(replayPath):
c.replayPaths[req] = replaycontroller.getReplayWebRelativePath(
req.matchrequest_id)
if os.path.isfile(
replaycontroller.getInfologPath(req.matchrequest_id)):
c.infologPaths[req] = replaycontroller.\
getInfologWebRelativePath(req.matchrequest_id)
return render('viewresults.html')
示例5: list
# 需要导入模块: from springgrid.lib.base import Session [as 别名]
# 或者: from springgrid.lib.base.Session import query [as 别名]
def list(self):
maps = Session.query(Map)
showForm = roles.isInRole(roles.mapadmin)
c.showForm = showForm
c.maps = maps
return render('viewmaps.html')
示例6: addmapifdoesntexist
# 需要导入模块: from springgrid.lib.base import Session [as 别名]
# 或者: from springgrid.lib.base.Session import query [as 别名]
def addmapifdoesntexist(mapname, maparchivechecksum):
map = Session.query(Map).filter(Map.map_name == mapname).first()
if map == None:
try:
map = Map(mapname)
map.map_archivechecksum = maparchivechecksum
Session.add(map)
Session.commit()
except:
return (False, "error adding to db: " + str(sys.exc_value))
return (True, "")
if map.map_archivechecksum == None:
map.map_archivechecksum = maparchivechecksum
try:
Session.commit()
return (True, "")
except:
return (False, "error updating db: " + str(sys.exc_value))
if map.map_archivechecksum != maparchivechecksum:
return (False, "map archive checksum doesn't match the one already on the website.")
return (True, "")
示例7: getcompatibleitemfromqueue
# 需要导入模块: from springgrid.lib.base import Session [as 别名]
# 或者: from springgrid.lib.base.Session import query [as 别名]
def getcompatibleitemfromqueue(botrunnername, sessionid):
archiveoldrequests()
botrunner = botrunnerhelper.getBotRunner( botrunnername )
botrunnersession = botrunnerhelper.getBotRunnerSession( botrunnername, sessionid )
# now we've archived the old requests, we just pick a request
# in the future, we'll pick a compatible request. In the future ;-)
# also, we need to handle options. In the future ;-)
matchrequests = Session.query(MatchRequest).filter(MatchRequest.matchrequestinprogress == None).filter(MatchRequest.matchresult == None).all()
for matchrequest in matchrequests:
mapok = False
modok = False
ai0ok = False
ai1ok = False
for map in botrunner.supportedmaps:
if map.map_name == matchrequest.map.map_name:
mapok = True
for mod in botrunner.supportedmods:
if mod.mod_name == matchrequest.mod.mod_name:
modok = True
for ai in botrunner.supportedais:
if ai.ai_base.ai_base_name == matchrequest.ai0.ai_base.ai_base_name and ai.ai_version == matchrequest.ai0.ai_version:
ai0ok = True
if ai.ai_base.ai_base_name == matchrequest.ai1.ai_base.ai_base_name and ai.ai_version == matchrequest.ai1.ai_version:
ai1ok = True
if mapok and modok and ai0ok and ai1ok:
# mark request in progress:
matchrequest.matchrequestinprogress = MatchRequestInProgress(botrunner, botrunnersession, datetime.datetime.now())
return matchrequest
# didn't find any compatible match
return None
示例8: list
# 需要导入模块: from springgrid.lib.base import Session [as 别名]
# 或者: from springgrid.lib.base.Session import query [as 别名]
def list(self):
engines = Session.query(Engine)
showForm = roles.isInRole(roles.modadmin)
c.showForm = showForm
c.engines = engines
return render('viewengines.html')
示例9: list
# 需要导入模块: from springgrid.lib.base import Session [as 别名]
# 或者: from springgrid.lib.base.Session import query [as 别名]
def list(self):
mods = Session.query(Mod)
showForm = roles.isInRole(roles.modadmin)
c.showForm = showForm
c.mods = mods
return render("viewmods.html")
示例10: requests
# 需要导入模块: from springgrid.lib.base import Session [as 别名]
# 或者: from springgrid.lib.base.Session import query [as 别名]
def requests(self):
c.requests = Session.query(MatchRequest).filter(
MatchRequest.matchresult == None)
try:
league_id = int(request.params['league'])
c.requests = c.requests.filter(MatchRequest.league_id == league_id)
except:
pass
page = 1
try:
page = int(request.params['page'])
except:
pass
c.requests = paginate.Page(
c.requests,
page=page,
items_per_page=20)
c.datetimeassignedbyrequest = {}
for req in c.requests:
if req.matchrequestinprogress != None:
c.datetimeassignedbyrequest[req] = \
req.matchrequestinprogress.datetimeassigned
return render('viewrequests.html')
示例11: remove
# 需要导入模块: from springgrid.lib.base import Session [as 别名]
# 或者: from springgrid.lib.base.Session import query [as 别名]
def remove(self, id):
if not roles.isInRole(roles.leagueadmin):
c.message = "You must be logged in as a leagueadmin"
return render('genericmessage.html')
league = Session.query(League).filter(League.league_id == id).first()
if league == None:
c.message = "No such league"
return render('genericmessage.html')
Session.query(LeagueAI).filter(LeagueAI.league_id == id).delete()
Session.delete(league)
Session.commit()
c.message = "Deleted ok"
return render('genericmessage.html')
示例12: list
# 需要导入模块: from springgrid.lib.base import Session [as 别名]
# 或者: from springgrid.lib.base.Session import query [as 别名]
def list(self):
ais = Session.query(AI)
showForm = roles.isInRole(roles.aiadmin)
c.ais = ais
c.showForm = showForm
return render("viewais.html")
示例13: validateUsernamePassword
# 需要导入模块: from springgrid.lib.base import Session [as 别名]
# 或者: from springgrid.lib.base.Session import query [as 别名]
def validateUsernamePassword(username, password):
account = Session.query(Account).filter(Account.username == username).first()
if account == None:
return False
if account.passwordinfo == None:
return False
result = account.passwordinfo.checkPassword(password)
return result
示例14: purgeExpiredSessions
# 需要导入模块: from springgrid.lib.base import Session [as 别名]
# 或者: from springgrid.lib.base.Session import query [as 别名]
def purgeExpiredSessions():
botrunners = Session.query(BotRunner)
for botrunner in botrunners:
for session in botrunner.sessions:
if session.lastpingtime != None:
secondssincelastping = dates.timedifftototalseconds(datetime.datetime.now() - session.lastpingtime)
if secondssincelastping > confighelper.getValue("expiresessionminutes") * 60:
expireBotRunnerSession(botrunner, session)
示例15: getValue
# 需要导入模块: from springgrid.lib.base import Session [as 别名]
# 或者: from springgrid.lib.base.Session import query [as 别名]
def getValue(key_name):
global defaults
if not defaults.has_key(key_name):
raise Exception("confighelper.setvalue, no such key_name: " + key_name)
configrow = Session.query(Config).filter(Config.config_key == key_name).first()
if configrow == None:
return populatedefault(key_name)
return configrow.getValue()