Exemple #1
0
    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')
Exemple #2
0
 def getmatchv1(self, matchrequest_id):
     try:
         request = Session.query(MatchRequest).filter(MatchRequest.matchrequest_id == matchrequest_id).first()
         if request is not None:
             options = []
             for option in request.options:
                 options.append(option.option_name)
             newresulttoreturn = {
                'matchrequest_id': request.matchrequest_id,
                'map_name': request.map.map_name,
                'mod_name': request.mod.mod_name,
                'ais': [ { 'ai_name': request.ai0.ai_name, 'ai_version': request.ai0.ai_version },
                   { 'ai_name': request.ai1.ai_name, 'ai_version': request.ai1.ai_version } ],
                'options': options,
                'ai0_side': { 'mod_side_name' : request.ai0_side.mod_side_name, 'mod_side_id' : request.ai0_side.mod_side_id},
                'ai1_side': { 'mod_side_name' : request.ai1_side.mod_side_name, 'mod_side_id' : request.ai1_side.mod_side_id}
             }
             if request.matchrequestinprogress.botrunner != None:
                 newresulttoreturn['botrunner_name'] = [True, request.matchrequestinprogress.botrunner.botrunner_name]
             else:
                 newresulttoreturn['botrunner_name'] = [False, '']
             if request.matchresult != None:
                 newresulttoreturn['matchresult'] = [True, request.matchresult.matchresult]
             else:
                 newresulttoreturn['matchresult'] = [False, '']
             if os.path.isfile(replaycontroller.getReplayPath(request.matchrequest_id) ):
                 newresulttoreturn['replayrelativeurl'] = replaycontroller.getReplayWebRelativePath(request.matchrequest_id)
             if os.path.isfile( replaycontroller.getInfologPath(request.matchrequest_id) ):
                 newresulttoreturn['infologrelativeurl'] = replaycontroller.getInfologWebRelativePath(request.matchrequest_id)
             return [True, newresulttoreturn]
         else:
             return [False, 'no match with such id']
     except:
         return (False,"An unexpected exception occurred: " + str( sys.exc_info() ) + "\n" + str( traceback.extract_tb( sys.exc_traceback ) ) )
Exemple #3
0
 def getmatchresultsv1(self):
     try:
         requests = Session.query(MatchRequest).filter(MatchRequest.matchresult != None )
         resultstoreturn = []
         for request in requests:
             options = []
             for option in request.options:
                 options.append(option.option_name)
             newresulttoreturn = {
                'matchrequest_id': request.matchrequest_id,
                'map_name': request.map.map_name,
                'mod_name': request.mod.mod_name,
                'ais': [ { 'ai_name': request.ai0.ai_name, 'ai_version': request.ai0.ai_version },
                   { 'ai_name': request.ai1.ai_name, 'ai_version': request.ai1.ai_version } ],
                'options': options,
                'botrunner_name': request.matchrequestinprogress.botrunner.botrunner_name,
                'matchresult': request.matchresult.matchresult
             }
             if os.path.isfile( replaycontroller.getReplayPath(request.matchrequest_id) ):
                 newresulttoreturn['replayrelativeurl'] = replaycontroller.getReplayWebRelativePath(request.matchrequest_id)
             if os.path.isfile( replaycontroller.getInfologPath(request.matchrequest_id) ):
                 newresulttoreturn['infologrelativeurl'] = replaycontroller.getInfologWebRelativePath(request.matchrequest_id)
             resultstoreturn.append( newresulttoreturn )
         return [True, resultstoreturn ]
     except:
         return (False,"An unexpected exception occurred: " + str( sys.exc_info() ) + "\n" + str( traceback.extract_tb( sys.exc_traceback ) ) )
    def submitresult(self, botrunnername, sharedsecret, matchrequestid,
            resultstring, uploaddatadict):
        if not botrunnerhelper.validatesharedsecret(botrunnername,
                sharedsecret):
            return (False, "Not authenticated")

      # check if this matchrequest_id was actually assigned to this engine
      # otherwise ditch the result
        if not matchrequestcontroller.matchrequestvalidforthisserver(
                botrunnername, matchrequestid):
            return (False, "invalid matchrequestid")

      # store the result, and remove from queue
      # if the replay upload fails, well, that's a shame, but it's not the end
      # of the world...
      # or we could get the botrunner to retry several times, to be decided.
        matchrequestcontroller.storeresult(botrunnername, matchrequestid,
                resultstring)

        if 'replay' in uploaddatadict:
          # now to handle uploading the replay...
            replaycontentsraw = uploaddatadict['replay'].data
            if replaycontentsraw != None and replaycontentsraw != '':
                replayfilehandle = open(replaycontroller.getReplayPath(
                    matchrequestid), "wb")
                replayfilehandle.write(replaycontentsraw)
                replayfilehandle.close()
                # really, we should validate that this match was assigned
                # to this server first...
                # also, ideally, if there is no upload, we should store that
                # info in the database somewhere

        if 'infolog' in uploaddatadict:
            contentsraw = uploaddatadict['infolog'].data
            if contentsraw != None and contentsraw != '':
                filehandle = open(replaycontroller.getInfologPath(
                    matchrequestid), "wb")
                filehandle.write(contentsraw)
                filehandle.close()

        return (True, '')