u
This commit is contained in:
10
wopy_tool.py
10
wopy_tool.py
@@ -4,7 +4,7 @@ import socket
|
|||||||
import os
|
import os
|
||||||
|
|
||||||
# 加载 默认配置文件 envar.py 和 本机配置文件 (envar.本机编码.py 例如 envar.lin237.py)
|
# 加载 默认配置文件 envar.py 和 本机配置文件 (envar.本机编码.py 例如 envar.lin237.py)
|
||||||
def load_envar():
|
def load_envar(fromPath=None):
|
||||||
# Get current OS type
|
# Get current OS type
|
||||||
if sys.platform.startswith('win'):
|
if sys.platform.startswith('win'):
|
||||||
ostype = 'win'
|
ostype = 'win'
|
||||||
@@ -20,10 +20,10 @@ def load_envar():
|
|||||||
lanip = s.getsockname()[0]
|
lanip = s.getsockname()[0]
|
||||||
s.close()
|
s.close()
|
||||||
# Load environment variables
|
# Load environment variables
|
||||||
this_script_dir = os.path.dirname(os.path.abspath(__file__))
|
if fromPath is None:
|
||||||
calling_script_dir = os.path.dirname(os.path.abspath(sys.argv[0])) # Get the directory of the calling script
|
fromPath = os.path.dirname(os.path.abspath(__file__))
|
||||||
envFileLocal = os.path.join(calling_script_dir, "envar." + ostype + lanip.split(".")[-1] + ".py") # 本主机配置文件
|
envFileLocal = os.path.join(fromPath, "envar." + ostype + lanip.split(".")[-1] + ".py") # 本主机配置文件
|
||||||
envFileDefault = os.path.join(calling_script_dir, "envar.py") # 默认配置文件
|
envFileDefault = os.path.join(fromPath, "envar.py") # 默认配置文件
|
||||||
# 总是加载默认配置文件,作为基础配置
|
# 总是加载默认配置文件,作为基础配置
|
||||||
print(f"*** Loading default envar file: {envFileDefault}")
|
print(f"*** Loading default envar file: {envFileDefault}")
|
||||||
if not os.path.exists(envFileDefault):
|
if not os.path.exists(envFileDefault):
|
||||||
|
|||||||
Reference in New Issue
Block a user