Exemple #1
0
def stat_master(game: str, game_info: dict, master_list: list):
    """Stats the master server"""
    server_table = []

    backend_config_object = helpers.load_table(BACKEND_CONFIG)

    protocol = backend_config_object["protocol"]["version"]

    for master_uri in master_list:
        master_page_uri = master_uri.strip("/") + "/?version=" + protocol
        try:
            master_page_object = requests.get(master_page_uri)
            master_page = master_page_object.text
        except:
            print(
                i18n._(RIGSOFRODS_MSG),
                i18n._("Accessing URI %(uri)s failed with error code %(code)s.")
                % {"uri": master_page_uri, "code": "unknown"},
            )
            continue

        try:
            temp_table = adapt_server_list(game, master_page)
        except:
            print(i18n._(RIGSOFRODS_MSG), i18n._("Error parsing URI %(uri)s.") % {"uri": master_page_uri})
            continue

        server_table += temp_table

    ping.add_rtt_info(server_table)

    return server_table, None
Exemple #2
0
def stat_master(game: str, game_info: dict, master_list: list):
  """Stats the master server"""
  try:
    backend_config_object = helpers.load_table(BACKEND_CONFIG)

    server_json_table = []
    server_table = []

    for master_uri in master_list:
        server_json_table += get_json(master_uri)

    for entry in server_json_table:
        entry_dict = parse_json_entry(entry)

        server_table.append(entry_dict)

    ping.add_rtt_info(server_table)

    for i in range(len(server_table)):
        entry = server_table[i]
        entry["game_id"] = game
        server_table[i] = entry

    return server_table
  except Exception as e:
    raise Exception(helpers.debug_msg_str([BACKENDCAT_MSG + MINETEST_MSG, e.args[0]]))
Exemple #3
0
def stat_master(game: str, game_info: dict, master_list: list):
    """Stats the master server"""
    try:
        backend_config_object = helpers.load_table(BACKEND_CONFIG)

        server_json_table = []
        server_table = []

        for master_uri in master_list:
            server_json_table += get_json(master_uri)

        for entry in server_json_table:
            entry_dict = parse_json_entry(entry)

            server_table.append(entry_dict)

        ping.add_rtt_info(server_table)

        for i in range(len(server_table)):
            entry = server_table[i]
            entry["game_id"] = game
            server_table[i] = entry

        return server_table
    except Exception as e:
        raise Exception(
            helpers.debug_msg_str([BACKENDCAT_MSG + MINETEST_MSG, e.args[0]]))
Exemple #4
0
def stat_master(game, game_info, master_list, proxy=None):
    """Stats the master server"""
    backend_config_object = helpers.load_table(BACKEND_CONFIG)

    server_json_table = []
    server_table = []

    for master_uri in master_list:
        master_page_uri = master_uri.strip('/') + '/list'
        try:
            server_json_table += get_json(master_page_uri)
        except (ConnectionError, ValueError) as e:
            print(BACKENDCAT_MSG + MINETEST_MSG, e)

    for entry in server_json_table:
        entry_dict = parse_json_entry(entry)

        server_table.append(entry_dict)

    ping.add_rtt_info(server_table)

    if proxy is not None:
        for entry in server_table:
            proxy.append(entry)

    return server_table
Exemple #5
0
def stat_master(game: str, game_info: dict, master_list: list, proxy=None) -> List[Dict[str, Union[str, int, bool]]]:
    """Stats the master server"""

    backend_config_object = helpers.load_table(BACKEND_CONFIG)

    protocol = backend_config_object["protocol"]["version"]

    server_table = []

    for master_uri in master_list:
        master_page_uri = master_uri.strip('/') + '/?version=' + protocol
        try:
            master_page_object = requests.get(master_page_uri)
            master_page = master_page_object.text
        except:
            print(i18n._(RIGSOFRODS_MSG), i18n._("Accessing URI %(uri)s failed with error code %(code)s.") % {'uri': master_page_uri, 'code': "unknown"})
            continue

        try:
            temp_table = adapt_server_list(game, master_page)
        except:
            print(i18n._(RIGSOFRODS_MSG), i18n._("Error parsing URI %(uri)s.") % {'uri': master_page_uri})
            continue

        server_table += temp_table

    ping.add_rtt_info(server_table)

    if proxy is not None:
        for entry in server_table:
            proxy.append(entry)

    return server_table
Exemple #6
0
def stat_master(game: str, game_info: dict, master_list: list):
    """Stats the master server"""
    server_table = []

    backend_config_object = helpers.load_table(BACKEND_CONFIG)

    protocol = backend_config_object["protocol"]["version"]

    for master_uri in master_list:
        master_page_uri = master_uri.strip('/') + '/?version=' + protocol
        try:
            master_page_object = requests.get(master_page_uri)
            master_page = master_page_object.text
        except:
            print(
                i18n._(RIGSOFRODS_MSG),
                i18n._(
                    "Accessing URI %(uri)s failed with error code %(code)s.") %
                {
                    'uri': master_page_uri,
                    'code': "unknown"
                })
            continue

        try:
            temp_table = adapt_server_list(game, master_page)
        except:
            print(
                i18n._(RIGSOFRODS_MSG),
                i18n._("Error parsing URI %(uri)s.") %
                {'uri': master_page_uri})
            continue

        server_table += temp_table

    ping.add_rtt_info(server_table)

    return server_table, None