This commit is contained in:
DingZQ
2023-10-27 21:17:38 +08:00
parent 6f22063a72
commit 1a0bc30785

View File

@@ -154,16 +154,15 @@ async def fastapi_dump_inp(network: str, inp: str) -> bool:
@app.get("/runproject/", response_class = PlainTextResponse)
async def fastapi_run_project(network: str) -> str:
filename = 'c:/lock.simulation'
if os.path.exists(filename):
filename2 = 'c:/lock.simulation2'
if os.path.exists(filename2):
print('file exists')
raise HTTPException(status_code=409, detail="is in simulation")
else:
print('file doesnt exists')
f = open(filename, "a")
f.write("locksimulaiton")
f.close()
os.rename(filename, filename2)
result = run_project(network)
os.remove(filename)
os.rename(filename2, filename)
return result
# put in inp folder, name without extension