def default(self, args): if self.pipe_runner(args): return apiname = args.partition(' ')[0] verb, subject = splitverbsubject(apiname) lexp = shlex.shlex(args.strip()) lexp.whitespace = " " lexp.whitespace_split = True lexp.posix = True args = [] while True: next_val = lexp.next() if next_val is None: break args.append(next_val.replace('\x00', '')) args_dict = dict(map(lambda x: [x.partition("=")[0], x.partition("=")[2]], args[1:])[x] for x in range(len(args) - 1)) field_filter = None if 'filter' in args_dict: field_filter = filter(lambda x: x is not '', map(lambda x: x.strip(), args_dict.pop('filter').split(','))) missing = [] if verb in self.apicache and subject in self.apicache[verb]: missing = filter(lambda x: x not in [key.split('[')[0] for key in args_dict], self.apicache[verb][subject]['requiredparams']) if len(missing) > 0: self.monkeyprint("Missing arguments: ", ' '.join(missing)) return isasync = False if 'asyncapis' in self.apicache: isasync = apiname in self.apicache['asyncapis'] for key in args_dict.keys(): args_dict[key] = urllib.quote(args_dict[key]) result = self.make_request(apiname, args_dict, isasync) if result is None: return try: responsekeys = filter(lambda x: 'response' in x, result.keys()) for responsekey in responsekeys: self.print_result(result[responsekey], field_filter) print except Exception as e: self.monkeyprint("Error on parsing and printing", e)
self.param_cache[api]["ts"] = int(time.time()) self.param_cache[api]["options"] = sorted(options) return sorted(uuids) def default(self, args): try: args = args.strip() args.decode("utf-8") except UnicodeError, ignore: args = args.encode("utf-8") if self.pipe_runner(args): return apiname = args.partition(' ')[0] verb, subject = splitverbsubject(apiname) lexp = shlex.shlex(args) lexp.whitespace = " " lexp.whitespace_split = True lexp.posix = True args = [] while True: next_val = lexp.next() if not next_val: break next_val = next_val.decode("utf-8") args.append(next_val.replace(u'\x00', u'')) args_dict = dict( map(lambda x: [x.partition("=")[0],
self.param_cache[api]["ts"] = int(time.time()) self.param_cache[api]["options"] = sorted(options) return sorted(uuids) def default(self, args): try: args = args.strip() args.decode("utf-8") except UnicodeError, ignore: args = args.encode("utf-8") if self.pipe_runner(args): return apiname = args.partition(' ')[0] verb, subject = splitverbsubject(apiname) lexp = shlex.shlex(args) lexp.whitespace = " " lexp.whitespace_split = True lexp.posix = True args = [] while True: try: next_val = lexp.next() if not next_val: break next_val = next_val.decode("utf-8") args.append(next_val.replace(u'\x00', u'')) except ValueError, err: self.monkeyprint("Command parsing error: ", err)