From 0bc19203f3d1b936c0073dcc55b9a4105e783c19 Mon Sep 17 00:00:00 2001 From: DeeDive Date: Wed, 9 Feb 2022 15:44:05 +0800 Subject: [PATCH 1/2] fix relative path error for file config.json --- src/Utils.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Utils.py b/src/Utils.py index a64e186..ca78321 100644 --- a/src/Utils.py +++ b/src/Utils.py @@ -6,7 +6,9 @@ 2018/5/29 =》增加获取操作系统平台方法,增加网络连通性检测(后续考虑重构) 2018/6/3 =》网络连通性代码重构 2018/6/10 =》增加配置文件读取方法(可能有IO性能影响,考虑重构) +2022/2/09 => 修复 config.json 相对路径问题,便于crontab使用. by Deedive ''' +import os import IpGetter import platform import subprocess @@ -69,6 +71,6 @@ def isOnline(): #从config.json中获取配置信息JSON串 def getConfigJson(): - with open('config.json') as file: + with open(os.path.join(os.path.dirname(__file__),'config.json')) as file: jsonStr = json.loads(file.read()) return jsonStr From 60cac86d964a0e7aea5ae37e769e4b6f86f2435d Mon Sep 17 00:00:00 2001 From: DeeDive <42198534+DeeDive@users.noreply.github.com> Date: Wed, 9 Feb 2022 15:51:24 +0800 Subject: [PATCH 2/2] Update Utils.py --- src/Utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Utils.py b/src/Utils.py index ca78321..e7e973b 100644 --- a/src/Utils.py +++ b/src/Utils.py @@ -6,7 +6,7 @@ 2018/5/29 =》增加获取操作系统平台方法,增加网络连通性检测(后续考虑重构) 2018/6/3 =》网络连通性代码重构 2018/6/10 =》增加配置文件读取方法(可能有IO性能影响,考虑重构) -2022/2/09 => 修复 config.json 相对路径问题,便于crontab使用. by Deedive +2022/2/09 => 修复 config.json 相对路径问题,便于crontab使用. by DeeDive ''' import os import IpGetter