mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 12:47:08 +00:00
Fix KeyError
This commit is contained in:
parent
c67c20f752
commit
95e0027924
@ -65,7 +65,7 @@ class TwitterNotificationService(BaseNotificationService):
|
||||
if data:
|
||||
media = data.get(ATTR_MEDIA)
|
||||
if not self.hass.config.is_allowed_path(media):
|
||||
_LOGGER.warning("'%s' is not in a whitelisted area.", media)
|
||||
_LOGGER.warning("'%s' is not a whitelisted directory", media)
|
||||
return
|
||||
|
||||
media_id = self.upload_media(media)
|
||||
@ -97,8 +97,7 @@ class TwitterNotificationService(BaseNotificationService):
|
||||
return None
|
||||
|
||||
media_id = resp.json()['media_id']
|
||||
media_id = self.upload_media_chunked(file, total_bytes,
|
||||
media_id)
|
||||
media_id = self.upload_media_chunked(file, total_bytes, media_id)
|
||||
|
||||
resp = self.upload_media_finalize(media_id)
|
||||
if 199 > resp.status_code < 300:
|
||||
@ -150,8 +149,8 @@ class TwitterNotificationService(BaseNotificationService):
|
||||
def log_error_resp(resp):
|
||||
"""Log error response."""
|
||||
obj = json.loads(resp.text)
|
||||
error_message = obj['error']
|
||||
_LOGGER.error("Error %s : %s", resp.status_code, error_message)
|
||||
error_message = obj['errors']
|
||||
_LOGGER.error("Error %s: %s", resp.status_code, error_message)
|
||||
|
||||
@staticmethod
|
||||
def log_error_resp_append(resp):
|
||||
@ -159,5 +158,5 @@ class TwitterNotificationService(BaseNotificationService):
|
||||
obj = json.loads(resp.text)
|
||||
error_message = obj['errors'][0]['message']
|
||||
error_code = obj['errors'][0]['code']
|
||||
_LOGGER.error("Error %s : %s (Code %s)", resp.status_code,
|
||||
_LOGGER.error("Error %s: %s (Code %s)", resp.status_code,
|
||||
error_message, error_code)
|
||||
|
Loading…
x
Reference in New Issue
Block a user