diff --git a/handler/gather/gather_log.py b/handler/gather/gather_log.py index e9fa0132..31bf07db 100644 --- a/handler/gather/gather_log.py +++ b/handler/gather/gather_log.py @@ -23,7 +23,7 @@ from handler.base_shell_handler import BaseShellHandler from common.obdiag_exception import OBDIAGFormatException from common.constant import const -from common.command import get_file_size, download_file, is_empty_dir, rm_rf_file, get_logfile_name_list, mkdir, delete_empty_file, tar_gz_dir +from common.command import get_file_size, download_file, is_empty_dir, rm_rf_file, get_logfile_name_list, mkdir, delete_empty_file, zip_encrypt_dir, zip_dir from common.command import SshClient from common.tool import TimeUtils from common.tool import Util @@ -368,17 +368,18 @@ def __handle_zip_file(self, ssh_client, resp, gather_dir_name, pack_dir_this_com self.stdio.print('[ip: {0}] gather observer log start'.format(ssh_client.get_name())) if self.zip_encrypt: zip_password = Util.gen_password(16) - tar_gz_dir(ssh_client, self.gather_ob_log_temporary_dir, gather_dir_name, self.stdio) - self.stdio.print('[{0}] gather observer log end'.format(ssh_client.get_name())) - gather_package_dir = "{0}.tar.gz".format(gather_dir_full_path) + self.zip_password = zip_password + zip_encrypt_dir(ssh_client, zip_password, self.gather_ob_log_temporary_dir, gather_dir_name, self.stdio) + else: + zip_dir(ssh_client, self.gather_ob_log_temporary_dir, gather_dir_name, self.stdio) + self.stdio.print('[{0}] zip observer log end'.format(ssh_client.get_name())) + gather_package_dir = "{0}.zip".format(gather_dir_full_path) gather_log_file_size = get_file_size(ssh_client, gather_package_dir, self.stdio) self.stdio.print(FileUtil.show_file_size_tabulate(ssh_client, gather_log_file_size)) local_store_path = "" if int(gather_log_file_size) < self.file_size_limit: - local_store_tar_gz_file = pack_dir_this_command + "/{0}.tar.gz".format(gather_dir_name) - download_file(ssh_client, gather_package_dir, local_store_tar_gz_file, self.stdio) local_store_path = pack_dir_this_command + "/{0}.zip".format(gather_dir_name) - FileUtil.tar_gz_to_zip(pack_dir_this_command, local_store_tar_gz_file, local_store_path, zip_password, self.stdio) + download_file(ssh_client, gather_package_dir, local_store_path, self.stdio) resp["error"] = "" resp["zip_password"] = zip_password else: diff --git a/handler/gather/gather_obproxy_log.py b/handler/gather/gather_obproxy_log.py index cc9a7539..c6e90a72 100644 --- a/handler/gather/gather_obproxy_log.py +++ b/handler/gather/gather_obproxy_log.py @@ -26,7 +26,7 @@ from common.obdiag_exception import OBDIAGFormatException from common.command import SshClient from common.constant import const -from common.command import get_file_size, download_file, is_empty_dir, get_logfile_name_list, mkdir, delete_empty_file, rm_rf_file, tar_gz_dir +from common.command import get_file_size, download_file, is_empty_dir, get_logfile_name_list, mkdir, delete_empty_file, rm_rf_file, zip_encrypt_dir, zip_dir from common.tool import Util from common.tool import DirectoryUtil from common.tool import FileUtil @@ -306,16 +306,16 @@ def __handle_zip_file(self, ssh_client, resp, gather_dir_name, pack_dir_this_com gather_dir_full_path = "{0}/{1}".format(self.gather_log_temporary_dir, gather_dir_name) if self.zip_encrypt: zip_password = Util.gen_password(16) - tar_gz_dir(ssh_client, self.gather_log_temporary_dir, gather_dir_name, self.stdio) - gather_package_dir = "{0}.tar.gz".format(gather_dir_full_path) + zip_encrypt_dir(ssh_client, zip_password, self.gather_log_temporary_dir, gather_dir_name, self.stdio) + else: + zip_dir(ssh_client, self.gather_log_temporary_dir, gather_dir_name, self.stdio) + gather_package_dir = "{0}.zip".format(gather_dir_full_path) gather_log_file_size = get_file_size(ssh_client, gather_package_dir, self.stdio) self.stdio.print(FileUtil.show_file_size_tabulate(ssh_client, gather_log_file_size)) local_path = "" if int(gather_log_file_size) < self.file_size_limit: - local_store_tar_gz_file = pack_dir_this_command + "/{0}.tar.gz".format(gather_dir_name) - download_file(ssh_client, gather_package_dir, local_store_tar_gz_file, self.stdio) - local_path = pack_dir_this_command + "/{0}.zip".format(gather_dir_name) - FileUtil.tar_gz_to_zip(pack_dir_this_command, local_store_tar_gz_file, local_path, zip_password, self.stdio) + local_store_path = pack_dir_this_command + "/{0}.zip".format(gather_dir_name) + local_path = download_file(ssh_client, gather_package_dir, local_store_path, self.stdio) resp["error"] = "" resp["zip_password"] = zip_password else: diff --git a/handler/gather/gather_obstack2.py b/handler/gather/gather_obstack2.py index f71afe73..1dd6b8d9 100644 --- a/handler/gather/gather_obstack2.py +++ b/handler/gather/gather_obstack2.py @@ -22,7 +22,7 @@ import tabulate -from common.command import download_file, is_empty_dir, is_support_arch, get_observer_version, get_observer_pid, mkdir, tar_gz_dir, get_file_size, delete_file_force, is_empty_file, upload_file +from common.command import download_file, is_empty_dir, is_support_arch, get_observer_version, get_observer_pid, mkdir, zip_dir, get_file_size, delete_file_force, is_empty_file, upload_file from common.constant import const from common.command import LocalClient, SshClient from handler.base_shell_handler import BaseShellHandler @@ -167,17 +167,15 @@ def __handle_from_node(self, local_stored_path, node): if is_empty_dir(ssh_client, "/tmp/{0}".format(remote_dir_name), self.stdio): resp["error"] = "gather failed, folder is empty" return resp - tar_gz_dir(ssh_client, "/tmp", remote_dir_name, self.stdio) - remote_tar_file_path = "{0}.tar.gz".format(remote_dir_full_path) + zip_dir(ssh_client, "/tmp", remote_dir_name, self.stdio) + remote_zip_file_path = "{0}.zip".format(remote_dir_full_path) + + file_size = get_file_size(ssh_client, remote_zip_file_path, self.stdio) + remote_file_full_path = "{0}.zip".format(remote_dir_full_path) - file_size = get_file_size(ssh_client, remote_tar_file_path, self.stdio) - remote_file_full_path = "{0}.tar.gz".format(remote_dir_full_path) if int(file_size) < self.file_size_limit: - local_tar_file_path = "{0}/{1}.tar.gz".format(local_stored_path, remote_dir_name) - self.stdio.verbose("local tar file path {0}...".format(local_tar_file_path)) - download_file(ssh_client, remote_file_full_path, local_tar_file_path, self.stdio) - local_zip_file_path = local_stored_path + "/{0}.zip".format(remote_dir_name) - FileUtil.tar_gz_to_zip(local_stored_path, local_tar_file_path, local_zip_file_path, None, self.stdio) + local_file_path = "{0}/{1}.zip".format(local_stored_path, remote_dir_name) + download_file(ssh_client, remote_file_full_path, local_file_path, self.stdio) resp["error"] = "" else: resp["error"] = "File too large" diff --git a/handler/gather/gather_perf.py b/handler/gather/gather_perf.py index 330b8ead..84b217ce 100644 --- a/handler/gather/gather_perf.py +++ b/handler/gather/gather_perf.py @@ -21,7 +21,7 @@ import tabulate -from common.command import get_observer_pid, mkdir, tar_gz_dir, get_file_size, download_file, delete_file_force +from common.command import get_observer_pid, mkdir, zip_dir, get_file_size, download_file, delete_file_force from common.command import SshClient from common.constant import const from handler.base_shell_handler import BaseShellHandler @@ -151,15 +151,12 @@ def __handle_from_node(self, node, local_stored_path): self.__gather_perf_flame(ssh_client, remote_dir_full_path, pid_observer) self.__gather_top(ssh_client, remote_dir_full_path, pid_observer) - tar_gz_dir(ssh_client, "/tmp", remote_dir_name, self.stdio) - remote_file_full_path = "{0}.tar.gz".format(remote_dir_full_path) + zip_dir(ssh_client, "/tmp", remote_dir_name, self.stdio) + remote_file_full_path = "{0}.zip".format(remote_dir_full_path) file_size = get_file_size(ssh_client, remote_file_full_path, self.stdio) if int(file_size) < self.file_size_limit: - local_tar_file_path = "{0}/{1}.tar.gz".format(local_stored_path, remote_dir_name) - self.stdio.verbose("local tar file path {0}...".format(local_tar_file_path)) - download_file(ssh_client, remote_file_full_path, local_tar_file_path, self.stdio) - local_zip_file_path = local_stored_path + "/{0}.zip".format(remote_dir_name) - FileUtil.tar_gz_to_zip(local_stored_path, local_tar_file_path, local_zip_file_path, None, self.stdio) + local_file_path = "{0}/{1}.zip".format(local_stored_path, remote_dir_name) + download_file(ssh_client, remote_file_full_path, local_file_path, self.stdio) resp["error"] = "" else: resp["error"] = "File too large" diff --git a/handler/gather/gather_sysstat.py b/handler/gather/gather_sysstat.py index da4d413b..f78d0af8 100644 --- a/handler/gather/gather_sysstat.py +++ b/handler/gather/gather_sysstat.py @@ -22,7 +22,7 @@ import tabulate from common.constant import const from common.command import LocalClient, SshClient -from common.command import get_file_size, download_file, mkdir, tar_gz_dir +from common.command import get_file_size, download_file, mkdir, zip_dir from handler.base_shell_handler import BaseShellHandler from common.tool import Util from common.tool import DirectoryUtil @@ -147,15 +147,13 @@ def __handle_from_node(self, node, local_stored_path): self.__gather_io_info(ssh_client, remote_dir_full_path) self.__gather_traffic_info(ssh_client, remote_dir_full_path) self.__gather_tcp_udp_info(ssh_client, remote_dir_full_path) - tar_gz_dir(ssh_client, "/tmp", remote_dir_name, self.stdio) - remote_file_full_path = "{0}.tar.gz".format(remote_dir_full_path) + zip_dir(ssh_client, "/tmp", remote_dir_name, self.stdio) + remote_file_full_path = "{0}.zip".format(remote_dir_full_path) file_size = get_file_size(ssh_client, remote_file_full_path, self.stdio) if int(file_size) < self.file_size_limit: - local_tar_file_path = "{0}/{1}.tar.gz".format(local_stored_path, remote_dir_name) - self.stdio.verbose("local tar file path {0}...".format(local_tar_file_path)) - download_file(ssh_client, remote_file_full_path, local_tar_file_path, self.stdio) - local_zip_file_path = local_stored_path + "/{0}.zip".format(remote_dir_name) - FileUtil.tar_gz_to_zip(local_stored_path, local_tar_file_path, local_zip_file_path, None, self.stdio) + local_file_path = "{0}/{1}.zip".format(local_stored_path, remote_dir_name) + self.stdio.verbose("local file path {0}...".format(local_file_path)) + download_file(ssh_client, remote_file_full_path, local_file_path, self.stdio) resp["error"] = "" else: resp["error"] = "File too large"