diff --git a/deux/notifications.py b/deux/notifications.py index 50a9c1d..d9f3384 100644 --- a/deux/notifications.py +++ b/deux/notifications.py @@ -1,7 +1,18 @@ 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 diff --git a/deux/tests/test_notifications.py b/deux/tests/test_notifications.py index 03386a4..3693a20 100644 --- a/deux/tests/test_notifications.py +++ b/deux/tests/test_notifications.py @@ -1,7 +1,13 @@ 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