Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: fix nomail image in get_mails function
Browse files Browse the repository at this point in the history
firstof9 committed Jun 17, 2021
1 parent 76d8c97 commit cb917fb
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions custom_components/mail_and_packages/helpers.py
Original file line number Diff line number Diff line change
@@ -286,6 +286,11 @@ def fetch(
image_name = data[const.ATTR_IMAGE_NAME]
amazon_image_name = data[const.ATTR_AMAZON_IMAGE]

if config.get(const.CONF_CUSTOM_IMG):
nomail = config.get(const.CONF_CUSTOM_IMG_FILE)
else:
nomail = None

if sensor in data:
return data[sensor]

@@ -298,6 +303,7 @@ def fetch(
gif_duration,
image_name,
generate_mp4,
nomail,
)
elif sensor == const.AMAZON_PACKAGES:
count[sensor] = get_items(account, const.ATTR_COUNT, amazon_fwds)
@@ -472,6 +478,7 @@ def get_mails(
gif_duration: int,
image_name: str,
gen_mp4: bool = False,
custom_img: str = None,
) -> int:
"""Creates GIF image based on the attachments in the inbox"""
image_count = 0
@@ -595,10 +602,11 @@ def get_mails(

try:
_LOGGER.debug("Copying nomail gif")
copyfile(
os.path.dirname(__file__) + "/mail_none.gif",
image_output_path + image_name,
)
if custom_img is not None:
nomail = custom_img
else:
nomail = os.path.dirname(__file__) + "/mail_none.gif"
copyfile(nomail, image_output_path + image_name)
except Exception as err:
_LOGGER.error("Error attempting to copy image: %s", str(err))

0 comments on commit cb917fb

Please sign in to comment.