Merge branch 'master' of https://e.coding.net/tjwater/tjwatercloud/TJWaterServer
This commit is contained in:
@@ -77,7 +77,7 @@ def _calculate_service_area(name: str, inp, time_index: int = 0) -> dict[str, li
|
||||
up_link_nodes = node_upstream[node]
|
||||
ready = True
|
||||
for link_node in up_link_nodes:
|
||||
if link_node in node_wip:
|
||||
if link_node[1] in node_wip:
|
||||
ready = False
|
||||
break
|
||||
if ready:
|
||||
@@ -115,7 +115,7 @@ def _calculate_service_area(name: str, inp, time_index: int = 0) -> dict[str, li
|
||||
|
||||
|
||||
def calculate_service_area(name: str) -> list[dict[str, list[str]]]:
|
||||
inp = json.loads(run_project(name))
|
||||
inp = json.loads(run_project(name, True))
|
||||
|
||||
result: list[dict[str, list[str]]] = []
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ import platform
|
||||
import os
|
||||
import sys
|
||||
import json
|
||||
import base64
|
||||
from typing import Any
|
||||
sys.path.append("..")
|
||||
from api import project
|
||||
@@ -14,6 +15,10 @@ def _verify_platform():
|
||||
if _platform != "Windows":
|
||||
raise Exception(f'Platform {_platform} unsupported (not yet)')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
_verify_platform()
|
||||
|
||||
|
||||
class Output:
|
||||
def __init__(self, path: str) -> None:
|
||||
@@ -210,10 +215,6 @@ class Output:
|
||||
return data
|
||||
|
||||
|
||||
def dump_report(path: str) -> str:
|
||||
return open(path, mode='r').read()
|
||||
|
||||
|
||||
def _dump_output(path: str) -> dict[str, Any]:
|
||||
opt = Output(path)
|
||||
data = opt.dump()
|
||||
@@ -227,7 +228,18 @@ def dump_output(path: str) -> str:
|
||||
return json.dumps(data)
|
||||
|
||||
|
||||
def run_project(name: str) -> str:
|
||||
def dump_report(path: str) -> str:
|
||||
return open(path, 'r').read()
|
||||
|
||||
|
||||
def dump_output_binary(path: str) -> str:
|
||||
with open(path, 'rb') as f:
|
||||
data = f.read()
|
||||
bast64_data = base64.b64encode(data)
|
||||
return str(bast64_data, 'utf-8')
|
||||
|
||||
|
||||
def run_project(name: str, readable_output: bool = False) -> str:
|
||||
if not project.have_project(name):
|
||||
raise Exception(f'Not found project [{name}]')
|
||||
|
||||
@@ -250,7 +262,10 @@ def run_project(name: str) -> str:
|
||||
data['simulation_result'] = 'failed'
|
||||
else:
|
||||
data['simulation_result'] = 'successful'
|
||||
data |= _dump_output(opt)
|
||||
if readable_output:
|
||||
data |= _dump_output(opt)
|
||||
else:
|
||||
data['output'] = dump_output_binary(opt)
|
||||
|
||||
data['report'] = dump_report(rpt)
|
||||
|
||||
@@ -273,12 +288,9 @@ def run_inp(name: str) -> str:
|
||||
data['simulation_result'] = 'failed'
|
||||
else:
|
||||
data['simulation_result'] = 'successful'
|
||||
data |= _dump_output(opt)
|
||||
# data |= _dump_output(opt)
|
||||
data['output'] = dump_output_binary(opt)
|
||||
|
||||
data['report'] = dump_report(rpt)
|
||||
|
||||
return json.dumps(data)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
_verify_platform()
|
||||
|
||||
42
install.py
Normal file
42
install.py
Normal file
@@ -0,0 +1,42 @@
|
||||
import os
|
||||
import sys
|
||||
|
||||
def install():
|
||||
if sys.version_info.major != 3:
|
||||
print("Require install Python 3.x !")
|
||||
return
|
||||
|
||||
minor = sys.version_info.minor
|
||||
if minor < 4 or minor > 10:
|
||||
print("Require install Python 3.4 ~ Python 3.10 !")
|
||||
return
|
||||
|
||||
# upgrade pipe
|
||||
os.system('python -m pip install --upgrade pip -i https://pypi.tuna.tsinghua.edu.cn/simple')
|
||||
|
||||
# install package
|
||||
packages = [
|
||||
'"psycopg[binary]"',
|
||||
'pytest',
|
||||
'numpy']
|
||||
|
||||
if minor == 4:
|
||||
packages.append('script/package/PyMetis-2018.1-cp34-cp34m-win_amd64.whl')
|
||||
elif minor == 5:
|
||||
packages.append('script/package/PyMetis-2019.1.1-cp35-cp35m-win_amd64.whl')
|
||||
elif minor == 6:
|
||||
packages.append('script/package/PyMetis-2019.1.1-cp36-cp36m-win_amd64.whl')
|
||||
elif minor == 7:
|
||||
packages.append('script/package/PyMetis-2020.1-cp37-cp37m-win_amd64.whl')
|
||||
elif minor == 8:
|
||||
packages.append('script/package/PyMetis-2020.1-cp38-cp38-win_amd64.whl')
|
||||
elif minor == 9:
|
||||
packages.append('script/package/PyMetis-2020.1-cp39-cp39-win_amd64.whl')
|
||||
elif minor == 10:
|
||||
packages.append('script/package/PyMetis-2020.1-cp310-cp310-win_amd64.whl')
|
||||
|
||||
for package in packages:
|
||||
os.system(f'pip install {package} -i https://pypi.tuna.tsinghua.edu.cn/simple')
|
||||
|
||||
if __name__ == '__main__':
|
||||
install()
|
||||
BIN
script/package/PyMetis-2018.1-cp34-cp34m-win_amd64.whl
Normal file
BIN
script/package/PyMetis-2018.1-cp34-cp34m-win_amd64.whl
Normal file
Binary file not shown.
BIN
script/package/PyMetis-2019.1.1-cp35-cp35m-win_amd64.whl
Normal file
BIN
script/package/PyMetis-2019.1.1-cp35-cp35m-win_amd64.whl
Normal file
Binary file not shown.
BIN
script/package/PyMetis-2019.1.1-cp36-cp36m-win_amd64.whl
Normal file
BIN
script/package/PyMetis-2019.1.1-cp36-cp36m-win_amd64.whl
Normal file
Binary file not shown.
BIN
script/package/PyMetis-2020.1-cp37-cp37m-win_amd64.whl
Normal file
BIN
script/package/PyMetis-2020.1-cp37-cp37m-win_amd64.whl
Normal file
Binary file not shown.
BIN
script/package/PyMetis-2020.1-cp38-cp38-win_amd64.whl
Normal file
BIN
script/package/PyMetis-2020.1-cp38-cp38-win_amd64.whl
Normal file
Binary file not shown.
BIN
script/package/PyMetis-2020.1-cp39-cp39-win_amd64.whl
Normal file
BIN
script/package/PyMetis-2020.1-cp39-cp39-win_amd64.whl
Normal file
Binary file not shown.
@@ -1,5 +0,0 @@
|
||||
python -m pip install --upgrade pip -i https://pypi.tuna.tsinghua.edu.cn/simple
|
||||
pip install "psycopg[binary]" -i https://pypi.tuna.tsinghua.edu.cn/simple
|
||||
pip install pytest -i https://pypi.tuna.tsinghua.edu.cn/simple
|
||||
pip install numpy -i https://pypi.tuna.tsinghua.edu.cn/simple
|
||||
pip install PyMetis-2020.1-cp310-cp310-win_amd64.whl -i https://pypi.tuna.tsinghua.edu.cn/simple
|
||||
12
setup_server.md
Normal file
12
setup_server.md
Normal file
@@ -0,0 +1,12 @@
|
||||
搭建服务器
|
||||
|
||||
1. `git clone https://e.coding.net/tjwater/tjwatercloud/TJWaterServer.git`
|
||||
2. 控制台进入 `TJWaterServer`
|
||||
3. 运行 `python install.py` 准备Python环境
|
||||
4. 解压 `pg14.zip` 到上一层文件夹
|
||||
5. 控制台进入 `../pg14/bin`
|
||||
6. 执行 `initdb -D ../data -E UTF-8` 创建数据库
|
||||
7. 执行 `pg_ctl -D ../data -l logfile start` 启动数据库服务
|
||||
- `pg_ctl -D ../data -l logfile stop` 关闭数据库服务
|
||||
8. 进入 `TJWaterServer`,执行 `python create_template.py` 创建模板
|
||||
9. 搭建FastAPI环境...
|
||||
Reference in New Issue
Block a user