示例#1
0
文件: core.py 项目: skybon/obozrenie
    def get_servers_data(self, game: str) -> dict:
        if game in ("", None):
            raise ValueError(i18n._("Please specify a valid game id."))

        with self.__game_table as game_table:
            servers_data = helpers.deepcopy(game_table[game]["servers"])
        return servers_data
示例#2
0
    def get_servers_data(self, game: str) -> dict:
        if game in ('', None):
            raise ValueError(i18n._('Please specify a valid game id.'))

        with self.__game_table as game_table:
            servers_data = helpers.deepcopy(game_table[game]["servers"])
        return servers_data
示例#3
0
文件: core.py 项目: skybon/obozrenie
 def get_game_table_copy(self):
     """
     Returns a deep copy of the Game Table.
     It is the slowest accessor method. Please try to query for specific information.
     """
     with self.__game_table as game_table:
         game_table_copy = helpers.deepcopy(game_table)
     return game_table_copy
示例#4
0
 def get_game_table_copy(self):
     """
     Returns a deep copy of the Game Table.
     It is the slowest accessor method. Please try to query for specific information.
     """
     with self.__game_table as game_table:
         game_table_copy = helpers.deepcopy(game_table)
     return game_table_copy
示例#5
0
文件: gtk.py 项目: fabianod/obozrenie
    def fill_server_list_model(self, server_table):
        """Fill the server view"""

        view_table = helpers.deepcopy(server_table)

        model = self.gtk_widgets["server-list-model"]
        model_append = model.append
        model_format = self.server_list_model_format

        game_icons = self.game_icons
        flag_icons = self.flag_icons

        # Clears the model

        # UGLY HACK!
        # Workaround for chaotic TreeViewSelection on ListModel erase
        host_selection = gtk_helpers.get_widget_value(
            self.gtk_widgets["server-connect-host"])
        game_selection = gtk_helpers.get_widget_value(
            self.gtk_widgets["server-connect-game"])
        model.clear()
        gtk_helpers.set_widget_value(self.gtk_widgets["server-connect-host"],
                                     host_selection)
        gtk_helpers.set_widget_value(
            self.gtk_widgets["server-connect-game"],
            game_selection,
            treeview_colnum=self.game_list_model_format.index("game_id"))

        # Goodies for GUI
        for entry in view_table:
            game_id = entry.get("game_id")
            country = entry.get("country")
            # Game icon
            entry["game_icon"] = game_icons.get(game_id)

            # Lock icon
            if entry["password"] is True:
                entry["password_icon"] = "network-wireless-encrypted-symbolic"
            else:
                entry["password_icon"] = None

            if entry["secure"] is True:
                entry["secure_icon"] = "security-high-symbolic"
            else:
                entry["secure_icon"] = None

            # Country flags
            entry["country_icon"] = flag_icons.get(country)

            # Filtering stuff
            entry["full"] = entry["player_count"] >= entry["player_limit"]
            entry["empty"] = entry["player_count"] == 0

        view_table = helpers.sort_dict_table(view_table, "ping")
        server_list = helpers.dict_to_list(view_table, model_format)

        for entry in server_list:
            model_append(entry)
示例#6
0
文件: core.py 项目: skybon/obozrenie
    def get_query_status(self, game: str):
        if game in ("", None):
            raise ValueError(i18n._("Invalid game specified."))

        with self.__game_table as game_table:
            try:
                game_entry = game_table[game]
            except KeyError:
                raise ValueError(i18n._("Game not found: %(game)s") % {"game": game})

            query_status = helpers.deepcopy(game_entry["query-status"])
        return query_status
示例#7
0
文件: gtk.py 项目: skybon/obozrenie
    def fill_server_list_model(self, server_table):
        """Fill the server view"""

        view_table = helpers.deepcopy(server_table)

        model = self.gtk_widgets["server-list-model"]
        model_append = model.append
        model_format = self.server_list_model_format

        game_icons = self.game_icons
        flag_icons = self.flag_icons

        # Clears the model

        # UGLY HACK!
        # Workaround for chaotic TreeViewSelection on ListModel erase
        host_selection = gtk_helpers.get_widget_value(self.gtk_widgets["server-connect-host"])
        game_selection = gtk_helpers.get_widget_value(self.gtk_widgets["server-connect-game"])
        model.clear()
        gtk_helpers.set_widget_value(self.gtk_widgets["server-connect-host"], host_selection)
        gtk_helpers.set_widget_value(self.gtk_widgets["server-connect-game"], game_selection, treeview_colnum=self.game_list_model_format.index("game_id"))

        # Goodies for GUI
        for entry in view_table:
            game_id = entry.get("game_id")
            country = entry.get("country")
            # Game icon
            entry["game_icon"] = game_icons.get(game_id)

            # Lock icon
            if entry["password"] is True:
                entry["password_icon"] = "network-wireless-encrypted-symbolic"
            else:
                entry["password_icon"] = None

            if entry["secure"] is True:
                entry["secure_icon"] = "security-high-symbolic"
            else:
                entry["secure_icon"] = None

            # Country flags
            entry["country_icon"] = flag_icons.get(country)

            # Filtering stuff
            entry["full"] = entry["player_count"] >= entry["player_limit"]
            entry["empty"] = entry["player_count"] == 0

        view_table = helpers.sort_dict_table(view_table, "ping")
        server_list = helpers.dict_to_list(view_table, model_format)

        for entry in server_list:
            model_append(entry)
示例#8
0
    def get_query_status(self, game: str):
        if game in ('', None):
            raise ValueError(i18n._('Invalid game specified.'))

        with self.__game_table as game_table:
            try:
                game_entry = game_table[game]
            except KeyError:
                raise ValueError(
                    i18n._('Game not found: %(game)s') % {'game': game})

            query_status = helpers.deepcopy(game_entry["query-status"])
        return query_status
示例#9
0
文件: core.py 项目: skybon/obozrenie
    def get_game_info(self, game):
        """
        Returns information about the specified game.
        """
        if game in ("", None):
            raise ValueError(i18n._("Invalid game specified."))

        with self.__game_table as game_table:
            try:
                game_entry = game_table[game]
            except KeyError:
                raise ValueError(i18n._("Game not found: %(game)s") % {"game": game})

            game_info = helpers.deepcopy(game_entry["info"])
        return game_info
示例#10
0
    def get_game_info(self, game):
        """
        Returns information about the specified game.
        """
        if game in ('', None):
            raise ValueError(i18n._('Invalid game specified.'))

        with self.__game_table as game_table:
            try:
                game_entry = game_table[game]
            except KeyError:
                raise ValueError(
                    i18n._('Game not found: %(game)s') % {'game': game})

            game_info = helpers.deepcopy(game_entry["info"])
        return game_info
示例#11
0
文件: core.py 项目: skybon/obozrenie
    def set_server_info(self, game: str, host: str, data) -> None:
        faulty_param = None
        if game in ("", None):
            faulty_param = i18n._("game id")
        elif host in ("", None):
            faulty_param = i18n._("hostname")
        elif isinstance(data, dict) is False:
            faulty_param = i18n._("server data")
        if faulty_param is not None:
            raise ValueError(i18n._("Invalid %(param)s specified.") % {"param": param})

        with self.__game_table as game_table:
            server_entry_index = game_table[helpers.search_dict_table(helpers.deepcopy(game_table), "host", host)]
            if server_entry_index is None:
                self.append_server_info(game, data)
            else:
                game_table[server_entry_index] = data
示例#12
0
文件: core.py 项目: skybon/obozrenie
    def get_server_info(self, game: str, host: str) -> dict:
        faulty_param = None
        if game in ("", None):
            faulty_param = i18n._("game id")
        elif host in ("", None):
            faulty_param = i18n._("hostname")
        if faulty_param is not None:
            raise ValueError(i18n._("Invalid %(param)s specified.") % {"param": param})

        with self.__game_table as game_table:
            try:
                game_entry = game_table[game]
            except KeyError:
                raise ValueError(i18n._("Game not found: %(game)s") % {"game": game})

            server_table = helpers.deepcopy(game_entry["servers"])
        server_entry = server_table[helpers.search_dict_table(server_table, "host", host)]
        return server_entry
示例#13
0
    def set_server_info(self, game: str, host: str, data) -> None:
        faulty_param = None
        if game in ('', None):
            faulty_param = i18n._('game id')
        elif host in ('', None):
            faulty_param = i18n._('hostname')
        elif isinstance(data, dict) is False:
            faulty_param = i18n._('server data')
        if faulty_param is not None:
            raise ValueError(
                i18n._('Invalid %(param)s specified.') % {'param': param})

        with self.__game_table as game_table:
            server_entry_index = game_table[helpers.search_dict_table(
                helpers.deepcopy(game_table), "host", host)]
            if server_entry_index is None:
                self.append_server_info(game, data)
            else:
                game_table[server_entry_index] = data
示例#14
0
    def get_server_info(self, game: str, host: str) -> dict:
        faulty_param = None
        if game in ('', None):
            faulty_param = i18n._('game id')
        elif host in ('', None):
            faulty_param = i18n._('hostname')
        if faulty_param is not None:
            raise ValueError(
                i18n._('Invalid %(param)s specified.') % {'param': param})

        with self.__game_table as game_table:
            try:
                game_entry = game_table[game]
            except KeyError:
                raise ValueError(
                    i18n._('Game not found: %(game)s') % {'game': game})

            server_table = helpers.deepcopy(game_entry["servers"])
        server_entry = server_table[helpers.search_dict_table(
            server_table, "host", host)]
        return server_entry