From f15b3af87037310b2b288aa55498a2ec407af6ac Mon Sep 17 00:00:00 2001 From: laszlojau <49835454+laszlojau@users.noreply.github.com> Date: Sat, 17 Jun 2023 21:57:19 +0930 Subject: [PATCH] Set the 'itemValue' for files, even when they can't be read --- plugins/lookup/tss.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/lookup/tss.py b/plugins/lookup/tss.py index 03f5c03627..095bad0342 100644 --- a/plugins/lookup/tss.py +++ b/plugins/lookup/tss.py @@ -292,11 +292,12 @@ class TSSClient(object): file_content = i['itemValue'].content with open(os.path.join(file_download_path, str(obj['id']) + "_" + i['slug']), "wb") as f: f.write(file_content) - i['itemValue'] = "*** Not Valid For Display ***" except ValueError: raise AnsibleOptionsError("Failed to download {0}".format(str(i['slug']))) except AttributeError: display.warning("Could not read file content for {0}".format(str(i['slug']))) + finally: + i['itemValue'] = "*** Not Valid For Display ***" else: raise AnsibleOptionsError("File download path does not exist") return obj