예제 #1
0
    def render_GET(self, request):
        if "/".join(request.postpath) == "json":
            raw = True
            force_update = True
        else:
            raw = False
            force_update = False

        server_list = self.stats.get_server_list(force_update)

        if raw:
            # List of keys to be removed
            restricted = ["publicip", "__session__", "localip0", "localip1"]

            # Filter out certain fields before displaying raw data
            if server_list is not None:
                for game in server_list:
                    for server in server_list[game]:
                        for r in restricted:
                            if r in server:
                                server.pop(r, None)

            output = json.dumps(server_list)

        else:
            output = self.header
            if server_list is not None:
                output += "".join(self.row % (game, len(server_list[game]))
                                  for game in server_list if server_list[game])
            output += self.footer % (self.stats.get_last_update_time())

        return output
    def render_GET(self, request):
        if "/".join(request.postpath) == "json":
            raw = True
            force_update = True
        else:
            raw = False
            force_update = False

        server_list = self.stats.get_server_list(force_update)

        if raw:
            # List of keys to be removed
            restricted = ["publicip", "__session__", "localip0", "localip1"]

            # Filter out certain fields before displaying raw data
            if server_list is not None:
                for game in server_list:
                    for server in server_list[game]:
                        for r in restricted:
                            if r in server:
                                server.pop(r, None)

            output = json.dumps(server_list)

        else:
            output = self.header
            if server_list is not None:
                output += "".join(self.row % (game, len(server_list[game]))
                                  for game in server_list
                                  if server_list[game])
            output += self.footer % (self.stats.get_last_update_time())

        return output
    def render_GET(self, request):
        raw = False
        force_update = False

        if '/'.join(request.postpath) == "json":
            raw = True
            force_update = True

        server_list = self.stats.get_server_list(force_update)

        if raw == True:
            # List of keys to be removed

            restricted = ["__session__", "localip0", "localip1"]

            # Filter out certain fields before displaying raw data
            if server_list != None:
                for game in server_list:
                    for server in server_list[game]:
                        for r in restricted:
                            if r in server:
                                server.pop(r, None)

            output = json.dumps(server_list)

        else:
            output = "<html>"
            output += "<table border='1'>"
            output += "<tr>"
            output += "<td>Game ID</td><td># Players</td>"
            output += "</tr>"

            if server_list != None:
                for game in server_list:
                    if not server_list[game]:
                        continue

                    output += "<tr>"
                    output += "<td>" + game + "</td>"
                    output += "<td><center>%d</center></td>" % (len(
                        server_list[game]))
                    output += "</tr>"

            output += "</table>"

            output += "<br>"
            output += "<i>Last updated: %s</i><br>" % (
                self.stats.get_last_update_time())
            output += "</html>"

        return output
    def render_GET(self, request):
        raw = False
        force_update = False

        if '/'.join(request.postpath) == "json":
            raw = True
            force_update = True

        server_list = self.stats.get_server_list(force_update)

        if raw == True:
            # List of keys to be removed
            
            restricted = [ "__session__", "localip0", "localip1" ]

            # Filter out certain fields before displaying raw data
            if server_list != None:
                for game in server_list:
                    for server in server_list[game]:
                        for r in restricted:
                            if r in server:
                                server.pop(r, None)

            output = json.dumps(server_list)

        else:
            output = "<html>"
            output += "<table border='1'>"
            output += "<tr>"
            output += "<td>Game ID</td><td># Players</td>"
            output += "</tr>"

            if server_list != None:
                for game in server_list:
                    if not server_list[game]:
                        continue

                    output += "<tr>"
                    output += "<td>" + game + "</td>"
                    output += "<td><center>%d</center></td>" % (len(server_list[game]))
                    output += "</tr>"

            output += "</table>"

            output += "<br>"
            output += "<i>Last updated: %s</i><br>" % (self.stats.get_last_update_time())
            output += "</html>"

        return output