Skip to content

Commit

Permalink
Merge pull request #1132 from bensonhome/main
Browse files Browse the repository at this point in the history
异常处理和版本号打印
  • Loading branch information
cyw3 authored Jul 16, 2024
2 parents 1a450f8 + 8ba50b4 commit 8080d44
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 8 deletions.
8 changes: 8 additions & 0 deletions client/codepuppy.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ def __init__(self):
self._params = CmdArgParser.parse_args()
# 日志输出设置
self.__setup_logger()
# 打印版本信息
self.__print_client_version()

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

def __print_client_version(self):
"""打印TCA客户端版本信息"""
LogPrinter.info("=" * 39)
LogPrinter.info(f"*** TCA Client v{settings.VERSION}({settings.EDITION.name} Beta) ***")
LogPrinter.info("=" * 39)

def __setup_logger(self):
"""日志打印配置
Expand Down
2 changes: 1 addition & 1 deletion client/settings/edition.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ class Edition(Enum):
# 版本号
# ========================
# puppy版本号,格式:浮点数,整数部分为8位日期,小数部分为编号(从1开始)
VERSION = 20220907.1
VERSION = 20240716.1
24 changes: 17 additions & 7 deletions client/util/zipmgr.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,24 @@ def decompress_by_7z(self, zip_file, path, print_enable=False):
def decompress(self, zip_file, path):
logger.info("zip模块执行解压操作...")
# 20190927 bug-fixed, 防止在当前目录下删除当前目录,出现权限异常情况
os.chdir("..")
if os.path.exists(path):
PathMgr().rmpath(path)
cur_dir = os.getcwd()
cur_dir_is_changed = False
if PathMgr().format_path(cur_dir) == PathMgr().format_path(path):
logger.info("Decompress dir is current dir, can not delete it directory, change to parent directory first.")
# 如果要删除的是当前工作目录,先切换到上层目录,再删除
os.chdir("..")
cur_dir_is_changed = True

self.decompress_by_7z(zip_file, path, print_enable=True)

if os.path.exists(WORK_DIR):
os.chdir(WORK_DIR)
try:
if os.path.exists(path):
PathMgr().rmpath(path)

self.decompress_by_7z(zip_file, path, print_enable=True)
finally:
# 恢复进入到当前工作目录
logger.info("Go back to the current working directory.")
if cur_dir_is_changed and os.path.exists(cur_dir):
os.chdir(cur_dir)
return True

def subprocc_log(self, line):
Expand Down

0 comments on commit 8080d44

Please sign in to comment.