def choose_server_ip_in_a_list(self): servers_list = None try: f = urllib.urlopen(SERVERS_LIST_URL) if f.read(len(SERVERS_LIST_HEADER)) == SERVERS_LIST_HEADER: servers_list = f.readlines() except: pass if servers_list is None: voice.alert([1029]) # hostile sound warning("couldn't get the servers list from the metaserver" " => using the default servers list") servers_list = DEFAULT_SERVERS nb = 0 menu = Menu() for s in servers_list: try: ip, version, login, port = s.split()[1:] # ignore the first parameter (time) except: warning("line not recognized from the metaserver: %s", s) continue nb += 1 if version == VERSION: menu.append([login, 4073, login], (connect_and_play, ip, port)) menu.title = nb2msg(len(menu.choices)) + [4078] + nb2msg(nb) + [4079] menu.append([4075, 4076], None) menu.run()
def choose_server_ip_in_a_list(): servers = servers_list(voice) total = 0 compatible = 0 menu = Menu() for s in servers: try: _, ip, version, login, port = s.split() except ValueError: warning("line not recognized from the metaserver: %s", s) else: total += 1 if version == VERSION: compatible += 1 menu.append([login], (connect_and_play, ip, port), mp.SERVER_HOSTED_BY + [login]) menu.title = nb2msg(compatible) + mp.SERVERS_ON + nb2msg(total) + mp.ARE_COMPATIBLE menu.append(mp.CANCEL2, None, mp.GO_BACK_TO_PREVIOUS_MENU) menu.run()
def choose_server_ip_in_a_list(): servers = servers_list(voice) total = 0 compatible = 0 menu = Menu() for s in servers: try: _, ip, version, login, port = s.split() except ValueError: warning("line not recognized from the metaserver: %s", s) else: total += 1 if version == VERSION: compatible += 1 menu.append([login], (connect_and_play, ip, port), mp.SERVER_HOSTED_BY + [login]) menu.title = nb2msg(compatible) + mp.SERVERS_ON + nb2msg( total) + mp.ARE_COMPATIBLE menu.append(mp.CANCEL2, None, mp.GO_BACK_TO_PREVIOUS_MENU) menu.run()