def validate_network(config): from zombie.common import validate_ip_hostname, validate_port from zombie.constants import DEFAULT_CONFIG section_name = 'network' default = DEFAULT_CONFIG[section_name] if section_name not in config: config[section_name] = default return network = config[section_name] if 'ip' not in network or not validate_ip_hostname(network['ip']): network['ip'] = DEFAULT_IP if 'port' not in network or not validate_port(network['port']): network['port'] = DEFAULT_PORT
def connect(self): from zombie.common import validate_ip_hostname, validate_port ip = validate_ip_hostname(self.ip.value.encode('ascii')) if not ip: # TODO: error message return port = validate_port(self.port.value) if not port: #TODO: error message return from zombie.common import switch_layer ## TODO: Switch to client layer. #print('Connecting to', ip, port) self.connect_screen.connect(ip, port) switch_layer(self.scene, ConnectScreen)