From 4121d090e127a83959c5e2e04f9ab1564a7c513d Mon Sep 17 00:00:00 2001 From: "Adam.Dybbroe" Date: Wed, 10 Mar 2021 14:40:34 +0100 Subject: [PATCH 1/2] Bugfix: Be forgiven if hook is not configured for Signed-off-by: Adam.Dybbroe --- bin/move_it.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/move_it.py b/bin/move_it.py index 279c6503..12102edf 100644 --- a/bin/move_it.py +++ b/bin/move_it.py @@ -1,7 +1,7 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- # -# Copyright (c) 2012, 2013, 2014, 2015 +# Copyright (c) 2012 - 2021 Pytroll community # # Author(s): # @@ -577,7 +577,7 @@ def fun(pathname): if attrs["delete"]: try: os.remove(pathname) - if attrs["delete_hook"]: + if 'delete_hook' in attrs and attrs["delete_hook"]: attrs["delete_hook"](pathname) LOGGER.debug("Removed %s", pathname) except OSError as e__: From c3b1378475515e857e1dc5c1566889929c7b36d4 Mon Sep 17 00:00:00 2001 From: "Adam.Dybbroe" Date: Wed, 10 Mar 2021 15:07:00 +0100 Subject: [PATCH 2/2] Refactor Signed-off-by: Adam.Dybbroe --- bin/move_it.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/move_it.py b/bin/move_it.py index 12102edf..8ddedf19 100644 --- a/bin/move_it.py +++ b/bin/move_it.py @@ -577,7 +577,7 @@ def fun(pathname): if attrs["delete"]: try: os.remove(pathname) - if 'delete_hook' in attrs and attrs["delete_hook"]: + if attrs.get("delete_hook"): attrs["delete_hook"](pathname) LOGGER.debug("Removed %s", pathname) except OSError as e__: