# Path: model/models.py
# def bind_session(connection_string, echo=False):
# class Measure(Base):
# class Settings(Base):
# 
# Path: model/hlr.py
# def bind_session(connection_string, echo=False):
# def user_data_decode(user_data, data_coding_scheme, ud_hdr_ind):
# def create_sms(src_addr, dest_addr, text, charset=None):
# class Subscriber(Base):
# class Sms(Base):


import os
import time
import Queue
import urllib
import socket
import datetime
import threading
import telnetlib
import transaction
import ConfigParser
import logging_utils
from SimpleXMLRPCServer import SimpleXMLRPCServer
from SimpleXMLRPCServer import SimpleXMLRPCRequestHandler
from sqlalchemy import func
from model.models import (
    bind_session,
    DBSession,
    Measure,
    Settings,
)
from model.hlr import (
    bind_session as bind_hlr_session,
    HLRDBSession,
    Subscriber,
    Sms,
    create_sms
)


        if last_measure is not None:
            self.logger.info("IMSI already detected.")

            last_measure_timestamp = time.mktime(last_measure.timestamp.timetuple())

            if meas['time'] < last_measure_timestamp:
                self.logger.info("Ignore measure because: measure is older then one in DB!")
                return

            if ((meas['time'] - last_measure_timestamp) < self.measure_update_period) and (last_measure.timing_advance == meas['meas_rep']['L1_TA']):
                self.logger.info("Ignore measure because: TA is no different from the last mesaure done less then {0} seconds!".format(self.measure_update_period))
                return

        else:
            self.logger.info("Detect new IMSI.")
            welcome_msg = self.get_formated_welcome_message(ms_phone_number=extension)

            if welcome_msg is None:
                self.logger.error("Send welcome message FAILD! There is no text message!")
            else:
                self.logger.debug("Send welcome message: {0}".format(welcome_msg))
                if not self.send_sms(imsi, welcome_msg):
                    self.logger.error("Welcome message not send.")

        self.save_measure_to_db(meas, extension)

    def get_formated_welcome_message(self, **wargs):
        wargs["ph_phone_number"] = self.pf_phone_number


# Path: model/models.py
# def bind_session(connection_string, echo=False):
# class Measure(Base):
# class Settings(Base):
# 
# Path: model/hlr.py
# def bind_session(connection_string, echo=False):
# def user_data_decode(user_data, data_coding_scheme, ud_hdr_ind):
# def create_sms(src_addr, dest_addr, text, charset=None):
# class Subscriber(Base):
# class Sms(Base):


# Path: com_interface/comms_interface_server.py
import os
import time
import Queue
import urllib
import socket
import datetime
import threading
import telnetlib
import transaction
import ConfigParser
import logging_utils
from SimpleXMLRPCServer import SimpleXMLRPCServer
from SimpleXMLRPCServer import SimpleXMLRPCRequestHandler
from sqlalchemy import func
from model.models import (
    bind_session,
    DBSession,
    Measure,
    Settings,
)
from model.hlr import (
    bind_session as bind_hlr_session,
    HLRDBSession,
    Subscriber,
    Sms,
    create_sms
)


        if last_measure is not None:
            self.logger.info("IMSI already detected.")

            last_measure_timestamp = time.mktime(last_measure.timestamp.timetuple())

            if meas['time'] < last_measure_timestamp:
                self.logger.info("Ignore measure because: measure is older then one in DB!")
                return

            if ((meas['time'] - last_measure_timestamp) < self.measure_update_period) and (last_measure.timing_advance == meas['meas_rep']['L1_TA']):
                self.logger.info("Ignore measure because: TA is no different from the last mesaure done less then {0} seconds!".format(self.measure_update_period))
                return

        else:
            self.logger.info("Detect new IMSI.")
            welcome_msg = self.get_formated_welcome_message(ms_phone_number=extension)

            if welcome_msg is None:
                self.logger.error("Send welcome message FAILD! There is no text message!")
            else:
                self.logger.debug("Send welcome message: {0}".format(welcome_msg))
                if not self.send_sms(imsi, welcome_msg):
                    self.logger.error("Welcome message not send.")

        self.save_measure_to_db(meas, extension)

    def get_formated_welcome_message(self, **wargs):
        wargs["ph_phone_number"] = self.pf_phone_number


        welcome_message_res = DBSession.query(Settings.value).filter(Settings.name == "welcomeMessage").all()
