(self, zip_file, path)
| 117 | raise TransferModuleError(err_msg) |
| 118 | |
| 119 | def decompress(self, zip_file, path): |
| 120 | logger.info("zip模块执行解压操作...") |
| 121 | # 20190927 bug-fixed, 防止在当前目录下删除当前目录,出现权限异常情况 |
| 122 | cur_dir = os.getcwd() |
| 123 | cur_dir_is_changed = False |
| 124 | if PathMgr().format_path(cur_dir) == PathMgr().format_path(path): |
| 125 | logger.info("Decompress dir is current dir, can not delete it directory, change to parent directory first.") |
| 126 | # 如果要删除的是当前工作目录,先切换到上层目录,再删除 |
| 127 | os.chdir("..") |
| 128 | cur_dir_is_changed = True |
| 129 | |
| 130 | try: |
| 131 | if os.path.exists(path): |
| 132 | PathMgr().rmpath(path) |
| 133 | |
| 134 | self.decompress_by_7z(zip_file, path, print_enable=True) |
| 135 | finally: |
| 136 | # 恢复进入到当前工作目录 |
| 137 | logger.info("Go back to the current working directory.") |
| 138 | if cur_dir_is_changed and os.path.exists(cur_dir): |
| 139 | os.chdir(cur_dir) |
| 140 | return True |
| 141 | |
| 142 | def subprocc_log(self, line): |
| 143 | logger.info(line) |
no test coverage detected