From 95e00279240e282c9a060d230ef2aaea33646a6d Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Mon, 17 Jul 2017 20:21:16 +0200 Subject: [PATCH] Fix KeyError --- homeassistant/components/notify/twitter.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/homeassistant/components/notify/twitter.py b/homeassistant/components/notify/twitter.py index 43efd2c2732..74002b89c76 100644 --- a/homeassistant/components/notify/twitter.py +++ b/homeassistant/components/notify/twitter.py @@ -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)