def __initialize_servers__(self): self.servers = {} # iterate servers. for server_path in glob.glob(f'{ROOT_DIR}/servers/*'): server_name = utils.__get_file_path_name__(server_path) settings = utils.__load_json__(f"{server_path}/settings.json") self.servers[server_name] = { "info": settings, "clients": {}, } # iterate clients. for client_path in glob.glob(f'{server_path}/*'): if os.path.isdir(client_path): client_name = utils.__get_file_path_name__(client_path) self.servers[server_name]["clients"][ client_name] = client.Client( server=server_name, username=client_name, )
def connect_to_host(self): host_ip = self.ip_entry.get() if not self.validate_ip(host_ip): self.show_sys_msg("IP is invalid") return port_entry_val = self.port_entry.get() if not self.validate_port(port_entry_val): msg = "65535 >= 1024 > port" self.show_sys_msg(msg) return try: self.chat = client.Client(host_ip, int(port_entry_val)) self.connect_btn.pack_forget() self.ip_entry.config(state='readonly') self.port_entry.config(state='readonly') except Exception as e: msg = "Error with firewall." self.show_sys_msg(repr(e) + '\n' + msg)
def connect_to_host(self): host_ip = self.ip_entry.get() if not self.validate_ip(host_ip): self.show_sys_msg("ip format is invalid") return port_entry_val = self.port_entry.get() if not self.validate_port(port_entry_val): msg = "port must be an integer where 1024 < port <= 65535" self.show_sys_msg(msg) return try: self.chat = client.Client(host_ip, int(port_entry_val)) self.connect_btn.pack_forget() self.ip_entry.config(state='readonly') self.port_entry.config(state='readonly') except Exception as e: msg = "Check the ip and port. Check host's firewall settings" self.show_sys_msg(repr(e) + '\n' + msg)