Skip to content

Commit

Permalink
Create missing directories as needed (#366)
Browse files Browse the repository at this point in the history
  • Loading branch information
firstof9 authored Feb 13, 2021
2 parents fd5ccbc + bedf639 commit 10ef92e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
11 changes: 11 additions & 0 deletions custom_components/mail_and_packages/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,17 @@ def image_file_name(hass: Any, config: Any) -> str:
image_name = None
path = f"{hass.config.path()}/{config.get(const.CONF_PATH)}"
mail_none = f"{os.path.dirname(__file__)}/mail_none.gif"

# Path check
path_check = os.path.exists(path)
if not path_check:
try:
os.makedirs(path)
except OSError as err:
_LOGGER.error("Problem creating: %s, error returned: %s", path, err)
return "mail_none.gif"

# SHA1 file hash check
try:
sha1 = hash_file(mail_none)
except OSError as err:
Expand Down
4 changes: 2 additions & 2 deletions custom_components/mail_and_packages/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
],
"config_flow": true,
"requirements": [
"imageio",
"python-resize-image"
"imageio>=2.9.0",
"python-resize-image>=1.1.19"
],
"version": "0.0.0"
}

0 comments on commit 10ef92e

Please sign in to comment.