iro/anbieter/sipgate.py
changeset 23 0180b538ed74
parent 20 0d7ffb9b2c7f
child 30 5253631a8dd3
equal deleted inserted replaced
22:8b363361ba55 23:0180b538ed74
    15 from anbieter import anbieter
    15 from anbieter import anbieter
    16 from telnumber import telnumber, NotATelNumber
    16 from telnumber import telnumber, NotATelNumber
    17 import ConfigParser
    17 import ConfigParser
    18 import xmlrpclib
    18 import xmlrpclib
    19 import base64
    19 import base64
       
    20 import logging
       
    21 logger=logging.getLogger("sipgate")
    20 
    22 
    21 class NoValidStatusCode(Exception):
    23 class NoValidStatusCode(Exception):
    22     pass
    24     pass
    23 
    25 
    24 class sipgate(anbieter):
    26 class sipgate(anbieter):
    39         self.user=cp.get(self.section, 'user')
    41         self.user=cp.get(self.section, 'user')
    40         self.password=cp.get(self.section, 'password')
    42         self.password=cp.get(self.section, 'password')
    41 
    43 
    42     def sendSMS(self,sms,recipients):
    44     def sendSMS(self,sms,recipients):
    43         """send SMS with $sms to $recipients"""
    45         """send SMS with $sms to $recipients"""
    44         import logging
    46         logger.debug('sipgate.sendSMS(%s,%s)'%(sms,  str(recipients)))
    45         logging.debug('sipgate.sendSMS(%s,%s)'%(sms,  str(recipients)))
       
    46         args={
    47         args={
    47                 "TOS" : "text",
    48                 "TOS" : "text",
    48                 "Content" : sms.content
    49                 "Content" : sms.content
    49                 }
    50                 }
    50         self.__send(args,recipients)
    51         self.__send(args,recipients)
    51 
    52 
    52     def sendFAX(self,fax,recipients):
    53     def sendFAX(self,fax,recipients):
    53         """send the PDF file $fax  to $recipients"""
    54         """send the PDF file $fax  to $recipients"""
    54         import logging
    55         logger.debug('sipgate.sendFAX(%s,%s)'%(fax,  str(recipients)))
    55         logging.debug('sipgate.sendFAX(%s,%s)'%(fax,  str(recipients)))
       
    56         pdf=open(fax.attachments[0],"rb")
    56         pdf=open(fax.attachments[0],"rb")
    57         args={
    57         args={
    58                 "TOS" : "fax",
    58                 "TOS" : "fax",
    59                 "Content" : base64.encodestring(pdf.read())
    59                 "Content" : base64.encodestring(pdf.read())
    60                 }
    60                 }