def process_unknown_adress_sms_worker(self): self.logger.info("Process unknown adressing sms thread START!") while not self.time_to_shutdown_event.is_set(): sms_info = self.measure_model.get_unknown_adresses_sms() if sms_info is not None: self.logger.info("Process sms {0}".format(sms_info)) reply_msg = self.get_formated_reply_message( ms_phone_number=sms_info['source'][0]) if reply_msg is None: self.logger.error( "Send reply message FAILD! There is no text message!") else: with transaction.manager: HLRDBSession.add_all([ create_sms(sms_info['source'][0], sms_info['destination'][0], sms_info['text'][0], sms_info['charset'][0]) ]) self.logger.debug("Send reply message. START!") if not self.send_sms_by_phone_number( sms_info['source'][0], reply_msg): self.logger.error("Reply message not send.") self.logger.debug("Send reply message. FINISH!") else: time.sleep(0.1) self.logger.info("Process unknown adressing sms thread FINISH!")
def main(argv=sys.argv): if len(argv) != 2: usage(argv) config_uri = argv[1] setup_logging(config_uri) settings = get_appsettings(config_uri) engine = engine_from_config(settings, 'sqlalchemy.pf.') DBSession.configure(bind=engine) Base.metadata.create_all(engine) hlr_engine = engine_from_config(settings, 'sqlalchemy.hlr.') HLRDBSession.configure(bind=hlr_engine) # initial settings with transaction.manager: DBSession.add_all([ Settings(name='imsiUpdate', value=3000), Settings(name='smsUpdate', value=3000), Settings(name='silentSms', value=3000), Settings( name='welcomeMessage', value='You are connected to a mobile search and rescue team. ' + \ 'Please SMS to {ph_phone_number} to communicate. ' + \ 'Your temporary phone number is {ms_phone_number}' ), Settings( name='replyMessage', value='Your SMSs are being sent to a mobile search and rescue team. ' + \ 'Reply to this message to communicate.' ), ]) HLRDBSession.add_all([ Subscriber( created=datetime.datetime.fromtimestamp(time.time()), updated=datetime.datetime.fromtimestamp(time.time()), imsi=pf_subscriber_imsi, name=pf_subscriber_name, extension=pf_subscriber_extension, authorized=1, lac=0 ) ])
def process_unknown_adress_sms_worker(self): self.logger.info("Process unknown adressing sms thread START!") while not self.time_to_shutdown_event.is_set(): sms_info = self.measure_model.get_unknown_adresses_sms() if sms_info is not None: self.logger.info("Process sms {0}".format(sms_info)) reply_msg = self.get_formated_reply_message( ms_phone_number=sms_info['source'][0]) if reply_msg is None: self.logger.error( "Send reply message FAILD! There is no text message!") else: self.logger.debug( "Send reply message: {0}".format(reply_msg)) if not self.vty_send_sms_by_phone_number( sms_info['source'][0], reply_msg): self.logger.error("Reply message not send.") with transaction.manager: HLRDBSession.add_all([ Sms(created=datetime.datetime.fromtimestamp( long(time.time())), sent=None, deliver_attempts=1, reply_path_req=0, status_rep_req=0, protocol_id=0, data_coding_scheme=0, ud_hdr_ind=0, src_addr=sms_info['source'][0], src_ton=0, src_npi=0, dest_addr=sms_info['destination'][0], dest_ton=0, dest_npi=0, text=sms_info['text'][0]) ]) else: time.sleep(0.1) self.logger.info("Process unknown adressing sms thread FINISH!")
def process_unknown_adress_sms_worker(self): self.logger.info("Process unknown adressing sms thread START!") while not self.time_to_shutdown_event.is_set(): sms_info = self.measure_model.get_unknown_adresses_sms() if sms_info is not None: self.logger.info("Process sms {0}".format(sms_info)) reply_msg = self.get_formated_reply_message(ms_phone_number=sms_info['source'][0]) if reply_msg is None: self.logger.error("Send reply message FAILD! There is no text message!") else: self.logger.debug("Send reply message: {0}".format(reply_msg)) if not self.vty_send_sms_by_phone_number(sms_info['source'][0], reply_msg): self.logger.error("Reply message not send.") with transaction.manager: HLRDBSession.add_all([ Sms( created=datetime.datetime.fromtimestamp(long(time.time())), sent=None, deliver_attempts=1, reply_path_req=0, status_rep_req=0, protocol_id=0, data_coding_scheme=0, ud_hdr_ind=0, src_addr=sms_info['source'][0], src_ton=0, src_npi=0, dest_addr=sms_info['destination'][0], dest_ton=0, dest_npi=0, text=sms_info['text'][0] ) ]) else: time.sleep(0.1) self.logger.info("Process unknown adressing sms thread FINISH!")