1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Set the 'itemValue' for files, even when they can't be read

This commit is contained in:
laszlojau 2023-06-17 21:57:19 +09:30
parent 76d74a8fe5
commit f15b3af870
No known key found for this signature in database
GPG key ID: 774C18E747321566

View file

@ -292,11 +292,12 @@ class TSSClient(object):
file_content = i['itemValue'].content file_content = i['itemValue'].content
with open(os.path.join(file_download_path, str(obj['id']) + "_" + i['slug']), "wb") as f: with open(os.path.join(file_download_path, str(obj['id']) + "_" + i['slug']), "wb") as f:
f.write(file_content) f.write(file_content)
i['itemValue'] = "*** Not Valid For Display ***"
except ValueError: except ValueError:
raise AnsibleOptionsError("Failed to download {0}".format(str(i['slug']))) raise AnsibleOptionsError("Failed to download {0}".format(str(i['slug'])))
except AttributeError: except AttributeError:
display.warning("Could not read file content for {0}".format(str(i['slug']))) display.warning("Could not read file content for {0}".format(str(i['slug'])))
finally:
i['itemValue'] = "*** Not Valid For Display ***"
else: else:
raise AnsibleOptionsError("File download path does not exist") raise AnsibleOptionsError("File download path does not exist")
return obj return obj