-
Notifications
You must be signed in to change notification settings - Fork 287
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1181 from bensonhome/main
🎨调整客户端版本信息输出日志
- Loading branch information
Showing
6 changed files
with
89 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# -*- encoding: utf-8 -*- | ||
# Copyright (c) 2021-2024 THL A29 Limited | ||
# | ||
# This source code file is made available under MIT License | ||
# See LICENSE for details | ||
# ============================================================================== | ||
|
||
""" | ||
打印客户端版本号 | ||
""" | ||
|
||
import sys | ||
|
||
from node.app import settings | ||
from tool.util.pythontool import PythonTool | ||
from util.exceptions import ConfigError | ||
from util.logutil import LogPrinter | ||
from util.pyinstallerlib import PyinstallerUtil | ||
|
||
|
||
class RunningType(object): | ||
SourceCode = 5 | ||
ExeP = 3 | ||
ExeN = 4 | ||
|
||
|
||
class VersionPrinter(object): | ||
@staticmethod | ||
def print_client_version(): | ||
running_type = VersionPrinter.get_running_type() | ||
star_str = "*" * running_type | ||
equal_sign_cnt = 31 + len(settings.EDITION.name) + running_type * 2 | ||
equal_sign_str = "=" * equal_sign_cnt | ||
LogPrinter.info(equal_sign_str) | ||
LogPrinter.info(f"{star_str} TCA Client v{settings.VERSION}({settings.EDITION.name} Beta) {star_str}") | ||
LogPrinter.info(equal_sign_str) | ||
|
||
@staticmethod | ||
def get_running_type(): | ||
if sys.argv[0].endswith(".py"): | ||
return RunningType.SourceCode | ||
elif PyinstallerUtil.is_running_in_bundle(): | ||
return RunningType.ExeP | ||
else: | ||
return RunningType.ExeN | ||
|
||
@staticmethod | ||
def check_python_version(): | ||
"""如果是源码执行,检查python版本是否符合""" | ||
if RunningType.SourceCode == VersionPrinter.get_running_type(): | ||
# 源码执行时,检查是否为python3.7版本 | ||
if not PythonTool.is_local_python_command_available("python3", python_version="3.7"): | ||
raise ConfigError("python3 command(Python Version 3.7) is not available, please install it first.") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# -*- encoding: utf-8 -*- | ||
# Copyright (c) 2021-2023 THL A29 Limited | ||
# | ||
# This source code file is made available under MIT License | ||
# See LICENSE for details | ||
# ============================================================================== | ||
|
||
""" | ||
pyinstaller相关的共用类库 | ||
""" | ||
|
||
import sys | ||
import logging | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
class PyinstallerUtil(object): | ||
@staticmethod | ||
def is_running_in_bundle(): | ||
""" | ||
检查是否在pyinstaller打包的程序中运行 | ||
""" | ||
if getattr(sys, 'frozen', False) and hasattr(sys, '_MEIPASS'): | ||
return True | ||
else: | ||
return False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters