from __future__ import print_function
from ievv_opensource.ievv_sms import sms_registry
[docs]class Backend(sms_registry.AbstractSmsBackend):
"""
Backend that just prints the phone number and
message. Does not send an SMS.
Useful for development.
The backend_id for this backend is ``debugprint``.
"""
[docs] @classmethod
def get_backend_id(cls):
return 'debugprint'
[docs] def send(self):
print(
'{border}\n'
'DEBUG PRINT SMS:\n'
'Phone number: {phone_number}\n'
'Message: {message}\n'
'Message length: {message_length}\n'
'{border}\n'.format(
phone_number=self.cleaned_phone_number,
message=self.cleaned_message,
message_length=len(self.cleaned_message),
border='-' * 70
)
)
[docs]class Latin1Backend(Backend):
"""
Just like :class:`.Backend`, but this backend crashes
if you try to send any characters outside the latin1
charset.
The backend_id for this backend is ``debugprint_latin1``.
Very useful when the targeted production backend
only supports latin1.
"""
[docs] @classmethod
def get_backend_id(cls):
return 'debugprint_latin1'
[docs] def clean_message(self, message):
return message.encode('latin1').decode('latin1')