def threads(self, threads): for t in threads: if utils.valid_threads(threads): self.__threads = int(threads) return raise BadHostInfoException('bad threads number. (t should between 1 - 50')
def output(self, paths): for path in paths: if path != '': if utils.valid_file_creatable(path): self.__output = path break else: raise BadHostInfoException('cannot create output file: {}'.format(path))
def file(self, paths): for path in paths: if path != '': if utils.valid_file_exist(path): self.read_host_file(path) break else: raise BadHostInfoException('no such file: {}'.format(path))
def timeout(self, timeouts): for t in timeouts: if utils.valid_timeout(t): self.__timeout = int(t) utils.print_info('set timeout: {}'.format(self.__timeout)) return raise BadHostInfoException('bad timeout number. (t should between 1 - 15)')
def timeout(self, timeouts): for t in timeouts: print(t) if utils.valid_timeout(t): self.__timeout = int(t) return raise BadHostInfoException( 'bad timeout number. (t should between 1 - 15)')
def do_task(self, args): try: sub_opt, arg = args.split(' ')[0], args.split(' ')[1:] if sub_opt not in self.sub_opt['task']: raise BadHostInfoException() except IndexError: utils.print_failed( "Error during setting '{}'\n" "Not enough arguments\n" "Use <tab> key multiple times for completion.".format(args)) return except BadHostInfoException as err: utils.print_failed( "Error during setting '{}'\n" "Use <tab> key multiple times for completion.".format(args)) return try: self.task.__getattribute__(sub_opt)(arg) except (BadHostInfoException, TypeError) as err: utils.print_failed("Error during setting '{}'\n" "{}.\n" "Please check the arguments input.".format( sub_opt, err))