-
Notifications
You must be signed in to change notification settings - Fork 16
修了一大堆问题 #153
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
修了一大堆问题 #153
Changes from all commits
e701177
cc86300
836a5d2
9974a62
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -2,6 +2,7 @@ | |||||||||
| import sys | ||||||||||
| import time | ||||||||||
| import gc | ||||||||||
| import subprocess | ||||||||||
|
|
||||||||||
| import sentry_sdk | ||||||||||
| from sentry_sdk.integrations.loguru import LoguruIntegration, LoggingLevels | ||||||||||
|
|
@@ -12,7 +13,7 @@ | |||||||||
| from app.tools.path_utils import get_app_root | ||||||||||
| from app.tools.config import configure_logging | ||||||||||
| from app.tools.settings_access import readme_settings_async | ||||||||||
| from app.tools.variable import APP_QUIT_ON_LAST_WINDOW_CLOSED, VERSION | ||||||||||
| from app.tools.variable import APP_QUIT_ON_LAST_WINDOW_CLOSED, VERSION, EXIT_CODE_RESTART | ||||||||||
| from app.core.single_instance import ( | ||||||||||
| check_single_instance, | ||||||||||
| setup_local_server, | ||||||||||
|
|
@@ -38,8 +39,8 @@ def main(): | |||||||||
| logger.remove() | ||||||||||
| configure_logging() | ||||||||||
|
|
||||||||||
| # 仅在开发环境(版本号包含 0.0.0)下初始化 Sentry | ||||||||||
| if VERSION == "v0.0.0": | ||||||||||
| # 仅在开发环境(版本号不包含 0.0.0)下初始化 Sentry | ||||||||||
| if "0.0.0" not in VERSION: | ||||||||||
|
|
||||||||||
| def before_send(event, hint): | ||||||||||
| # 如果事件中不包含异常信息(即没有堆栈),则不上传 | ||||||||||
|
|
@@ -58,6 +59,7 @@ def before_send(event, hint): | |||||||||
| before_send=before_send, | ||||||||||
| release=VERSION, | ||||||||||
| send_default_pii=True, | ||||||||||
| enable_logs=True, | ||||||||||
| ) | ||||||||||
|
|
||||||||||
| wm.app_start_time = time.perf_counter() | ||||||||||
|
|
@@ -170,7 +172,7 @@ def new_notify(receiver, event): | |||||||||
| app.notify = new_notify | ||||||||||
|
|
||||||||||
| try: | ||||||||||
| app.exec() | ||||||||||
| exit_code = app.exec() | ||||||||||
| logger.debug("Qt 事件循环已结束") | ||||||||||
|
|
||||||||||
| # 尝试停止所有后台服务 | ||||||||||
|
|
@@ -202,6 +204,50 @@ def new_notify(receiver, event): | |||||||||
| logger.info("程序退出流程已完成,正在结束进程") | ||||||||||
| sys.stdout.flush() | ||||||||||
| sys.stderr.flush() | ||||||||||
|
|
||||||||||
| if exit_code == EXIT_CODE_RESTART: | ||||||||||
| logger.info("检测到重启信号,正在重启应用程序...") | ||||||||||
| # 过滤掉 --url 等参数 | ||||||||||
| filtered_args = [arg for arg in sys.argv if not arg.startswith("--")] | ||||||||||
|
Comment on lines
+210
to
+211
|
||||||||||
| # 过滤掉 --url 等参数 | |
| filtered_args = [arg for arg in sys.argv if not arg.startswith("--")] | |
| # 过滤掉 --url 等参数,并且跳过 sys.argv[0](可执行文件路径) | |
| filtered_args = [arg for arg in sys.argv[1:] if not arg.startswith("--")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment is incorrect - it states "仅在开发环境(版本号不包含 0.0.0)下初始化 Sentry" (Only initialize Sentry in development environment where version doesn't contain 0.0.0), but the condition
if "0.0.0" not in VERSION:actually initializes Sentry in non-development builds (when version doesn't contain "0.0.0"). The comment should say "仅在非开发环境" (Only in non-development environment) or the logic should be inverted to match the comment.