def validate_options(self): if not self.host_list: self.usage('no hosts specified') validate_hostport_list(self.host_list, port_optional=True) validate_port(self.port) if self.protocol and self.protocol not in ('http', 'https', 'ping'): code_error('invalid protocol, must be one of http or https') if self.regex: if not self.protocol: self.usage('--regex cannot be used without --http / --https') validate_regex(self.regex) self.regex = re.compile(self.regex) validate_int(self.num_threads, 'num threads', 1, 100)
def validate_common_opts(self): hosts = self.get_opt('host') self.port = self.get_opt('port') if hosts: self.host_list = [host.strip() for host in hosts.split(',') if host] self.host_list += self.args self.host_list = uniq_list_ordered(self.host_list) if not self.host_list: self.usage('no hosts specified') validate_hostport_list(self.host_list, port_optional=True) validate_port(self.port) self.port = int(self.port) self.validate_protocol_opts() self.validate_misc_opts()