Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Properly report failures for Clickatell

  • Loading branch information...
commit 05dcb609ce8ff4a7646320b213d21759a3fd14a6 1 parent 794982a
@mludvig authored
View
9 Sms/Engines/Clickatell.py
@@ -2,7 +2,7 @@
## http://www.logix.cz/michal/devel/sms-cli
## License: GPL Version 2
-from logging import debug, info
+from Sms.Logger import *
from Sms.Exceptions import SmsError
import GenericHttp
@@ -10,11 +10,12 @@ class SmsDriver(GenericHttp.SmsDriver):
url_pattern = "https://api.clickatell.com/http/sendmsg?api_id=%(api_id)s&user=%(user)s&password=%(password)s&to=%(recipient)s&text=%(message)s"
def sendOne(self, message, recipient):
+ debug("Clickatell.sendOne(%s)" % recipient)
ret = GenericHttp.SmsDriver.sendOne(self, message, recipient)
arr = ret.split("\n")[0].split(" ", 1)
if arr[0].startswith("ID"):
info("SMS(Clickatell) sent to %s with ID: %s" % (recipient, arr[1]))
- return arr[1]
- raise SmsError("SMS(Clickatell): %s" % arr[1])
+ else:
+ warning("SMS(Clickatell) failed to %s: %s" % (recipient, ret))
-# vim:et:ts=4:sts=4:ai
+# vim: et:sw=4:sts=4:sta:ai:
View
4 Sms/Engines/GenericHttp.py
@@ -13,7 +13,7 @@ class SmsDriver(GenericSmsDriver):
url_pattern = None
def __init__(self, options):
- ret = GenericSmsDriver.__init__(self, options)
+ GenericSmsDriver.__init__(self, options)
if not self.url_pattern:
try:
self.url_pattern = self.options['url_pattern'].strip('"\'')
@@ -21,6 +21,7 @@ def __init__(self, options):
raise SmsConfigError("GenericHttp driver requires 'url_pattern' option")
def sendOne(self, message, recipient):
+ debug("GenericHttp.sendOne(%s)" % recipient)
all_options = { 'message' : urllib.quote(message), 'recipient' : recipient }
all_options.update(self.options)
url = self.url_pattern % all_options
@@ -31,7 +32,6 @@ def sendOne(self, message, recipient):
raise SmsError("HTTP Return code = %d" % u.code)
ret_data = u.read()
debug("GenericHttp: ret_data: %s" % ret_data)
- raise
return ret_data
# vim: et:sw=4:sts=4:sta:ai:
View
3  Sms/Engines/MessageMedia.py
@@ -13,6 +13,9 @@ class SmsDriver(GenericSoap.SmsDriver):
url = 'http://soap.m4u.com.au/?wsdl'
def sendMulti(self, message, recipients):
+ debug("MessageMedia.sendMulti([%s])" % ", ".join(recipients))
+
+ # Soap Client
client = Client(self.url, cache = self.cache)
# Authentication
View
3  Sms/Sender.py
@@ -41,7 +41,6 @@ def send(self, message = None, recipients = []):
try:
self._driver.sendMulti(message, recipients)
except AttributeError:
- raise
for recipient in recipients:
self._driver.sendOne(message, recipient)
except SmsError, e:
@@ -50,4 +49,4 @@ def send(self, message = None, recipients = []):
return True
-# vim:et:ts=4:sts=4:ai
+# vim: et:sw=4:sts=4:sta:ai:
Please sign in to comment.
Something went wrong with that request. Please try again.