Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix rca err #404

Merged
merged 1 commit into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions common/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ def zip_dir(ssh_client, father_dir, zip_dir, stdio=None):
Compress files through zip
:return:
"""
cmd = "zip {father_dir}/{zip_dir}.zip -rm {father_dir}/{zip_dir}".format(father_dir=father_dir, zip_dir=zip_dir)
cmd = "cd {father_dir} && zip {zip_dir}.zip -rm {zip_dir}".format(father_dir=father_dir, zip_dir=zip_dir)
ssh_client.exec_cmd(cmd)


Expand All @@ -198,7 +198,7 @@ def zip_encrypt_dir(ssh_client, zip_password, father_dir, zip_dir, stdio=None):
Compress files by encryption
:return:
"""
cmd = "zip --password {zip_password} {father_dir}/{zip_dir}.zip -rm {father_dir}/{zip_dir}".format(zip_password=zip_password, father_dir=father_dir, zip_dir=zip_dir)
cmd = "cd {father_dir} && zip --password {zip_password} {zip_dir}.zip -rm {zip_dir}".format(zip_password=zip_password, father_dir=father_dir, zip_dir=zip_dir)
ssh_client.exec_cmd(cmd)


Expand Down
1 change: 1 addition & 0 deletions common/ssh_client/remote_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ def exec_cmd(self, cmd):
if len(stderr.read().decode('utf-8').strip()) > 0:
raise Exception(stderr.read().decode('utf-8'))
cmd = "sudo {0}".format(cmd)
cmd = cmd.replace("&&", "&& sudo ")
self.stdio.verbose('Execute Shell command on server {0}:{1}'.format(self.host_ip, cmd))
stdin, stdout, stderr = self._ssh_fd.exec_command(cmd)
err_text = stderr.read()
Expand Down
8 changes: 5 additions & 3 deletions handler/rca/rca_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,13 +175,15 @@ def execute(self):
self.rca_scene.execute()
except RCANotNeedExecuteException as e:
self.stdio.warn("rca_scene.execute not need execute: {0}".format(e))
return ObdiagResult(ObdiagResult.SERVER_ERROR_CODE, data="rca_scene.execute not need execute: {0}")
return ObdiagResult(ObdiagResult.SERVER_ERROR_CODE, data={"result": "rca_scene.execute not need execute"})
except Exception as e:
raise Exception("rca_scene.execute err: {0}".format(e))
self.stdio.error("rca_scene.execute err: {0}".format(e))
return ObdiagResult(ObdiagResult.SERVER_ERROR_CODE, error_data="rca_scene.execute err: {0}".format(e))
try:
self.rca_scene.export_result()
except Exception as e:
raise Exception("rca_scene.export_result err: {0}".format(e))
self.stdio.error("rca_scene.export_result err: {0}".format(e))
return ObdiagResult(ObdiagResult.SERVER_ERROR_CODE, error_data="rca_scene.export_result err: {0}".format(e))
self.stdio.print("rca finished. For more details, the result on '" + Fore.YELLOW + self.get_result_path() + Style.RESET_ALL + "' \nYou can get the suggest by '" + Fore.YELLOW + "cat " + self.get_result_path() + "/record" + Style.RESET_ALL + "'")
return ObdiagResult(ObdiagResult.SUCCESS_CODE, data={"store_dir": self.get_result_path(), "record": self.rca_scene.Result.records_data()})

Expand Down
Loading