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