def call_method(client, args, unknown_args, wait_thread): method = args.method stdin_passwd = args.stdin_passwd view_params = get_view_params(client, method + '_view', step = None, \ expert = True) view = get_view(client, method, client.sid, view_params) method_parser = get_method_argparser(view, args) param_object = _create_obj(client, method) try: unknown_args = method_parser.fixBoolVariables(unknown_args) args, unknown_args = method_parser.parse_known_args(unknown_args) no_questions = args.no_questions except SystemExit: raise Exception(1) for i in unknown_args: if i.startswith('-'): if i in parse().parse_known_args()[1]: wait_thread.stop() sys.stdout.write('\r') sys.stdout.flush() _print (_('Unknown parameter'), i) raise Exception(1) if not view.groups is None: param_object, steps = collect_object(client, param_object, view, args, wait_thread,stdin_passwd=stdin_passwd) if steps.label and hasattr (param_object, 'CheckOnly'): param_object['CheckOnly'] = True check_res = {} while True: method_result = client.service[0][method](client.sid,param_object) if not method_result: print _('Method not available') return None if method_result.ReturnedMessage[0].type and \ method_result.ReturnedMessage[0].type != "pid": wait_thread.stop() check_res = check_result_msg(method_result, view, check_res) if not check_res: return None else: param_object = get_param_pwd(check_res, view, param_object, client) else: break view_params = get_view_params(client, method + '_view', step = None, \ expert = True, brief = True) view = get_view(client, method, client.sid, view_params) wait_thread.stop() sys.stdout.write('\r') sys.stdout.flush() print_brief(view, steps.label) if not no_questions: while True: try: ask = raw_input('\n' + _('Run the process? (yes/no): ')) red = '\033[31m * \033[0m' except KeyboardInterrupt: ask = 'no' red = '\n'+'\033[31m * \033[0m' if ask.lower() in ['n', 'no']: print red + _("Manually interrupted") return None if ask.lower() in ['y', 'yes']: break param_object['CheckOnly'] = False else: param_object = {} method_result = client.service[0][method](client.sid, param_object) if not method_result: print _('Method not available') return None if method_result.ReturnedMessage[0].type and \ method_result.ReturnedMessage[0].type != "pid": for error in method_result.ReturnedMessage: params_text = '' for Group in view.groups.GroupField: for field in Group.fields.Field: if field.name == error.field: params_text += getErrorOnParam(args,field) red = '\033[31m * \033[0m' _print ('\r' + red + params_text + error.message) return None wait_thread.stop() return method_result
def https_server(client, args, unknown_args, url, clVarsCore, wait_thread): client_post_auth(client) # sym_link = os.path.basename(sys.argv[0]) # if sym_link != 'cl-console': # wait_thread.stop() # results = client.service.get_methods(client.sid, 'console') # find_flag = False # if hasattr (results, 'stringArray'): # for _array in results.stringArray: # if _array.string[0] == sym_link: # args.method = _array.string[1] # find_flag = True # break # if not find_flag: # _print (_('Method not found for %s') %sym_link) if args.stop_consoled: wait_thread.stop() os.system('cl-consoled --stop') return 0 if args.session_clean: wait_thread.stop() session_clean(client) if args.session_info or args.session_num_info: wait_thread.stop() client_session_info(client, args.session_num_info) return 0 if args.session_list: wait_thread.stop() client_session_list(client) return 0 if args.list_pid: wait_thread.stop() if args.dump: from pid_information import client_pid_info client_pid_info(client) else: from pid_information import client_list_pid client_list_pid(client) if args.pid_res: wait_thread.stop() get_entire_frame(client, args.pid_res) return 0 if args.pid_kill: wait_thread.stop() from pid_information import client_pid_kill return client_pid_kill(client, args.pid_kill) retCode = 0 if not args.method: wait_thread.stop() client_list_methods(client) return 1 elif args.method and args.help: view_params = get_view_params(client, args.method + '_view', step = None, expert = True, onlyhelp = True) view = get_view(client, args.method, client.sid, view_params) wait_thread.stop() sys.stdout.write("\b") sys.stdout.flush() method_parser = get_method_argparser(view, args) method_parser.print_help() client.service.clear_method_cache(client.sid, args.method) else: try: client.frame_period = clVarsCore.Get('core.cl_core_get_frame_period') except: client.frame_period = 2 method_result = call_method(client, args, unknown_args, wait_thread) if method_result: client.no_progress = args.no_progress try: analysis(client, client.sid, method_result) except urllib2.URLError, e: _print (e) except KeyboardInterrupt: try: print mess = method_result[0][0] pid = int(mess.message) result = client.service.pid_kill(pid, client.sid) if result in [0,2]: print _('Process terminated') elif result == -1: print _("Certificate not found on the server") elif result == -2: print _("Session not matching your certificate") elif result == 1: print _("Failed to terminate the process") # get_entire_frame(client, pid) analysis(client, client.sid, method_result) except Exception, e: _print (e.message)