• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python base.Session类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中springgrid.lib.base.Session的典型用法代码示例。如果您正苦于以下问题:Python Session类的具体用法?Python Session怎么用?Python Session使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: setbotrunnernotsupportsthisai

def setbotrunnernotsupportsthisai(botrunnername, ainame, aiversion):
    botrunner = botrunnerhelper.getBotRunner( botrunnername )
    for ai in botrunner.supportedais:
        if ai.ai_base.ai_base_name == ainame and ai.ai_version == aiversion:
            botrunner.supportedais.remove( ai )
    Session.commit()
    return (True,'')
开发者ID:gajop,项目名称:springgrid,代码行数:7,代码来源:aihelper.py


示例2: storeresult

def storeresult( botrunnername, matchrequest_id, result ):
    # delete any existing result, saves doing check first...
    matchrequest = getmatchrequest( matchrequest_id )
    if matchrequest == None:
        return
    matchrequest.matchresult  = MatchResult( result )
    Session.commit()
开发者ID:gajop,项目名称:springgrid,代码行数:7,代码来源:matchrequestcontroller.py


示例3: setbotrunnersupportsthismap

def setbotrunnersupportsthismap(botrunnername, mapname):
    # Now, register the map as supported map
    botrunner = botrunnerhelper.getBotRunner(botrunnername)
    for map in botrunner.supportedmaps:
        if map.map_name == mapname:
            return (True, "")
    map = getMap(mapname)
    botrunner.supportedmaps.append(map)
    Session.commit()
    return (True, "")
开发者ID:gajop,项目名称:springgrid,代码行数:10,代码来源:maphelper.py


示例4: add

    def add(self):
        botrunnerName = self.form_result["botrunnerName"]
        sharedSecret = self.form_result["sharedSecret"]

        botrunner = BotRunner(botrunnerName, sharedSecret)
        Session.add(botrunner)
        Session.commit()

        c.message = "Added ok"
        return render('genericmessage.html')
开发者ID:gajop,项目名称:springgrid,代码行数:10,代码来源:botrunner.py


示例5: addLeagueMatches

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()
开发者ID:gajop,项目名称:springgrid,代码行数:33,代码来源:matchscheduler.py


示例6: addstaticdata

def addstaticdata():
    rolerows = Session.query(Role).all()
    for rolename in [ 'accountadmin', 'aiadmin', 'mapadmin', 'modadmin', 'leagueadmin', 'botrunneradmin', 'requestadmin', 'apiclient' ]:
        rolefound = False
        for rolerow in rolerows:
            if rolerow.role_name == rolename:
                rolefound = True
        if not rolefound:
            role = Role(rolename)
            Session.add(role)
            Session.flush()
开发者ID:gajop,项目名称:springgrid,代码行数:11,代码来源:roles.py


示例7: setValue

def setValue(key_name, key_value):
    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:
        config = Config(key_name, key_value)
        Session.add(config)
    else:
        configrow.setValue(key_value)
开发者ID:gajop,项目名称:springgrid,代码行数:12,代码来源:confighelper.py


示例8: view

    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')
开发者ID:gajop,项目名称:springgrid,代码行数:13,代码来源:account.py


示例9: logonUserWithAuthenticatedOpenID

def logonUserWithAuthenticatedOpenID(openidurl):
    account = None
    # note: this could be optimized a little...
    for thisaccount in Session.query(Account):
        for openid in thisaccount.openids:
            if openid.openid == openidurl:
                account = thisaccount
    if account == None:
        # create new account
        account = Account(openidurl, openidurl)
        account.openids.append(OpenID(openidurl))
        Session.add(account)

    session['username'] = openidurl
开发者ID:gajop,项目名称:springgrid,代码行数:14,代码来源:loginhelper.py


示例10: remove

    def remove(self, id):
        if not roles.isInRole(roles.modadmin):
            c.message = "You must be logged in as a modadmin, temporary!"
            return render('genericmessage.html')

        engine = Session.query(Engine).filter(Engine.engine_id == id).first()
        if engine == None:
            c.message = "No such engine"
            return render('genericmessage.html')

        Session.delete(engine)
        Session.commit()

        c.message = "Deleted ok"
        return render('genericmessage.html')
开发者ID:gajop,项目名称:springgrid,代码行数:15,代码来源:engine.py


示例11: remove

    def remove(self, id):
        if not roles.isInRole(roles.aiadmin):
            c.message = "You must be logged in as a aiadmin"
            return render("genericmessage.html")

        ai = Session.query(AI).filter(AI.ai_id == id).first()
        if ai == None:
            c.message = "No such ai"
            return render("genericmessage.html")

        Session.delete(ai)
        Session.commit()

        c.message = "Deleted ok"
        return render("genericmessage.html")
开发者ID:gajop,项目名称:springgrid,代码行数:15,代码来源:ai.py


示例12: remove

    def remove(self, id):
        if not roles.isInRole(roles.mapadmin):
            c.message = "You must be logged in as a mapadmin"
            return render('genericmessage.html')

        map = Session.query(Map).filter(Map.map_id == id).first()
        if map == None:
            c.message = "No such map"
            return render('genericmessage.html')

        Session.delete(map)
        Session.commit()

        c.message = "Deleted ok"
        return render('genericmessage.html')
开发者ID:gajop,项目名称:springgrid,代码行数:15,代码来源:map.py


示例13: remove

    def remove(self, id):
        if not roles.isInRole(roles.modadmin):
            c.message = "You must be logged in as a modadmin"
            return render("genericmessage.html")

        mod = Session.query(Mod).filter(Mod.mod_id == id).first()
        if mod == None:
            c.message = "No such mod"
            return render("genericmessage.html")

        Session.delete(mod)
        Session.commit()

        c.message = "Deleted ok"
        return render("genericmessage.html")
开发者ID:gajop,项目名称:springgrid,代码行数:15,代码来源:mod.py


示例14: list

    def list(self):
        maps = Session.query(Map)
        showForm = roles.isInRole(roles.mapadmin)

        c.showForm = showForm
        c.maps = maps
        return render('viewmaps.html')
开发者ID:gajop,项目名称:springgrid,代码行数:7,代码来源:map.py


示例15: list

    def list(self):
        mods = Session.query(Mod)
        showForm = roles.isInRole(roles.modadmin)

        c.showForm = showForm
        c.mods = mods
        return render("viewmods.html")
开发者ID:gajop,项目名称:springgrid,代码行数:7,代码来源:mod.py


示例16: requests

    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')
开发者ID:gajop,项目名称:springgrid,代码行数:27,代码来源:matches.py


示例17: results

    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')
开发者ID:gajop,项目名称:springgrid,代码行数:33,代码来源:matches.py


示例18: list

    def list(self):
        ais = Session.query(AI)
        showForm = roles.isInRole(roles.aiadmin)

        c.ais = ais
        c.showForm = showForm
        return render("viewais.html")
开发者ID:gajop,项目名称:springgrid,代码行数:7,代码来源:ai.py


示例19: list

    def list(self):
        engines = Session.query(Engine)
        showForm = roles.isInRole(roles.modadmin)

        c.showForm = showForm
        c.engines = engines
        return render('viewengines.html')
开发者ID:gajop,项目名称:springgrid,代码行数:7,代码来源:engine.py


示例20: getcompatibleitemfromqueue

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
开发者ID:gajop,项目名称:springgrid,代码行数:33,代码来源:matchrequestcontroller.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python context.ApplicationContext类代码示例发布时间:2022-05-27
下一篇:
Python api.Client类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap