From 5926a0f72ee2f235be3c77aa822d75c9d0427481 Mon Sep 17 00:00:00 2001 From: fly Date: Wed, 15 Jan 2020 13:54:27 +0000 Subject: [PATCH] Always clean up Signed-off-by: fly --- worldbuild-worker.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/worldbuild-worker.py b/worldbuild-worker.py index 05dc10a..70d7a3c 100755 --- a/worldbuild-worker.py +++ b/worldbuild-worker.py @@ -111,6 +111,12 @@ def get_job(action): ret = get_job(action) return ret +def cleanup(): + if os.path.isfile("projects/worldbuild-" + name + "/osm2city-exceptions.log"): + run("mv projects/worldbuild-" + name + "/osm2city-exceptions.log projects/worldbuild/output/error/" + name + ".exceptions.log", shell=True) + + run("rm -rf projects/worldbuild-" + name, shell=True) + running = True while running: @@ -165,11 +171,7 @@ while running: build = Popen("./build -S 10 -t 1 worldbuild-" + name, shell=True, start_new_session=True) - if os.path.isfile("projects/worldbuild-" + name + "/osm2city-exceptions.log"): - run("mv projects/worldbuild-" + name + "/osm2city-exceptions.log projects/worldbuild/output/error/" + name + ".exceptions.log", shell=True) - - sleep(10) - run("rm -rf projects/worldbuild-" + name, shell=True) + cleanup() send_status(name, "done") except KeyboardInterrupt: @@ -177,6 +179,8 @@ while running: running = False try: build.wait() + cleanup() + send_status(name, "done") except KeyboardInterrupt: #TODO doesn't work print("Forcing shutdown...") @@ -184,4 +188,5 @@ while running: sleep(5) build.kill() sleep(5) + cleanup() sys.exit(0)