diff --git a/core.py b/core.py index c8439023..95cb1206 100644 --- a/core.py +++ b/core.py @@ -240,8 +240,7 @@ def gather_function(self, function_type, opt): handler_log = GatherLogHandler(self.context) handler_log.handle() handler_obproxy = GatherObProxyLogHandler(self.context) - handler_obproxy.handle() - return ObdiagResult(ObdiagResult.SUCCESS_CODE, data={"store_dir": self.context.get_variable("store_dir")}) + return handler_obproxy.handle() elif function_type == 'gather_sysstat': handler = GatherOsInfoHandler(self.context) return handler.handle() diff --git a/diag_cmd.py b/diag_cmd.py index b0a2a72b..d934ed11 100644 --- a/diag_cmd.py +++ b/diag_cmd.py @@ -277,9 +277,16 @@ def do_command(self): if ROOT_IO.silent: if isinstance(ret, ObdiagResult) is False: ROOT_IO.error('The return value of the command is not ObdiagResult. Please contact thebase community. The return value is: {0}'.format(ret)) - ret = ObdiagResult(code=ObdiagResult.SERVER_ERROR_CODE, error_data={"err_info": "The return value of the command is not ObdiagResult. Maybe the command not support silent. Please contact thebase community."}) + ret = ObdiagResult(code=ObdiagResult.SERVER_ERROR_CODE, error_data= "The return value of the command is not ObdiagResult. Maybe the command not support silent. Please contact thebase community." ) ret.set_trace_id(self.trace_id) - ret.set_command(self.prev_cmd) + + def args_to_str(args): + args_str = "" + for arg in args: + args_str += arg + " " + return args_str.strip() + + ret.set_command(self.prev_cmd + " " + args_to_str(self.args)) ROOT_IO.set_silent(False) ROOT_IO.print(ret.get_result()) ROOT_IO.set_silent(True) diff --git a/handler/gather/gather_scenes.py b/handler/gather/gather_scenes.py index 561f4fe1..55a17d91 100644 --- a/handler/gather/gather_scenes.py +++ b/handler/gather/gather_scenes.py @@ -76,9 +76,9 @@ def handle(self): self.execute() if self.is_inner: result = self.__get_sql_result() - return ObdiagResult(ObdiagResult.SUCCESS_CODE, data={"store_dir": result}) + return ObdiagResult(ObdiagResult.SUCCESS_CODE, data={"store_dir": self.report_path}) else: - return ObdiagResult(ObdiagResult.SUCCESS_CODE, data={"store_dir": result}) + return ObdiagResult(ObdiagResult.SUCCESS_CODE, data={"store_dir": self.report_path}) def execute(self): try: diff --git a/handler/gather/gather_tabledump.py b/handler/gather/gather_tabledump.py index 45cffccf..88ac6078 100644 --- a/handler/gather/gather_tabledump.py +++ b/handler/gather/gather_tabledump.py @@ -104,7 +104,9 @@ def handle(self): return ObdiagResult(ObdiagResult.SERVER_ERROR_CODE, error_data="init failed") excute_status = self.execute() if not self.is_innner and excute_status: - return self.__print_result() + self.__print_result() + return ObdiagResult(ObdiagResult.SUCCESS_CODE, data={"store_dir": self.store_dir}) + return ObdiagResult(ObdiagResult.SERVER_ERROR_CODE, error_data="execute failed") def execute(self): try: @@ -255,4 +257,4 @@ def __print_result(self): self.stdio.print("\nAnalyze SQL Summary:") self.stdio.print(table) self.stdio.print("\n") - return ObdiagResult(ObdiagResult.SERVER_ERROR_CODE, data={"firstrow": data}) + return diff --git a/update/update.py b/update/update.py index a59b1117..acbab830 100644 --- a/update/update.py +++ b/update/update.py @@ -60,13 +60,13 @@ def execute(self): return self.handle_update_offline(file_path) if NetUtils.network_connectivity(remote_server) is False: self.stdio.warn("[update] network connectivity failed. Please check your network connection.") - return ObdiagResult(ObdiagResult.SERVER_ERROR_CODE, error_data={"msg": "network connectivity failed. Please check your network connection."}) + return ObdiagResult(ObdiagResult.SERVER_ERROR_CODE, error_data="network connectivity failed. Please check your network connection.") NetUtils.download_file(remote_version_file_name, os.path.expanduser(local_version_file_name)) with open(local_version_file_name, 'r') as file: remote_data = yaml.safe_load(file) if remote_data.get("obdiag_version") is None: self.stdio.warn("obdiag_version is None. Do not perform the upgrade process.") - return ObdiagResult(ObdiagResult.SERVER_ERROR_CODE, error_data={"msg": "obdiag_version is None. Do not perform the upgrade process."}) + return ObdiagResult(ObdiagResult.SERVER_ERROR_CODE, error_data="obdiag_version is None. Do not perform the upgrade process.") else: self.remote_obdiag_version = remote_data["obdiag_version"].strip() if StringUtils.compare_versions_greater(self.remote_obdiag_version, self.local_obdiag_version): @@ -77,15 +77,15 @@ def execute(self): ) return ObdiagResult( ObdiagResult.SERVER_ERROR_CODE, - error_data={ - "msg": "remote_obdiag_version is {0}. local_obdiag_version is {1}. " - "remote_obdiag_version>local_obdiag_version. Unable to update dependency files, please upgrade " - "obdiag. Do not perform the upgrade process.".format(self.remote_obdiag_version, self.local_obdiag_version) - }, + error_data= + "remote_obdiag_version is {0}. local_obdiag_version is {1}. " + "remote_obdiag_version>local_obdiag_version. Unable to update dependency files, please upgrade " + "obdiag. Do not perform the upgrade process.".format(self.remote_obdiag_version, self.local_obdiag_version) + , ) if remote_data.get("remote_tar_sha") is None: self.stdio.warn("remote_tar_sha is None. Do not perform the upgrade process.") - return ObdiagResult(ObdiagResult.SERVER_ERROR_CODE, error_data={"msg": "remote_tar_sha is None. Do not perform the upgrade process."}) + return ObdiagResult(ObdiagResult.SERVER_ERROR_CODE, error_data= "remote_tar_sha is None. Do not perform the upgrade process.") else: self.remote_tar_sha = remote_data["remote_tar_sha"] # need update?