From 1a0bc30785f04013d37fdc896136f800b8eef47b Mon Sep 17 00:00:00 2001 From: DingZQ Date: Fri, 27 Oct 2023 21:17:38 +0800 Subject: [PATCH] Refine --- main.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/main.py b/main.py index c517ef2..e35b1b6 100644 --- a/main.py +++ b/main.py @@ -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