From 8e8d63ee0a2c0ac83e10532fb52620f90b8d9208 Mon Sep 17 00:00:00 2001 From: Andy Date: Thu, 27 Jul 2017 10:43:50 +0100 Subject: [PATCH 1/4] Updates import for TwilioRestClient and TwilioRestException to use 6.x twilio python sdk --- deux/notifications.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/deux/notifications.py b/deux/notifications.py index 50a9c1d..088bc50 100644 --- a/deux/notifications.py +++ b/deux/notifications.py @@ -1,7 +1,16 @@ from __future__ import absolute_import, unicode_literals -from twilio.rest import TwilioRestClient -from twilio.rest.exceptions import TwilioRestException +try: + from twilio.rest import Client as TwilioRestClient +except ImportError: + from twilio.rest import TwilioRestClient + print("DeprecationWarning: Importing TwilioRestClient from twilio.rest is deprecated. Update twilio package to >6.x") + +try: + from twilio.base.exceptions import TwilioRestException +except ImportError: + from twilio.rest.exceptions import TwilioRestException + print("DeprecationWarning: Importing TwilioRestException from twilio.rest is deprecated. Update twilio package to >6.x") from deux import strings from deux.app_settings import mfa_settings From 22ba550f33b3f670af6d6fce073489a35cd4451f Mon Sep 17 00:00:00 2001 From: Andy Date: Thu, 27 Jul 2017 11:13:47 +0100 Subject: [PATCH 2/4] Replaces TwilioRestException in test module --- deux/tests/test_notifications.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/deux/tests/test_notifications.py b/deux/tests/test_notifications.py index 03386a4..6bd6ee2 100644 --- a/deux/tests/test_notifications.py +++ b/deux/tests/test_notifications.py @@ -1,7 +1,12 @@ from __future__ import absolute_import, unicode_literals from mock import Mock, patch -from twilio.rest.exceptions import TwilioRestException + +try: + from twilio.base.exceptions import TwilioRestException +except ImportError: + from twilio.rest.exceptions import TwilioRestException + print("DeprecationWarning: Importing TwilioRestException from twilio.rest is deprecated. Update twilio package to >6.x") from deux.app_settings import mfa_settings from deux.exceptions import InvalidPhoneNumberError, TwilioMessageError From 1fc69709af76afed198eb0c651fac0e7510f4ba0 Mon Sep 17 00:00:00 2001 From: Andy Date: Thu, 27 Jul 2017 11:31:36 +0100 Subject: [PATCH 3/4] pep8 --- deux/notifications.py | 6 ++++-- deux/tests/test_notifications.py | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/deux/notifications.py b/deux/notifications.py index 088bc50..d9f3384 100644 --- a/deux/notifications.py +++ b/deux/notifications.py @@ -4,13 +4,15 @@ from twilio.rest import Client as TwilioRestClient except ImportError: from twilio.rest import TwilioRestClient - print("DeprecationWarning: Importing TwilioRestClient from twilio.rest is deprecated. Update twilio package to >6.x") + print("DeprecationWarning: Importing TwilioRestClient from twilio.rest" + " is deprecated. Update twilio package to >6.x") try: from twilio.base.exceptions import TwilioRestException except ImportError: from twilio.rest.exceptions import TwilioRestException - print("DeprecationWarning: Importing TwilioRestException from twilio.rest is deprecated. Update twilio package to >6.x") + print("DeprecationWarning: Importing TwilioRestException from twilio.rest" + " is deprecated. Update twilio package to >6.x") from deux import strings from deux.app_settings import mfa_settings diff --git a/deux/tests/test_notifications.py b/deux/tests/test_notifications.py index 6bd6ee2..93ce775 100644 --- a/deux/tests/test_notifications.py +++ b/deux/tests/test_notifications.py @@ -6,7 +6,8 @@ from twilio.base.exceptions import TwilioRestException except ImportError: from twilio.rest.exceptions import TwilioRestException - print("DeprecationWarning: Importing TwilioRestException from twilio.rest is deprecated. Update twilio package to >6.x") + print("DeprecationWarning: Importing TwilioRestException from twilio.rest" + " is deprecated. Update twilio package to >6.x") from deux.app_settings import mfa_settings from deux.exceptions import InvalidPhoneNumberError, TwilioMessageError From cc49b98b27e9cd28c5d1575434b145d3260bdf06 Mon Sep 17 00:00:00 2001 From: Andy Date: Thu, 27 Jul 2017 11:36:42 +0100 Subject: [PATCH 4/4] removes trailing whitespace --- deux/tests/test_notifications.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/deux/tests/test_notifications.py b/deux/tests/test_notifications.py index 93ce775..3693a20 100644 --- a/deux/tests/test_notifications.py +++ b/deux/tests/test_notifications.py @@ -4,9 +4,9 @@ try: from twilio.base.exceptions import TwilioRestException -except ImportError: +except ImportError: from twilio.rest.exceptions import TwilioRestException - print("DeprecationWarning: Importing TwilioRestException from twilio.rest" + print("DeprecationWarning: Importing TwilioRestException from twilio.rest" " is deprecated. Update twilio package to >6.x") from deux.app_settings import mfa_settings