Skip to content

Commit

Permalink
fix: fix nomail image in get_mails function (#469)
Browse files Browse the repository at this point in the history
  • Loading branch information
firstof9 authored Jun 17, 2021
2 parents a980d99 + cb917fb commit 69747a4
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
Expand Up @@ -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]

Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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))

Expand Down

0 comments on commit 69747a4

Please sign in to comment.