Skip to content

Commit 01fd2bd

Browse files
committed
Merge branch 'pages-test' of https://github.com/cyw3/CodeAnalysis into pages-test
2 parents 7c03a22 + 96a4078 commit 01fd2bd

File tree

3 files changed

+26
-8
lines changed

3 files changed

+26
-8
lines changed

client/codepuppy.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ def __init__(self):
3737
self._params = CmdArgParser.parse_args()
3838
# 日志输出设置
3939
self.__setup_logger()
40+
# 打印版本信息
41+
self.__print_client_version()
4042

4143
if getattr(sys, 'frozen', False) and hasattr(sys, '_MEIPASS'):
4244
LogPrinter.info('running in a PyInstaller bundle')
@@ -49,6 +51,12 @@ def __init__(self):
4951
# 默认git配置
5052
GitConfig.set_default_config()
5153

54+
def __print_client_version(self):
55+
"""打印TCA客户端版本信息"""
56+
LogPrinter.info("=" * 39)
57+
LogPrinter.info(f"*** TCA Client v{settings.VERSION}({settings.EDITION.name} Beta) ***")
58+
LogPrinter.info("=" * 39)
59+
5260
def __setup_logger(self):
5361
"""日志打印配置
5462

client/settings/edition.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,4 @@ class Edition(Enum):
2828
# 版本号
2929
# ========================
3030
# puppy版本号,格式:浮点数,整数部分为8位日期,小数部分为编号(从1开始)
31-
VERSION = 20220907.1
31+
VERSION = 20240716.1

client/util/zipmgr.py

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -119,14 +119,24 @@ def decompress_by_7z(self, zip_file, path, print_enable=False):
119119
def decompress(self, zip_file, path):
120120
logger.info("zip模块执行解压操作...")
121121
# 20190927 bug-fixed, 防止在当前目录下删除当前目录,出现权限异常情况
122-
os.chdir("..")
123-
if os.path.exists(path):
124-
PathMgr().rmpath(path)
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
125129

126-
self.decompress_by_7z(zip_file, path, print_enable=True)
127-
128-
if os.path.exists(WORK_DIR):
129-
os.chdir(WORK_DIR)
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)
130140
return True
131141

132142
def subprocc_log(self, line):

0 commit comments

Comments
 (0)