# 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):


from datetime import datetime
from pyramid.view import view_config
from sqlalchemy import func
from model.models import (
    DBSession,
    Measure,
)
from model.hlr import (
    HLRDBSession,
    Sms,
    Subscriber,
    user_data_decode,
)
import time
import xmlrpclib
import socket
        Sms.sent
    ).filter(
        ((Sms.src_addr == Subscriber.extension) |
         (Sms.dest_addr == Subscriber.extension)) &
        (Subscriber.imsi == imsi) &
        (Sms.protocol_id != 64)
    ).order_by(Sms.created.asc())

    result = {
        'imsi': imsi,
        'sms': []
    }

    multipart_massages = {}

    for obj in query.all():
        dest_subscriber_res = HLRDBSession.query(
            Subscriber.imsi
        ).filter(
            Subscriber.extension == obj.dest_addr
        ).all()

        dest = "xx"
        if len(dest_subscriber_res) > 0:
            dest_imsi = int(dest_subscriber_res[0].imsi)
            dest = "station" if dest_imsi == int(pimsi) else str(dest_imsi)

        direction = 'to' if obj.src_addr == pfnum else 'from'

        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: web/peoplefinder/views/imsi.py
from datetime import datetime
from pyramid.view import view_config
from sqlalchemy import func
from model.models import (
    DBSession,
    Measure,
)
from model.hlr import (
    HLRDBSession,
    Sms,
    Subscriber,
    user_data_decode,
)
import time
import xmlrpclib
import socket

        Sms.sent
    ).filter(
        ((Sms.src_addr == Subscriber.extension) |
         (Sms.dest_addr == Subscriber.extension)) &
        (Subscriber.imsi == imsi) &
        (Sms.protocol_id != 64)
    ).order_by(Sms.created.asc())

    result = {
        'imsi': imsi,
        'sms': []
    }

    multipart_massages = {}

    for obj in query.all():
        dest_subscriber_res = HLRDBSession.query(
            Subscriber.imsi
        ).filter(
            Subscriber.extension == obj.dest_addr
        ).all()

        dest = "xx"
        if len(dest_subscriber_res) > 0:
            dest_imsi = int(dest_subscriber_res[0].imsi)
            dest = "station" if dest_imsi == int(pimsi) else str(dest_imsi)

        direction = 'to' if obj.src_addr == pfnum else 'from'

        try:

            msg_id, msg_part_num, msg_parts_count, msg_part_text = user_data_decode(obj.user_data, obj.data_coding_scheme, (obj.ud_hdr_ind == 1) )