diff --git a/src/Utils.py b/src/Utils.py index a64e186..e7e973b 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