# 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 sys
import argparse
import ConfigParser
import time
import datetime
import multiprocessing
import transaction
import logging_utils
from multiprocessing.managers import BaseManager
from model.models import bind_session, DBSession, Measure, Settings
from model.hlr import bind_session as bind_hlr_session, HLRDBSession, Subscriber, Sms
from meas_json_client import MeasJsonListenerProcess
from gpsd_client import GPSDListenerProcess
from comms_interface_server import CommsInterfaceServer
from sms_server import SMSServer

        srv = SMSServer(configuration, comms_model, logger)
        srv.serve_forever()
    except ValueError as err:
        print "Cann't init sms server: {0}".format(err.message)
        logger.error("Cann't init sms server: {0}".format(err.message))
        sys.exit(1)

if __name__ == "__main__":
    parser = argparse.ArgumentParser(
        description='People finder. Comm interface.')
    parser.add_argument('-c', '--configuration', type=file, required=True)
    parser.add_argument('-t', '--test_mode', action='store_true')
    args = parser.parse_args()

    configuration = ConfigParser.ConfigParser()
    configuration.readfp(args.configuration)

    logger = logging_utils.get_logger("main")
    logger.info("Comm interface started! pid: {0}".format(os.getpid()))

    # Init DB ================================================================
    pf_db_conn_str = None
    try:
        pf_db_conn_str = configuration.get('app:main', 'sqlalchemy.pf.url')
    except ConfigParser.Error as err:
        logger.error("Identification People Finder DB fail: {0}".format(err.message))
        sys.exit(1)

    logger.info("PF db sqlite path: {0}".format(pf_db_conn_str))
    try:

# 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.py
import os
import sys
import argparse
import ConfigParser
import time
import datetime
import multiprocessing
import transaction
import logging_utils
from multiprocessing.managers import BaseManager
from model.models import bind_session, DBSession, Measure, Settings
from model.hlr import bind_session as bind_hlr_session, HLRDBSession, Subscriber, Sms
from meas_json_client import MeasJsonListenerProcess
from gpsd_client import GPSDListenerProcess
from comms_interface_server import CommsInterfaceServer
from sms_server import SMSServer

        srv = SMSServer(configuration, comms_model, logger)
        srv.serve_forever()
    except ValueError as err:
        print "Cann't init sms server: {0}".format(err.message)
        logger.error("Cann't init sms server: {0}".format(err.message))
        sys.exit(1)

if __name__ == "__main__":
    parser = argparse.ArgumentParser(
        description='People finder. Comm interface.')
    parser.add_argument('-c', '--configuration', type=file, required=True)
    parser.add_argument('-t', '--test_mode', action='store_true')
    args = parser.parse_args()

    configuration = ConfigParser.ConfigParser()
    configuration.readfp(args.configuration)

    logger = logging_utils.get_logger("main")
    logger.info("Comm interface started! pid: {0}".format(os.getpid()))

    # Init DB ================================================================
    pf_db_conn_str = None
    try:
        pf_db_conn_str = configuration.get('app:main', 'sqlalchemy.pf.url')
    except ConfigParser.Error as err:
        logger.error("Identification People Finder DB fail: {0}".format(err.message))
        sys.exit(1)

    logger.info("PF db sqlite path: {0}".format(pf_db_conn_str))
    try:

        bind_session(pf_db_conn_str)
