def get_numbering(self): if self.numbering: return self.numbering numbering_path = os.path.join(self.file_path, "word/numbering.xml") if not os.path.exists(numbering_path): self.numbering = Numbering() return self.numbering with open(numbering_path, encoding="UTF-8") as f: numbering = f.read() numbering = BeautifulSoup(numbering, "xml") self.numbering = Numbering(numbering) return self.numbering
def __init__(self): self.server = kannel_server self.port = kannel_port self.username = kannel_username self.password = kannel_password self.charset = 'UTF-8' self.coding = 2 self.context = 'SMS_LOCAL' self.source = '' self.destination = '' self.text = '' self.save_sms = 1 self.numbering = Numbering()
def __init__(self): self.server = kannel_server self.port = kannel_port self.username = kannel_username self.password = kannel_password self.charset = 'UTF-8' self.coding = 2 self.context = 'SMS_LOCAL' self.source = '' self.destination = '' self.text = '' self.save_sms = 1 self.numbering = Numbering() #added by Talal for applications self.fishline = fishline.fishline() self.summarization = fishline.summarization()
def roaming(self, subject): self.numbering = Numbering() self.subscriber = Subscriber() if subject == 'caller': # calling number is roaming # check if destination number is roaming as well if self.numbering.is_number_roaming(self.destination): # well destination number is roaming as well send SMS to current_bts where the subscriber is roaming try: current_bts = self.numbering.get_current_bts( self.destination) sms_log.info( 'Destination number is roaming send SMS to current_bts: %s' % current_bts) if current_bts == config['local_ip']: log.info( 'Current bts same as local site send call to local Kannel' ) self.context = 'SMS_ROAMING_LOCAL' self.send(self.source, self.destination, self.text, self.charset) else: # send sms to destination site self.context = 'SMS_ROAMING_INTERNAL' self.send(self.source, self.destination, self.text, self.charset, current_bts) except NumberingException as e: sms_log.error(e) else: # destination is not roaming check if destination if local site if self.numbering.is_number_local(self.destination) and len( self.destination) == 11: sms_log.info('Destination is a local number') if self.subscriber.is_authorized(self.destination, 0): sms_log.info('Send sms to local kannel') self.context = 'SMS_ROAMING_LOCAL' self.send(self.source, self.destination, self.text) else: # destination cannot receive SMS inform source self.context = 'SMS_ROAMING_UNAUTH' # Why receive here? Why not send? self.receive(config['smsc'], source, config['sms_destination_unauthorized'], self.charset, self.coding) else: # number is not local check if number is internal if self.numbering.is_number_internal( self.destination) and len(self.destination) == 11: # number is internal send SMS to destination site current_bts = self.numbering.get_site_ip( self.destination) self.context = 'SMS_ROAMING_INTERNAL' self.send(self.source, self.destination, self.text, self.charset, current_bts) else: # check if number is for outbound. # not implemented yet. just return sms_log.info('Invalid destination for SMS') return else: # the destination is roaming send call to current_bts try: current_bts = self.numbering.get_current_bts(self.destination) if current_bts == config['local_ip']: sms_log.info( 'Destination is roaming on our site send SMS to local kannel' ) self.context = 'SMS_ROAMING_LOCAL' self.send(self.source, self.destination, self.text, self.charset) else: sms_log.info( 'Destination is roaming send sms to other site') self.context = 'SMS_ROAMING_INTERNAL' self.send(self.source, self.destination, self.text, self.charset, current_bts) except NumberingException as e: sms_log.error(e)