[libvirt] [dockerfiles PATCH 3/3] refresh: Move exception handling to Application.run()

Andrea Bolognani abologna at redhat.com
Fri Mar 15 13:49:22 UTC 2019


This commit is best viewed with 'git show -w'.

Signed-off-by: Andrea Bolognani <abologna at redhat.com>
---
 refresh | 25 +++++++++++++------------
 1 file changed, 13 insertions(+), 12 deletions(-)

diff --git a/refresh b/refresh
index 1b94736..1db0fc8 100755
--- a/refresh
+++ b/refresh
@@ -117,19 +117,20 @@ class Application:
 
     def run(self):
 
-        for item in self.here.iterdir():
-            try:
-                dockerfile = Dockerfile(item)
-            except MoveAlongException:
-                continue
+        try:
+            for item in self.here.iterdir():
+                try:
+                    dockerfile = Dockerfile(item)
+                except MoveAlongException:
+                    continue
 
-            print(item.stem + item.suffix)
-            dockerfile.refresh(self.lcitool)
+                print(item.stem + item.suffix)
+                dockerfile.refresh(self.lcitool)
+
+        except Exception as ex:
+            sys.stderr.write("{}: {}\n".format(sys.argv[0], ex))
+            sys.exit(1)
 
 
 if __name__ == "__main__":
-    try:
-        Application().run()
-    except Exception as ex:
-        sys.stderr.write("{}: {}\n".format(sys.argv[0], ex))
-        sys.exit(1)
+    Application().run()
-- 
2.20.1




More information about the libvir-list mailing list