Beispiel #1
0
    def get_award(self, id):
        '''
        Provides details for a specific award based on the given award
        identifier.

        Args:
           id (string): The unique identifier of an award.

        Returns:
            award (object): Detailed information for a specific award.
        '''

        # Get the processor for the requested award
        processor = stat_mgr.get_processor(id)
        if not processor: raise cherrypy.HTTPError(404)

        processors = stat_mgr.get_processors(processor.processor_type)
        prev_id = None
        if processor.type_index > 0:
            prev_id = processors[processor.type_index - 1].id
        next_id = None
        if processor.type_index < len(processors) - 1:
            next_id = processors[processor.type_index + 1].id

        # Respond with a summary of the award information
        return {
            'id': processor.id,
            'name': processor.name,
            'desc': processor.desc,
            'columns': processor.columns,
            'notes': processor.notes,
            'rows': processor.get_results(),
            'prev_id': prev_id,
            'next_id': next_id
        }
Beispiel #2
0
    def GET(self, id=None):
        '''
        Provides a full game state model that includes all the kill packets
        parsed for the game with the given identifier.

        Args:
           id (string): The unique identifier of the game to include in the
                            response.

        Returns:
            state (GameState): Returns the full game state including kill
                            packets.
        '''

        # Use the replay stats processor to get the requested state
        processor = stat_mgr.get_processor('replays')
        if processor:
            if id and id != 'index.json':
                id = os.path.splitext(id)[0]
                return processor.get_game_state(id)
        return None
Beispiel #3
0
    def GET(self, packet_type=None, tick=None, _=None):
        '''
        Provides a list of log packets that were parsed since the given threshold.

        Args:
           packet_type (string): The type of log packets to include in the response. None indicates
                            all log types should be included.
           tick (long): A threshold after which log packets should be included.
           _ (long): A timestamp used to ensure the browser does not cache the request.

        Returns:
            packets (list): Returns the list of updated log packets.
        '''

        # Convert the tick value to a number
        if tick:
            tick = int(tick)

        # Use the live stats processor to get the requested packets
        processor = stat_mgr.get_processor('live')
        if processor:
            return processor.get_packets(packet_type, tick)
        return None
Beispiel #4
0
    def get_award(self, id):
        """
        Provides details for a specific award based on the given award
        identifier.

        Args:
           id (string): The unique identifier of an award.

        Returns:
            award (object): Detailed information for a specific award.
        """

        # Get the processor for the requested award
        processor = stat_mgr.get_processor(id)
        if not processor:
            raise cherrypy.HTTPError(404)

        processors = stat_mgr.get_processors(processor.processor_type)
        prev_id = None
        if processor.type_index > 0:
            prev_id = processors[processor.type_index - 1].id
        next_id = None
        if processor.type_index < len(processors) - 1:
            next_id = processors[processor.type_index + 1].id

        # Respond with a summary of the award information
        return {
            "id": processor.id,
            "name": processor.name,
            "desc": processor.desc,
            "columns": processor.columns,
            "notes": processor.notes,
            "rows": processor.get_results(),
            "prev_id": prev_id,
            "next_id": next_id,
        }