Beispiel #1
0
    def getPersonalBests(self, carid, custid):
        """
        Returns a list of personal bests for the specified car and driver
        """
        self.__logger.info("Getting personal bests for %d" % custid)
        url = "http://members.iracing.com/memberstats/member/GetPersonalBests"
        params = urllib.urlencode({"carid":carid, "custid":custid})
        params = params.encode('utf-8')

        response = self.__readUrl(url, params)
        jsondata = json.loads(response.read())
        
        laps = []
        
        for jsonlaptime in jsondata:
            trackid = jsonlaptime['trackid']
#            trackname = urllib.unquote(jsonlaptime['trackname']).replace("+"," ")
#            trackconfigname = urllib.unquote(jsonlaptime['trackconfigname']).replace("+"," ")

            bestlaptimeformatted = urllib.unquote(jsonlaptime['bestlaptimeformatted'])
            besttime = iRacingUtils.getTimeDelta(bestlaptimeformatted)
            
            eventtypename = urllib.unquote(jsonlaptime['eventtypename']).replace("+"," ")
            
            eventtype = Driver.EVENT_TYPES.get(eventtypename, None)
            if eventtype is None:
                pass
            
            assert(eventtype is not None)
            laps.append(Laptime(trackid, eventtype, besttime))
            
        return laps
Beispiel #2
0
    def getPersonalBests(self, carid, custid):
        """
        Returns a list of personal bests for the specified car and driver
        """
        self.__logger.info("Getting personal bests for %d" % custid)
        url = "http://members.iracing.com/memberstats/member/GetPersonalBests"
        params = urllib.urlencode({"carid": carid, "custid": custid})
        params = params.encode('utf-8')

        response = self.__readUrl(url, params)
        jsondata = json.loads(response.read())

        laps = []

        for jsonlaptime in jsondata:
            trackid = jsonlaptime['trackid']
            #            trackname = urllib.unquote(jsonlaptime['trackname']).replace("+"," ")
            #            trackconfigname = urllib.unquote(jsonlaptime['trackconfigname']).replace("+"," ")

            bestlaptimeformatted = urllib.unquote(
                jsonlaptime['bestlaptimeformatted'])
            besttime = iRacingUtils.getTimeDelta(bestlaptimeformatted)

            eventtypename = urllib.unquote(
                jsonlaptime['eventtypename']).replace("+", " ")

            eventtype = Driver.EVENT_TYPES.get(eventtypename, None)
            if eventtype is None:
                pass

            assert (eventtype is not None)
            laps.append(Laptime(trackid, eventtype, besttime))

        return laps
Beispiel #3
0
 def getSessionResults(self, subsessionid):
     """
     Returns a a list of RaceResult objects for the specified race session
     """
     self.__logger.debug("Download results of race %d" % subsessionid)
     
     url = 'http://members.iracing.com/membersite/member/GetEventResultsAsCSV?subsessionid=%d' % int(subsessionid)
     fieldnames, rows = self.__readCSVFromUrl(url)
     
     finposIdx = fieldnames.index('Fin Pos')
     caridIdx= fieldnames.index('Car ID')
     carIdx = fieldnames.index('Car')
     carclassidIdx = fieldnames.index('Car Class ID')
     carclassIdx = fieldnames.index('Car Class')
     custidIdx = fieldnames.index('Custid')
     driverIdx = fieldnames.index('Driver')
     startposIdx = fieldnames.index('Start Pos')
     carnumIdx = fieldnames.index('Car #')
     outidIdx = fieldnames.index('Out ID')
     outIdx = fieldnames.index('Out')
     intervalIdx = fieldnames.index('Interval')
     lapsledIdx = fieldnames.index('Laps Led')
     averagelaptimeIdx = fieldnames.index('Average Lap Time')
     fastestlaptimeIdx = fieldnames.index('Fastest Lap Time')
     fastlapnumIdx = fieldnames.index('Fast Lap#')
     lapscompIdx = fieldnames.index('Laps Comp')
     incIdx = fieldnames.index('Inc')
     ptsIdx = fieldnames.index('Pts')
     clubptsIdx = fieldnames.index('Club Pts')
     divIdx = fieldnames.index('Div')
     clubidIdx = fieldnames.index('Club ID')
     clubIdx = fieldnames.index('Club')
     oldiratingIdx = fieldnames.index('Old iRating')
     newiratingIdx = fieldnames.index('New iRating')
     oldlicenselevelIdx = fieldnames.index('Old License Level')
     oldlicensesublevelIdx = fieldnames.index('Old License Sub-Level')
     newlicenselevelIdx = fieldnames.index('New License Level')
     newlicensesublevelIdx = fieldnames.index('New License Sub-Level')
     seriesnameIdx = fieldnames.index('Series Name')
     
     raceResults = list()
     
     for row in rows:
         finpos = int(row[finposIdx])
         carid = int(row[caridIdx])
         car = row[carIdx]
         carclassid = int(row[carclassidIdx])
         carclass = row[carclassIdx]
         custid = int(row[custidIdx])
         driver = row[driverIdx]
         startpos = int(row[startposIdx])
         carnum = int(row[carnumIdx])
         outid = int(row[outidIdx])
         out = row[outIdx]
         interval = row[intervalIdx]
         lapsled = int(row[lapsledIdx])
         averagelaptime = iRacingUtils.getTimeDelta(row[averagelaptimeIdx])
         fastestlaptime = iRacingUtils.getTimeDelta(row[fastestlaptimeIdx])
         
         fastlapnumStr = row[fastlapnumIdx]
         if len(fastlapnumStr) == 0:
             fastlapnum = -1
         else:
             fastlapnum = int(fastlapnumStr)
         lapscomp = int(row[lapscompIdx])
         inc = int(row[incIdx])
         pts = int(row[ptsIdx])
         clubpts = int(row[clubptsIdx])
         if row[divIdx].isdigit():
             div = int(row[divIdx])
         else:
             div = 0
         
         clubid = int(row[clubidIdx])
         club = row[clubIdx]
         oldirating = int(row[oldiratingIdx])
         newirating = int(row[newiratingIdx])
         oldlicenselevel = int(row[oldlicenselevelIdx])
         oldlicensesublevel = int(row[oldlicensesublevelIdx])
         newlicenselevel = int(row[newlicenselevelIdx])
         newlicensesublevel = int(row[newlicensesublevelIdx])
         seriesname = row[seriesnameIdx]
         raceResults.append(SessionResult(subsessionid, finpos, carid, car, carclassid, carclass, custid, driver, startpos, carnum, outid, out, interval, lapsled, averagelaptime, fastestlaptime, fastlapnum, lapscomp, inc, pts, clubpts, div, clubid, club, oldirating, newirating, oldlicenselevel, oldlicensesublevel, newlicenselevel, newlicensesublevel, seriesname))
     
     return raceResults
Beispiel #4
0
    def getSessionResults(self, subsessionid):
        """
        Returns a a list of RaceResult objects for the specified race session
        """
        self.__logger.debug("Download results of race %d" % subsessionid)

        url = 'http://members.iracing.com/membersite/member/GetEventResultsAsCSV?subsessionid=%d' % int(
            subsessionid)
        fieldnames, rows = self.__readCSVFromUrl(url)

        finposIdx = fieldnames.index('Fin Pos')
        caridIdx = fieldnames.index('Car ID')
        carIdx = fieldnames.index('Car')
        carclassidIdx = fieldnames.index('Car Class ID')
        carclassIdx = fieldnames.index('Car Class')
        custidIdx = fieldnames.index('Custid')
        driverIdx = fieldnames.index('Driver')
        startposIdx = fieldnames.index('Start Pos')
        carnumIdx = fieldnames.index('Car #')
        outidIdx = fieldnames.index('Out ID')
        outIdx = fieldnames.index('Out')
        intervalIdx = fieldnames.index('Interval')
        lapsledIdx = fieldnames.index('Laps Led')
        averagelaptimeIdx = fieldnames.index('Average Lap Time')
        fastestlaptimeIdx = fieldnames.index('Fastest Lap Time')
        fastlapnumIdx = fieldnames.index('Fast Lap#')
        lapscompIdx = fieldnames.index('Laps Comp')
        incIdx = fieldnames.index('Inc')
        ptsIdx = fieldnames.index('Pts')
        clubptsIdx = fieldnames.index('Club Pts')
        divIdx = fieldnames.index('Div')
        clubidIdx = fieldnames.index('Club ID')
        clubIdx = fieldnames.index('Club')
        oldiratingIdx = fieldnames.index('Old iRating')
        newiratingIdx = fieldnames.index('New iRating')
        oldlicenselevelIdx = fieldnames.index('Old License Level')
        oldlicensesublevelIdx = fieldnames.index('Old License Sub-Level')
        newlicenselevelIdx = fieldnames.index('New License Level')
        newlicensesublevelIdx = fieldnames.index('New License Sub-Level')
        seriesnameIdx = fieldnames.index('Series Name')

        raceResults = list()

        for row in rows:
            finpos = int(row[finposIdx])
            carid = int(row[caridIdx])
            car = row[carIdx]
            carclassid = int(row[carclassidIdx])
            carclass = row[carclassIdx]
            custid = int(row[custidIdx])
            driver = row[driverIdx]
            startpos = int(row[startposIdx])
            carnum = int(row[carnumIdx])
            outid = int(row[outidIdx])
            out = row[outIdx]
            interval = row[intervalIdx]
            lapsled = int(row[lapsledIdx])
            averagelaptime = iRacingUtils.getTimeDelta(row[averagelaptimeIdx])
            fastestlaptime = iRacingUtils.getTimeDelta(row[fastestlaptimeIdx])

            fastlapnumStr = row[fastlapnumIdx]
            if len(fastlapnumStr) == 0:
                fastlapnum = -1
            else:
                fastlapnum = int(fastlapnumStr)
            lapscomp = int(row[lapscompIdx])
            inc = int(row[incIdx])
            pts = int(row[ptsIdx])
            clubpts = int(row[clubptsIdx])
            if row[divIdx].isdigit():
                div = int(row[divIdx])
            else:
                div = 0

            clubid = int(row[clubidIdx])
            club = row[clubIdx]
            oldirating = int(row[oldiratingIdx])
            newirating = int(row[newiratingIdx])
            oldlicenselevel = int(row[oldlicenselevelIdx])
            oldlicensesublevel = int(row[oldlicensesublevelIdx])
            newlicenselevel = int(row[newlicenselevelIdx])
            newlicensesublevel = int(row[newlicensesublevelIdx])
            seriesname = row[seriesnameIdx]
            raceResults.append(
                SessionResult(subsessionid, finpos, carid, car, carclassid,
                              carclass, custid, driver, startpos, carnum,
                              outid, out, interval, lapsled, averagelaptime,
                              fastestlaptime, fastlapnum, lapscomp, inc, pts,
                              clubpts, div, clubid, club, oldirating,
                              newirating, oldlicenselevel, oldlicensesublevel,
                              newlicenselevel, newlicensesublevel, seriesname))

        return raceResults