1. Peter Sagerson
  2. django-otp

Commits

Peter Sagerson  committed 9fe9ea6

Fix for requests integration.

  • Participants
  • Parent commits 03f3d75
  • Branches default

Comments (0)

Files changed (4)

File django-otp-twilio/CHANGES

View file
 .. vim: ft=rst nospell tw=80
 
+v0.1.2 - March 24, 2013 - Bug fix
+---------------------------------
+
+- Fix for requests integration.
+
 
 v0.1.1 - October 8, 2012 - Bug fix
 ----------------------------------

File django-otp-twilio/docs/source/conf.py

View file
 # The short X.Y version.
 version = '0.1'
 # The full version, including alpha/beta/rc tags.
-release = '0.1.1'
+release = '0.1.2'
 
 # The language for content autogenerated by Sphinx. Refer to documentation
 # for a list of supported languages.

File django-otp-twilio/otp_twilio/models.py

View file
             auth=(settings.OTP_TWILIO_ACCOUNT, settings.OTP_TWILIO_AUTH)
         )
 
-        if response.error is not None:
-            self._report_error(str(response.error))
-        elif 'sid' not in response.json:
-            self._report_error(response.json.get('message'))
+        try:
+            response.raise_for_status()
+        except Exception as e:
+            logger.exception('Error sending token by Twilio SMS: {0}'.format(e))
+            raise
+
+        if 'sid' not in response.json():
+            message = response.json().get('message')
+            logger.error('Error sending token by Twilio SMS: {0}'.format(message))
+            raise Exception(message)
 
     def _validate_config(self):
         if settings.OTP_TWILIO_ACCOUNT is None:
         if settings.OTP_TWILIO_FROM is None:
             raise ImproperlyConfigured('OTP_TWILIO_FROM must be set to one of your Twilio phone numbers')
 
-    def _report_error(self, message):
-        logger.error('Error sending token by Twilio SMS: {0}'.format(message))
-        raise Exception('Could not deliver the token')
-
-
     def verify_token(self, token):
         try:
             token = int(token)

File django-otp-twilio/setup.py

View file
 
 setup(
     name='django-otp-twilio',
-    version='0.1.1',
+    version='0.1.2',
     description="A django-otp plugin that delivers tokens via Twilio's SMS service.",
     long_description=open('README').read(),
     author='Peter Sagerson',
         "Topic :: Security",
         "Topic :: Software Development :: Libraries :: Python Modules",
     ],
-) 
+)