Skip to content

Commit

Permalink
fix rca err (#404)
Browse files Browse the repository at this point in the history
  • Loading branch information
wayyoungboy authored Aug 28, 2024
1 parent e8922fb commit 2702f59
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
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

0 comments on commit 2702f59

Please sign in to comment.