<s> import logging <EOL> import unicodedata <EOL> from smssluzbacz_api . lite import SmsGateApi <EOL> from django . conf import settings <EOL> from sendsms . backends . base import BaseSmsBackend <EOL> log = logging . getLogger ( __name__ ) <EOL> class SmsBackend ( BaseSmsBackend ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , fail_silently = False , ** kwargs ) : <EOL> super ( SmsBackend , self ) . __init__ ( fail_silently = fail_silently , ** kwargs ) <EOL> self . open ( ) <EOL> def __del__ ( self ) : <EOL> self . close ( ) <EOL> def open ( self ) : <EOL> """<STR_LIT>""" <EOL> self . client = SmsGateApi ( getattr ( settings , '<STR_LIT>' , '<STR_LIT>' ) , <EOL> getattr ( settings , '<STR_LIT>' , '<STR_LIT>' ) , <EOL> getattr ( settings , '<STR_LIT>' , <NUM_LIT:2> ) , <EOL> getattr ( settings , '<STR_LIT>' , True ) ) <EOL> def close ( self ) : <EOL> """<STR_LIT>""" <EOL> self . client = None <EOL> def send_messages ( self , messages ) : <EOL> """<STR_LIT>""" <EOL> count = <NUM_LIT:0> <EOL> for message in messages : <EOL> message_body = unicodedata . normalize ( '<STR_LIT>' , unicode ( message . body ) ) . encode ( '<STR_LIT:ascii>' , '<STR_LIT:ignore>' ) <EOL> for tel_number in message . to : <EOL> try : <EOL> self . client . send ( tel_number , message_body , getattr ( settings , '<STR_LIT>' , True ) ) <EOL> except Exception : <EOL> if self . fail_silently : <EOL> log . exception ( '<STR_LIT>' ) <EOL> else : <EOL> raise <EOL> else : <EOL> count += <NUM_LIT:1> <EOL> return count </s>
