Skip to content

Commit

Permalink
fix: 'AlexaLogin' object has no attribute 'delete_cookiefile' (#2471)
Browse files Browse the repository at this point in the history
* Update __init__.py

Added `if callable(getattr(os,'delete_cookiefile', None)):`
for compatibility with alexapy<=1.28.2

* Update __init__.py

Class was wrong
Needs to be `AlexaLogin,'delete_cookiefile'`

* style: auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
danielbrunt57 and pre-commit-ci[bot] committed Aug 19, 2024
1 parent 7ae4f2b commit 36d36b6
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions custom_components/alexa_media/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1332,13 +1332,20 @@ async def async_unload_entry(hass, entry) -> bool:
if hass.data.get(DATA_ALEXAMEDIA):
hass.data.pop(DATA_ALEXAMEDIA)
# Delete cookiefile
try:
await login_obj.delete_cookiefile()
_LOGGER.debug("Deleted cookiefile")
except Exception as ex:
_LOGGER.error(
"Failed to delete cookiefile: %s",
ex,
if callable(getattr(AlexaLogin, "delete_cookiefile", None)):
try:
await login_obj.delete_cookiefile()
_LOGGER.debug("Deleted cookiefile")
except Exception as ex:
_LOGGER.error(
"Failed to delete cookiefile: %s",
ex,
)
else:
_LOGGER.warn(
"Could not remove cookiefile: /config/.storage/alexa_media.%s.pickle."
" Please manually delete the file.",
email,
)
else:
_LOGGER.debug(
Expand Down

0 comments on commit 36d36b6

Please sign in to comment.