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
Example #2
0
def setbotrunnernotsupportsthisai(botrunnername, ainame, aiversion):
    botrunner = botrunnerhelper.getBotRunner(botrunnername)
    for ai in botrunner.supportedais:
        if ai.ai_name == ainame and ai.ai_version == aiversion:
            botrunner.supportedais.remove(ai)
    sqlalchemysetup.session.commit()
    return (True, "")
Example #3
0
def getsupportedais( botrunnername ):
   botrunner = botrunnerhelper.getBotRunner(botrunnername)
   if botrunner == None:
      return []
   supportedais = []
   for ai in botrunner.supportedais:
      supportedais.append( [ ai.ai.ai_name, ai.ai.ai_version ] )

   return supportedais
Example #4
0
def getsupportedais(botrunnername):
    botrunner = botrunnerhelper.getBotRunner(botrunnername)
    if botrunner == None:
        return []
    supportedais = []
    for ai in botrunner.supportedais:
        supportedais.append([ai.ai.ai_name, ai.ai.ai_version])

    return supportedais
Example #5
0
def setbotrunnersupportsthisai( botrunnername, ainame, aiversion ):
   botrunner = botrunnerhelper.getBotRunner( botrunnername )
   for ai in botrunner.supportedais:
      if ai.ai.ai_name == ainame and ai.ai.ai_version == aiversion:
       return (True,'')

   ai = getAI(ainame,aiversion)
   botrunner.supportedais.append(BotRunnerSupportedAI(ai))
   sqlalchemysetup.session.commit()
   return (True,'')
Example #6
0
def setbotrunnersupportsthismod( botrunnername, modname ):
   # Now, register the mod as supported mod
   botrunner = botrunnerhelper.getBotRunner( botrunnername )
   for mod in botrunner.supportedmods:
      if mod.mod_name == modname:
       return (True,'')
   mod = getMod(modname)
   botrunner.supportedmods.append(mod)
   sqlalchemysetup.session.commit()
   return (True,'')
Example #7
0
def getsupportedmods( botrunnername ):
   botrunner = botrunnerhelper.getBotRunner( botrunnername )
   if botrunner == None:
      return []
   if botrunner.supportedmods == None:
      return []
   supportedmodnames = []
   for mod in botrunner.supportedmods:
      supportedmodnames.append(mod.mod_name)
   return supportedmodnames
Example #8
0
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, "")
Example #9
0
def getsupportedmaps(botrunnername):
    botrunner = botrunnerhelper.getBotRunner(botrunnername)
    if botrunner == None:
        return []
    if botrunner.supportedmaps == None:
        return []
    supportedmapnames = []
    for map in botrunner.supportedmaps:
        supportedmapnames.append(map.map_name)
    return supportedmapnames
Example #10
0
def setbotrunnersupportsthisai(botrunnername, ainame, aiversion):
    botrunner = botrunnerhelper.getBotRunner(botrunnername)
    for ai in botrunner.supportedais:
        if ai.ai.ai_name == ainame and ai.ai.ai_version == aiversion:
            return (True, '')

    ai = getAI(ainame, aiversion)
    botrunner.supportedais.append(BotRunnerSupportedAI(ai))
    sqlalchemysetup.session.commit()
    return (True, '')
Example #11
0
def setbotrunnersupportsthismap(botrunnername, mapname):
    # Now, register the map as supported map
    botrunner = botrunnerhelper.getBotRunner(botrunnername)
    for map in botrunner.supportedmaps:
        if map.map.map_name == mapname:
            return (True, '')
    map = getMap(mapname)
    botrunner.supportedmaps.append(BotRunnerSupportedMap(map))
    sqlalchemysetup.session.commit()
    return (True, '')
Example #12
0
def getsupportedmaps(botrunnername):
    botrunner = botrunnerhelper.getBotRunner(botrunnername)
    if botrunner == None:
        return []
    if botrunner.supportedmaps == None:
        return []
    supportedmapnames = []
    for map in botrunner.supportedmaps:
        supportedmapnames.append(map.map.map_name)
    return supportedmapnames
Example #13
0
def setbotrunnersupportsthismod(botrunnername, modname):
    # Now, register the mod as supported mod
    botrunner = botrunnerhelper.getBotRunner(botrunnername)
    for mod in botrunner.supportedmods:
        if mod.mod.mod_name == modname:
            return (True, '')
    mod = getMod(modname)
    botrunner.supportedmods.append(BotRunnerSupportedMod(mod))
    sqlalchemysetup.session.commit()
    return (True, '')
Example #14
0
def getsupportedmods(botrunnername):
    botrunner = botrunnerhelper.getBotRunner(botrunnername)
    if botrunner == None:
        return []
    if botrunner.supportedmods == None:
        return []
    supportedmodnames = []
    for mod in botrunner.supportedmods:
        supportedmodnames.append(mod.mod.mod_name)
    return supportedmodnames
def getcompatibleitemfromqueue(botrunnername, sessionid):
    archiveoldrequests()

    botrunner = botrunnerhelper.getBotRunner(botrunnername)
    botrunnersession = botrunnerhelper.getBotRunnerSession(botrunnername, sessionid)

    # Also, remove any requests that this engine was supposedly processing
    # for which there are no results
    matchrequests = (
        sqlalchemysetup.session.query(MatchRequest)
        .filter(MatchRequest.matchresult == None)
        .filter(MatchRequest.matchrequestinprogress != None)
    )
    for matchrequest in matchrequests:
        if matchrequest.matchrequestinprogress.botrunner is botrunner:
            if matchrequest.matchrequestinprogress.botrunnersession is botrunnersession:
                sqlalchemysetup.session.delete(matchrequest.matchrequestinprogress)
    sqlalchemysetup.session.commit()

    # 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 = (
        sqlalchemysetup.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_name == matchrequest.ai0.ai_name and ai.ai_version == matchrequest.ai0.ai_version:
                ai0ok = True
            if ai.ai_name == matchrequest.ai1.ai_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, dates.dateTimeToDateString(datetime.datetime.now())
            )

            return matchrequest

    # didn't find any compatible match
    return None
Example #16
0
def getcompatibleitemfromqueue(botrunnername, sessionid):
    archiveoldrequests()

    botrunner = botrunnerhelper.getBotRunner(botrunnername)
    botrunnersession = botrunnerhelper.getBotRunnerSession(
        botrunnername, sessionid)

    # Also, remove any requests that this engine was supposedly processing
    # for which there are no results
    matchrequests = sqlalchemysetup.session.query(MatchRequest).filter(
        MatchRequest.matchresult == None).filter(
            MatchRequest.matchrequestinprogress != None)
    for matchrequest in matchrequests:
        if matchrequest.matchrequestinprogress.botrunner is botrunner:
            if matchrequest.matchrequestinprogress.botrunnersession is botrunnersession:
                sqlalchemysetup.session.delete(
                    matchrequest.matchrequestinprogress)
    sqlalchemysetup.session.commit()

    # 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 = sqlalchemysetup.session.query(MatchRequest).filter(
        MatchRequest.matchrequestinprogress == None).filter(
            MatchRequest.matchresult == None).all()
    for matchrequest in matchrequests:
        mapok = False
        for map in botrunner.supportedmaps:
            if map.map.map_name == matchrequest.map.map_name:
                mapok = True
        modok = False
        for mod in botrunner.supportedmods:
            if mod.mod.mod_name == matchrequest.mod.mod_name:
                modok = True
        if mapok and modok:
            # mark request in progress:
            matchrequest.matchrequestinprogress = MatchRequestInProgress(
                botrunner, botrunnersession,
                dates.dateTimeToDateString(datetime.datetime.now()))

            return matchrequest

    # didn't find any compatible match
    return None