From 54d9c41e76fc478fb753b8179a4eff8c0337b318 Mon Sep 17 00:00:00 2001 From: yshtcn Date: Tue, 5 Sep 2023 14:48:09 +0800 Subject: [PATCH] Update heartbeat.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 更新当前目录的兼容性,为打包提供支持 --- heartbeat.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/heartbeat.py b/heartbeat.py index 2fc27e5..4600b46 100644 --- a/heartbeat.py +++ b/heartbeat.py @@ -14,6 +14,8 @@ import platform # 获取当前脚本所在的目录 current_dir = os.path.dirname(os.path.realpath(__file__)) +if getattr(sys, 'frozen', False): + current_dir = sys._MEIPASS # 如果是frozen的(即打包后的exe),使用这个目录 # 创建日志文件 log_file_path = os.path.join(current_dir, 'heartbeat.log')