更新 epanet linux 版本,修正数值读取错误的问题;新增 api linux 封装版本;更新 requirements.txt 适配 linux;更新 main.py、epanet.py 以适配 linux 环境
This commit is contained in:
@@ -328,7 +328,16 @@ def run_project_return_dict(name: str, readable_output: bool = False) -> dict[st
|
||||
|
||||
data = {}
|
||||
|
||||
result = os.system(command)
|
||||
# 设置环境变量以包含库文件路径
|
||||
env = os.environ.copy()
|
||||
if platform.system() == "Linux":
|
||||
lib_dir = os.path.dirname(exe)
|
||||
env["LD_LIBRARY_PATH"] = f"{lib_dir}:{env.get('LD_LIBRARY_PATH', '')}"
|
||||
|
||||
# 使用 subprocess 替代 os.system 以传递 env
|
||||
process = subprocess.run(command, shell=True, env=env)
|
||||
result = process.returncode
|
||||
|
||||
if result != 0:
|
||||
data["simulation_result"] = "failed"
|
||||
else:
|
||||
@@ -372,8 +381,15 @@ def run_project(name: str, readable_output: bool = False) -> str:
|
||||
|
||||
data = {}
|
||||
|
||||
# DingZQ, 2025-06-02, 使用subprocess.Popen捕获输出到全局日志, 原来的代码是这么写的
|
||||
result = os.system(command)
|
||||
# 设置环境变量以包含库文件路径
|
||||
env = os.environ.copy()
|
||||
if platform.system() == "Linux":
|
||||
lib_dir = os.path.dirname(exe)
|
||||
env["LD_LIBRARY_PATH"] = f"{lib_dir}:{env.get('LD_LIBRARY_PATH', '')}"
|
||||
|
||||
# DingZQ, 2025-06-02, 使用subprocess替代os.system
|
||||
process = subprocess.run(command, shell=True, env=env)
|
||||
result = process.returncode
|
||||
# logging.info(f"Simulation result: {result}")
|
||||
|
||||
if result != 0:
|
||||
@@ -414,7 +430,15 @@ def run_inp(name: str) -> str:
|
||||
|
||||
data = {}
|
||||
|
||||
result = os.system(command)
|
||||
# 设置环境变量以包含库文件路径
|
||||
env = os.environ.copy()
|
||||
if platform.system() == "Linux":
|
||||
lib_dir = os.path.dirname(exe)
|
||||
env["LD_LIBRARY_PATH"] = f"{lib_dir}:{env.get('LD_LIBRARY_PATH', '')}"
|
||||
|
||||
process = subprocess.run(command, shell=True, env=env)
|
||||
result = process.returncode
|
||||
|
||||
if result != 0:
|
||||
data["simulation_result"] = "failed"
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user