From e434f144593403e8050d5b2195adbe3f04e44c87 Mon Sep 17 00:00:00 2001 From: Dominic Cleal Date: Mon, 19 May 2014 11:08:04 +0100 Subject: [PATCH] Cleanup builders on interruption when called directly --- src/tito/builder/main.py | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/tito/builder/main.py b/src/tito/builder/main.py index 86959d8..ddba7cf 100644 --- a/src/tito/builder/main.py +++ b/src/tito/builder/main.py @@ -127,16 +127,21 @@ class BuilderBase(object): # Reset list of artifacts on each call to run(). self.artifacts = [] - if options.tgz: - self.tgz() - if options.srpm: - self.srpm() - if options.rpm: - # TODO: not protected anymore - self.rpm() - self._auto_install() + try: + try: + if options.tgz: + self.tgz() + if options.srpm: + self.srpm() + if options.rpm: + # TODO: not protected anymore + self.rpm() + self._auto_install() + except KeyboardInterrupt: + print("Interrupted, cleaning up...") + finally: + self.cleanup() - self.cleanup() return self.artifacts def cleanup(self):