def process_ussd_records(ussd_record, file_id, file_name):

        if ussd_record.getComponentByName("callReference") is None:
            call_reference = ""
        else:
            call_reference = binascii.hexlify(
                str(ussd_record.getComponentByName("callReference")))

        end_time_tmp = binascii.hexlify(
            str(ussd_record.getComponentByName("endTime")))
        end_time = append_timezone_offset(parseTimestamp(end_time_tmp))

        if ussd_record.getComponentByName("errorCode") is None:
            error_code = ""
        else:
            error_code = ussd_record.getComponentByName("errorCode").getName()

        if ussd_record.getComponentByName("exchangeIdentity") is None:
            exchange_identity = ""
        else:
            exchange_identity = str(
                ussd_record.getComponentByName("exchangeIdentity"))

        if ussd_record.getComponentByName("hotBillingTag") is None:
            hot_billing_tag = -255
        else:
            hot_billing_tag = long(
                str(ussd_record.getComponentByName("hotBillingTag")))

        if ussd_record.getComponentByName("hotBillingTag2") is None:
            hot_billing_tag2 = -255
        else:
            hot_billing_tag2 = long(
                str(ussd_record.getComponentByName("hotBillingTag2")))

        if ussd_record.getComponentByName("location") is not None:
            location = ussd_record.getComponentByName("location")
            location_area = binascii.hexlify(
                str(location.getComponentByName("locationArea")))
            location_area_str = str(location_area)

            location_cellid_binascii = location_area_str[10:14]
            format_location_cellid_binascii = int(location_cellid_binascii, 16)
            location_cellid = format(format_location_cellid_binascii, '05')

            location_area_code_binascii = location_area_str[6:10]
            format_location_area_code_binascii = int(
                location_area_code_binascii, 16)
            location_area_code = format(format_location_area_code_binascii,
                                        '05')

            location_plmn = parseMcc(location_area_str[0:6]) + parseMnc(
                location_area_str[0:6])

            location_sac = location_area_str[-4:]
        else:
            location_cellid = ""
            location_area_code = ""
            location_plmn = ""
            location_sac = ""

        if ussd_record.getComponentByName("msClassmark") is None:
            ms_classmark = ""
        else:
            ms_classmark = binascii.hexlify(
                str(ussd_record.getComponentByName("msClassmark")))

        if ussd_record.getComponentByName("operatorId") is None:
            operator_id = -255
        else:
            operator_id = long(
                str(ussd_record.getComponentByName("operatorId")))

        if ussd_record.getComponentByName("recordSequenceNumber") is None:
            record_sequence_number = ""
        else:
            record_sequence_number = binascii.hexlify(
                str(ussd_record.getComponentByName("recordSequenceNumber")))

        if ussd_record.getComponentByName("recordType") is None:
            record_type = -255
        else:
            record_type = long(
                str(ussd_record.getComponentByName("recordType")))

        if ussd_record.getComponentByName("recordingEntity") is None:
            recording_entity = ""
        else:
            recording_entity_binascii = binascii.hexlify(
                str(ussd_record.getComponentByName("recordingEntity")))
            recording_entity_list = []
            recording_entity_data = list(recording_entity_binascii)
            for l in xrange(0, len(recording_entity_data) - 1, 2):
                recording_entity_list.append(recording_entity_data[l + 1] +
                                             "" + recording_entity_data[l])
            recording_entity_concatenated = ''.join(recording_entity_list)
            recording_entity_replace_f = recording_entity_concatenated.replace(
                "f", "")
            recording_entity = recording_entity_replace_f[
                2:7] + recording_entity_replace_f[7:]

        if ussd_record.getComponentByName("servedIMEI") is None:
            served_imei = ""
        else:
            served_imei_binascii = binascii.hexlify(
                str(ussd_record.getComponentByName("servedIMEI")))
            served_imei_list = []
            served_imei_data = list(served_imei_binascii)
            for i in xrange(0, len(served_imei_data) - 1, 2):
                served_imei_list.append(served_imei_data[i + 1] + "" +
                                        served_imei_data[i])
            served_imei_concatenated = ''.join(served_imei_list)
            served_imei = served_imei_concatenated.replace("f", "")

        if ussd_record.getComponentByName("servedIMSI") is None:
            served_imsi = ""
        else:
            served_imsi_binascii = binascii.hexlify(
                str(ussd_record.getComponentByName("servedIMSI")))
            served_imsi_list = []
            served_imsi_data = list(served_imsi_binascii)
            for j in xrange(0, len(served_imsi_data) - 1, 2):
                served_imsi_list.append(served_imsi_data[j + 1] + "" +
                                        served_imsi_data[j])
            served_imsi_concatenated = ''.join(served_imsi_list)
            served_imsi = served_imsi_concatenated.replace("f", "")

        if ussd_record.getComponentByName("servedMSISDN") is None:
            served_msisdn = ""
        else:
            served_msisdn_binascii = binascii.hexlify(
                str(ussd_record.getComponentByName("servedMSISDN")))
            served_msisdn_list = []
            served_msisdn_data = list(served_msisdn_binascii)
            for k in xrange(0, len(served_msisdn_data) - 1, 2):
                served_msisdn_list.append(served_msisdn_data[k + 1] + "" +
                                          served_msisdn_data[k])
            served_msisdn_concatenated = ''.join(served_msisdn_list)
            served_msisdn_replace_f = served_msisdn_concatenated.replace(
                "f", "")
            served_msisdn = served_msisdn_replace_f.replace(
                served_msisdn_replace_f[:3], '')

        start_time_tmp = binascii.hexlify(
            str(ussd_record.getComponentByName("startTime")))
        start_time = append_timezone_offset(parseTimestamp(start_time_tmp))

        if ussd_record.getComponentByName("systemType") is None:
            system_type = ""
        else:
            system_type_tmp = long(
                str(ussd_record.getComponentByName("systemType")))
            system_type = ""
            if system_type_tmp == 0:
                system_type = "unknown"
            elif system_type_tmp == 1:
                system_type = "iuUTRAN"
            elif system_type_tmp == 2:
                system_type = "gERAN"

        if ussd_record.getComponentByName("uSSDDataCodingScheme") is None:
            ussd_datacoding_scheme = ""
        else:
            ussd_datacoding_scheme = binascii.hexlify(
                str(ussd_record.getComponentByName("uSSDDataCodingScheme")))

        if ussd_record.getComponentByName("uSSDInteractionCount") is None:
            ussd_interaction_code = -255
        else:
            ussd_interaction_code = long(
                str(ussd_record.getComponentByName("uSSDInteractionCount")))

        if ussd_record.getComponentByName("uSSDOperationCode") is None:
            ussd_operation_code = ""
        else:
            ussd_operation_code_tmp = long(
                str(ussd_record.getComponentByName("uSSDOperationCode")))
            ussd_operation_code = ""
            if ussd_operation_code_tmp == 19:
                ussd_operation_code = "processUnstructuredSS-Data"
            elif ussd_operation_code_tmp == 59:
                ussd_operation_code = "processUnstructuredSS-Request"
            elif ussd_operation_code_tmp == 60:
                ussd_operation_code = "unstructuredSS-Request"
            elif ussd_operation_code_tmp == 61:
                ussd_operation_code = "unstructuredSS-Notify"

        if ussd_record.getComponentByName("uSSDServiceCode") is None:
            ussd_service_code = -255
        else:
            ussd_service_code = long(
                str(ussd_record.getComponentByName("uSSDServiceCode")))

        if ussd_record.getComponentByName("uSSDUnstructuredData") is None:
            ussd_unstructured_data = ""
        else:
            ussd_unstructured_data = binascii.hexlify(
                str(ussd_record.getComponentByName("uSSDUnstructuredData")))

        ussd_record = [
            call_reference, end_time, error_code, exchange_identity, file_id,
            hot_billing_tag, hot_billing_tag2, location_cellid,
            location_area_code, location_plmn, location_sac, ms_classmark,
            operator_id, record_sequence_number, record_type, recording_entity,
            served_imei, served_imsi, served_msisdn, start_time, system_type,
            ussd_datacoding_scheme, ussd_interaction_code, ussd_operation_code,
            ussd_service_code, ussd_unstructured_data,
            long(start_time.strftime("%Y%m%d")),
            long(start_time.strftime("%H"))
        ]

        return ussd_record
    def process_outgateway_records(outgateway_record, file_id, file_name):

        additional_chg_info = outgateway_record.getComponentByName(
            "additionalChgInfo")

        if additional_chg_info is None:
            charge_indicator = -255
        else:
            charge_indicator = long(
                str(additional_chg_info.getComponentByName("chargeIndicator")))

        if additional_chg_info is None:
            charged_party = ""
        else:
            charged_party_tmp = long(
                str(additional_chg_info.getComponentByName("chargedParty")))
            charged_party = ""
            if charged_party_tmp == 0:
                charged_party = "callingAsChargedParty"
            elif charged_party_tmp == 1:
                charged_party = "calledAsChargedParty"
            elif charged_party_tmp == 2:
                charged_party = "noCharging"
            elif charged_party_tmp == 3:
                charged_party = "anotherNumAsChargedParty"

        answer_time_tmp = binascii.hexlify(
            str(outgateway_record.getComponentByName("answerTime")))
        answer_time = append_timezone_offset(parseTimestamp(answer_time_tmp))

        if outgateway_record.getComponentByName("callDuration") is None:
            call_duration = -255
        else:
            call_duration = long(
                str(outgateway_record.getComponentByName("callDuration")))

        if outgateway_record.getComponentByName("callReference") is None:
            call_reference = ""
        else:
            call_reference = binascii.hexlify(
                str(outgateway_record.getComponentByName("callReference")))

        if outgateway_record.getComponentByName("calledNumber") is None:
            called_number = ""
        else:
            called_number_binascii = binascii.hexlify(
                str(outgateway_record.getComponentByName("calledNumber")))
            called_number_list = []
            called_number_data = list(called_number_binascii)
            for i in xrange(0, len(called_number_data) - 1, 2):
                called_number_list.append(called_number_data[i + 1] + "" +
                                          called_number_data[i])
            called_number_concatenated = ''.join(called_number_list)
            called_number = called_number_concatenated[2:]

        if outgateway_record.getComponentByName("callingNumber") is None:
            calling_number = ""
        else:
            calling_number_binascii = binascii.hexlify(
                str(outgateway_record.getComponentByName("callingNumber")))
            calling_number_list = []
            calling_number_data = list(calling_number_binascii)
            for i in xrange(0, len(calling_number_data) - 1, 2):
                calling_number_list.append(calling_number_data[i + 1] + "" +
                                           calling_number_data[i])
            calling_number_concatenated = ''.join(calling_number_list)
            calling_number = calling_number_concatenated[2:]

        if outgateway_record.getComponentByName("causeForTerm") is None:
            cause_for_termination = ""
        else:
            cause_for_termination_tmp = long(
                str(outgateway_record.getComponentByName("causeForTerm")))
            cause_for_termination = ""
            if cause_for_termination_tmp == 0:
                cause_for_termination = "normalRelease"
            elif cause_for_termination_tmp == 1:
                cause_for_termination = "partialRecord"
            elif cause_for_termination_tmp == 2:
                cause_for_termination = "partialRecordCallReestablishment"
            elif cause_for_termination_tmp == 3:
                cause_for_termination = "unsuccessfulCallAttempt"
            elif cause_for_termination_tmp == 4:
                cause_for_termination = "stableCallAbnormalTermination"
            elif cause_for_termination_tmp == 5:
                cause_for_termination = "cAMELInitCallRelease"
            elif cause_for_termination_tmp == 52:
                cause_for_termination = "unauthorizedRequestingNetwork"
            elif cause_for_termination_tmp == 53:
                cause_for_termination = "unauthorizedLCSClient"
            elif cause_for_termination_tmp == 54:
                cause_for_termination = "positionMethodFailure"
            elif cause_for_termination_tmp == 58:
                cause_for_termination = "unknownOrUnreachableLCSClient"
            elif cause_for_termination_tmp == 101:
                cause_for_termination = "cAMELPlayTone"
            elif cause_for_termination_tmp == 102:
                cause_for_termination = "changeOfConfDueToCPH"
            elif cause_for_termination_tmp == 103:
                cause_for_termination = "falseAnswerCharge"
            elif cause_for_termination_tmp == 104:
                cause_for_termination = "failPlayTone"
            elif cause_for_termination_tmp == 105:
                cause_for_termination = "releaseForPreemption"

        if outgateway_record.getComponentByName("connectedNumber") is None:
            connected_number = ""
        else:
            connected_number_binascii = binascii.hexlify(
                str(outgateway_record.getComponentByName("connectedNumber")))
            connected_number_list = []
            connected_number_data = list(connected_number_binascii)
            for i in xrange(0, len(connected_number_data) - 1, 2):
                connected_number_list.append(connected_number_data[i + 1] +
                                             "" + connected_number_data[i])
            connected_number_concatenated = ''.join(connected_number_list)
            connected_number = connected_number_concatenated[2:]

        if outgateway_record.getComponentByName("dataVolume") is None:
            data_volume = -255
        else:
            data_volume = long(
                str(outgateway_record.getComponentByName("dataVolume")))

        if outgateway_record.getComponentByName("dDCFlag") is None:
            ddc_flag = -255
        else:
            ddc_flag = long(
                str(outgateway_record.getComponentByName("dDCFlag")))

        if outgateway_record.getComponentByName("diagnostics") is None:
            diagnostics = ""
        else:
            diagnostics = outgateway_record.getComponentByName(
                "diagnostics").getName()

        if outgateway_record.getComponentByName("exchangeIdentity") is None:
            exchange_identity = ""
        else:
            exchange_identity = str(
                outgateway_record.getComponentByName("exchangeIdentity"))

        if outgateway_record.getComponentByName("forwardedToNumber") is None:
            forwarded_to_number = ""
        else:
            forwarded_to_number = str(
                outgateway_record.getComponentByName("forwardedToNumber"))

        if outgateway_record.getComponentByName("gatewayRecordType") is None:
            gateway_record_type = ""
        else:
            gateway_record_type_tmp = long(
                str(outgateway_record.getComponentByName("gatewayRecordType")))
            gateway_record_type = ""
            if gateway_record_type_tmp == 0:
                gateway_record_type = "gatewayRecord"
            elif gateway_record_type_tmp == 1:
                gateway_record_type = "trunkRecord"
            elif gateway_record_type_tmp == 2:
                gateway_record_type = "sipRecord"

        if outgateway_record.getComponentByName("globalCallReference") is None:
            global_call_reference = ""
        else:
            global_call_reference = str(
                outgateway_record.getComponentByName("globalCallReference"))

        if outgateway_record.getComponentByName(
                "iMS-Charging-Identifier") is None:
            ims_charging_identifier = ""
        else:
            ims_charging_identifier = str(
                outgateway_record.getComponentByName(
                    "iMS-Charging-Identifier"))

        incoming_cic = outgateway_record.getComponentByName("incomingCic")

        if incoming_cic is None:
            incoming_cic_channel = -255
        else:
            incoming_cic_channel = long(
                str(incoming_cic.getComponentByName("channel")))

        if incoming_cic is None:
            incoming_cic_pcmunit = -255
        else:
            incoming_cic_pcmunit = long(
                str(incoming_cic.getComponentByName("pcmUnit")))

        if outgateway_record.getComponentByName("incomingTKGPName") is None:
            incoming_tkgpname = ""
        else:
            incoming_tkgpname = str(
                outgateway_record.getComponentByName("incomingTKGPName"))

        if outgateway_record.getComponentByName("incomingTrafficType") is None:
            incoming_traffic_type = ""
        else:
            incoming_traffic_type_tmp = long(
                str(outgateway_record.getComponentByName(
                    "incomingTrafficType")))
            incoming_traffic_type = ""
            if incoming_traffic_type_tmp == 0:
                incoming_traffic_type = "unknown"
            elif incoming_traffic_type_tmp == 1:
                incoming_traffic_type = "localNetworkMobile"
            elif incoming_traffic_type_tmp == 2:
                incoming_traffic_type = "localNetworkFixed"
            elif incoming_traffic_type_tmp == 3:
                incoming_traffic_type = "externalNetwork"

        if outgateway_record.getComponentByName("initialCalledNumber") is None:
            initial_called_number = ""
        else:
            initial_called_number = str(
                outgateway_record.getComponentByName("initialCalledNumber"))

        if outgateway_record.getComponentByName("isdnBasicService") is None:
            isdn_basicservice = ""
        else:
            isdn_basicservice_choice = outgateway_record.getComponentByName(
                "isdnBasicService")
            isdn_basicservice_choice_hexvalue = isdn_basicservice_choice.getComponent(
            ).prettyPrint()
            if isdn_basicservice_choice_hexvalue == "0x11":
                isdn_basicservice = "teleservice"
            else:
                isdn_basicservice = "bearerservice"

        is_multimedia_call_get_value = outgateway_record.getComponentByName(
            "isMultiMediaCall")
        is_multimedia_call = boolean_value(is_multimedia_call_get_value)

        last_longpart_ind_get_value = outgateway_record.getComponentByName(
            "lastLongPartInd")
        last_longpart_ind = boolean_value(last_longpart_ind_get_value)

        if outgateway_record.getComponentByName("localOfficeForward") is None:
            local_office_forward = ""
        else:
            local_office_forward = str(
                outgateway_record.getComponentByName("localOfficeForward"))

        if outgateway_record.getComponentByName("millisecDuration") is None:
            milli_sec_duration = -255
        else:
            milli_sec_duration = long(
                str(outgateway_record.getComponentByName("millisecDuration")))

        if outgateway_record.getComponentByName("mNPNumber") is None:
            mnpnumber = ""
        else:
            mnpnumber = str(outgateway_record.getComponentByName("mNPNumber"))

        if outgateway_record.getComponentByName("mscIncomingTKGP") is None:
            msc_incoming_tkgp = ""
        else:
            msc_incoming_tkgp = binascii.hexlify(
                str(outgateway_record.getComponentByName("mscIncomingTKGP")))

        if outgateway_record.getComponentByName("mscOutgoingTKGP") is None:
            msc_outgoing_tkgp = ""
        else:
            msc_outgoing_tkgp = binascii.hexlify(
                str(outgateway_record.getComponentByName("mscOutgoingTKGP")))

        if outgateway_record.getComponentByName("mscSPC14") is None:
            mscspc14 = ""
        else:
            mscspc14 = binascii.hexlify(
                str(outgateway_record.getComponentByName("mscSPC14")))

        if outgateway_record.getComponentByName("mscSPC24") is None:
            mscspc24 = ""
        else:
            mscspc24 = binascii.hexlify(
                str(outgateway_record.getComponentByName("mscSPC24")))

        if outgateway_record.getComponentByName("operatorId") is None:
            operator_id = -255
        else:
            operator_id = long(
                str(outgateway_record.getComponentByName("operatorId")))

        if outgateway_record.getComponentByName("orig-ioi") is None:
            orig_ioi = ""
        else:
            orig_ioi = str(outgateway_record.getComponentByName("orig-ioi"))

        outgoing_cic = outgateway_record.getComponentByName("outgoingCic")

        if outgoing_cic is None:
            outgoing_cic_channel = -255
        else:
            outgoing_cic_channel = long(
                str(outgoing_cic.getComponentByName("channel")))

        if outgoing_cic is None:
            outgoing_cic_pcmunit = -255
        else:
            outgoing_cic_pcmunit = long(
                str(outgoing_cic.getComponentByName("pcmUnit")))

        if outgateway_record.getComponentByName("outgoingTKGPName") is None:
            outgoing_tkgpname = ""
        else:
            outgoing_tkgpname = str(
                outgateway_record.getComponentByName("outgoingTKGPName"))

        if outgateway_record.getComponentByName("outgoingTrafficType") is None:
            outgoing_traffic_type = ""
        else:
            outgoing_traffic_type_tmp = long(
                str(outgateway_record.getComponentByName(
                    "outgoingTrafficType")))
            outgoing_traffic_type = ""
            if outgoing_traffic_type_tmp == 0:
                outgoing_traffic_type = "unknown"
            elif outgoing_traffic_type_tmp == 1:
                outgoing_traffic_type = "localNetworkMobile"
            elif outgoing_traffic_type_tmp == 2:
                outgoing_traffic_type = "localNetworkFixed"
            elif outgoing_traffic_type_tmp == 3:
                outgoing_traffic_type = "externalNetwork"

        if outgateway_record.getComponentByName("partialRecordType") is None:
            partial_record_type = ""
        else:
            partial_record_type_tmp = long(
                str(outgateway_record.getComponentByName("partialRecordType")))
            partial_record_type = ""
            if partial_record_type_tmp == 1:
                partial_record_type = "serviceChange"

        if outgateway_record.getComponentByName("pbrt") is None:
            pbrt = -255
        else:
            pbrt = long(str(outgateway_record.getComponentByName("pbrt")))

        if outgateway_record.getComponentByName(
                "reasonForServiceChange") is None:
            reason_for_service_change = ""
        else:
            reason_for_service_change_tmp = long(
                str(
                    outgateway_record.getComponentByName(
                        "reasonForServiceChange")))
            reason_for_service_change = ""
            if reason_for_service_change_tmp == 0:
                reason_for_service_change = "msubInitiate"
            elif reason_for_service_change_tmp == 1:
                reason_for_service_change = "mscInitiated"
            elif reason_for_service_change_tmp == 2:
                reason_for_service_change = "callSetupFallBack"
            elif reason_for_service_change_tmp == 3:
                reason_for_service_change = "callSetupChangeOrder"

        if outgateway_record.getComponentByName("recordingEntity") is None:
            recording_entity = ""
        else:
            recording_entity_binascii = binascii.hexlify(
                str(outgateway_record.getComponentByName("recordingEntity")))
            recording_entity_list = []
            recording_entity_data = list(recording_entity_binascii)
            for l in xrange(0, len(recording_entity_data) - 1, 2):
                recording_entity_list.append(recording_entity_data[l + 1] +
                                             "" + recording_entity_data[l])
            recording_entity_concatenated = ''.join(recording_entity_list)
            recording_entity_replace_f = recording_entity_concatenated.replace(
                "f", "")
            recording_entity = recording_entity_replace_f[
                2:7] + recording_entity_replace_f[7:]

        if outgateway_record.getComponentByName(
                "recordSequenceNumber") is None:
            record_sequence_number = ""
        else:
            record_sequence_number = binascii.hexlify(
                str(
                    outgateway_record.getComponentByName(
                        "recordSequenceNumber")))

        if outgateway_record.getComponentByName("recordType") is None:
            record_type = -255
        else:
            record_type = long(
                str(outgateway_record.getComponentByName("recordType")))

        if outgateway_record.getComponentByName("redirectNumber") is None:
            redirecting_number = ""
        else:
            redirecting_number_binascii = binascii.hexlify(
                str(outgateway_record.getComponentByName("redirectNumber")))
            redirecting_number_list = []
            redirecting_number_data = list(redirecting_number_binascii)
            for i in xrange(0, len(redirecting_number_data) - 1, 2):
                redirecting_number_list.append(redirecting_number_data[i + 1] +
                                               "" + redirecting_number_data[i])
            redirecting_number_concatenated = ''.join(redirecting_number_list)
            redirecting_number = redirecting_number_concatenated[2:].replace(
                "f", "")

        release_time_tmp = binascii.hexlify(
            str(outgateway_record.getComponentByName("releaseTime")))
        release_time = append_timezone_offset(parseTimestamp(release_time_tmp))

        rn_plus_b_get_value = outgateway_record.getComponentByName("rnPlusB")
        rn_plus_b = boolean_value(rn_plus_b_get_value)

        if outgateway_record.getComponentByName("roamingNumber") is None:
            roaming_number = ""
        else:
            roaming_number_binascii = binascii.hexlify(
                str(outgateway_record.getComponentByName("roamingNumber")))
            roaming_number_list = []
            roaming_number_data = list(roaming_number_binascii)
            for i in xrange(0, len(roaming_number_data) - 1, 2):
                roaming_number_list.append(roaming_number_data[i + 1] + "" +
                                           roaming_number_data[i])
            roaming_number_concatenated = ''.join(roaming_number_list)
            roaming_number = roaming_number_concatenated[2:].replace("f", "")

        seizure_time_tmp = binascii.hexlify(
            str(outgateway_record.getComponentByName("seizureTime")))
        seizure_time = append_timezone_offset(parseTimestamp(seizure_time_tmp))

        if outgateway_record.getComponentByName("sequenceNumber") is None:
            sequence_number = -255
        else:
            sequence_number = long(
                str(outgateway_record.getComponentByName("sequenceNumber")))

        if outgateway_record.getComponentByName(
                "serviceChangeInitiator") is None:
            service_change_initiator = -255
        else:
            service_change_initiator = long(
                str(
                    outgateway_record.getComponentByName(
                        "serviceChangeInitiator")))

        if outgateway_record.getComponentByName("term-ioi") is None:
            term_ioi = ""
        else:
            term_ioi = str(outgateway_record.getComponentByName("term-ioi"))

        if outgateway_record.getComponentByName("trunkLine") is None:
            trunk_line = ""
        else:
            trunk_line = binascii.hexlify(
                str(outgateway_record.getComponentByName("trunkLine")))

        if outgateway_record.getComponentByName("typeOfServiceChange") is None:
            types_of_service_change = ""
        else:
            types_of_service_change_tmp = long(
                str(outgateway_record.getComponentByName(
                    "typeOfServiceChange")))
            types_of_service_change = ""
            if types_of_service_change_tmp == 0:
                types_of_service_change = "changeToSpeech"
            elif types_of_service_change_tmp == 1:
                types_of_service_change = "changeToMultimedia"

        if outgateway_record.getComponentByName("startTime") is None:
            start_time = parse_start_time(file_name)
        else:
            start_time_tmp = binascii.hexlify(
                str(outgateway_record.getComponentByName("startTime")))
            start_time = append_timezone_offset(parseTimestamp(start_time_tmp))

        outgateway_record = [
            charge_indicator, charged_party, answer_time, call_duration,
            call_reference, called_number, calling_number,
            cause_for_termination, connected_number, ddc_flag, data_volume,
            diagnostics, exchange_identity, file_id, forwarded_to_number,
            gateway_record_type, global_call_reference,
            ims_charging_identifier, incoming_cic_channel,
            incoming_cic_pcmunit, incoming_tkgpname, incoming_traffic_type,
            initial_called_number, is_multimedia_call, isdn_basicservice,
            last_longpart_ind, local_office_forward, mnpnumber,
            milli_sec_duration, msc_incoming_tkgp, msc_outgoing_tkgp, mscspc14,
            mscspc24, operator_id, orig_ioi, outgoing_cic_channel,
            outgoing_cic_pcmunit, outgoing_tkgpname, outgoing_traffic_type,
            partial_record_type, pbrt, reason_for_service_change,
            record_sequence_number, record_type, recording_entity,
            redirecting_number, release_time, rn_plus_b, roaming_number,
            seizure_time, sequence_number, service_change_initiator,
            start_time, term_ioi, trunk_line, types_of_service_change,
            long(seizure_time.strftime("%Y%m%d")),
            long(seizure_time.strftime("%H"))
        ]

        return outgateway_record
Exemple #3
0
    def process_mcfcall_records(mcfcall_record, file_id, file_name):

        additional_chg_info = mcfcall_record.getComponentByName("additionalChgInfo")

        if additional_chg_info is None:
            charge_indicator = -255
        else:
            charge_indicator = long(str(additional_chg_info.getComponentByName("chargeIndicator")))

        if additional_chg_info is None:
            charged_party = ""
        else:
            charged_party_tmp = long(str(additional_chg_info.getComponentByName("chargedParty")))
            charged_party = ""
            if charged_party_tmp == 0:
                charged_party = "callingAsChargedParty"
            elif charged_party_tmp == 1:
                charged_party = "calledAsChargedParty"
            elif charged_party_tmp == 2:
                charged_party = "noCharging"
            elif charged_party_tmp == 3:
                charged_party = "anotherNumAsChargedParty"

        answer_time_tmp = binascii.hexlify(str(mcfcall_record.getComponentByName("answerTime")))
        answer_time = append_timezone_offset(parseTimestamp(answer_time_tmp))
        if mcfcall_record.getComponentByName("bSCIdentification") is None:
            bsdidentification = ""
        else:
            bsdidentification = binascii.hexlify(str(mcfcall_record.getComponentByName("bSCIdentification")))

        if mcfcall_record.getComponentByName("basicService") is None:
            basic_service = ""
        else:
            basic_service_choice = mcfcall_record.getComponentByName("basicService")
            basic_service_choice_hexvalue = basic_service_choice.getComponent().prettyPrint()
            if basic_service_choice_hexvalue == "0x11":
                basic_service = "teleservice"
            else:
                basic_service = "bearerservice"

        if mcfcall_record.getComponentByName("bscIdentification24") is None:
            bsdidentification_24 = ""
        else:
            bsdidentification_24 = binascii.hexlify(str(mcfcall_record.getComponentByName("bscIdentification24")))

        if mcfcall_record.getComponentByName("byPass") is None:
            by_pass = -255
        else:
            by_pass = long(str(mcfcall_record.getComponentByName("byPass")))

        if mcfcall_record.getComponentByName("byPassFlag2") is None:
            by_pass_flag2 = -255
        else:
            by_pass_flag2 = long(str(mcfcall_record.getComponentByName("byPassFlag2")))

        if mcfcall_record.getComponentByName("cAMELInitCFIndicator") is None:
            camel_initcf_indicator = ""
        else:
            camel_initcf_indicator_tmp = long(str(mcfcall_record.getComponentByName("cAMELInitCFIndicator")))
            camel_initcf_indicator = ""
            if camel_initcf_indicator_tmp == 0:
                camel_initcf_indicator = "noCAMELCallForwarding"
            if camel_initcf_indicator_tmp == 1:
                camel_initcf_indicator = "cAMELCallForwarding"

        cug_category = mcfcall_record.getComponentByName("cUGCategory")

        if cug_category is None:
            cug_category_calltype = -255
        else:
            cug_category_calltype = long(str(cug_category.getComponentByName("callType")))

        if cug_category is None:
            cug_category_usertype = -255
        else:
            cug_category_usertype = long(str(cug_category.getComponentByName("userType")))

        if cug_category is None:
            cug_index = -255
        else:
            cug_index = long(str(cug_category.getComponentByName("cUGIndex")))

        if mcfcall_record.getComponentByName("cUGInterLockCode") is None:
            cug_interlock_code = ""
        else:
            cug_interlock_code = str(mcfcall_record.getComponentByName("cUGInterLockCode"))

        cug_outgoing_accessind = bool(mcfcall_record.getComponentByName("cUGOutgoingAccessInd"))

        cug_outgoing_accessused = bool(mcfcall_record.getComponentByName("cUGOutgoingAccessUsed"))

        if mcfcall_record.getComponentByName("callDuration") is None:
            call_duration = -255
        else:
            call_duration = long(str(mcfcall_record.getComponentByName("callDuration")))

        if mcfcall_record.getComponentByName("callReference") is None:
            call_reference = ""
        else:
            call_reference = binascii.hexlify(str(mcfcall_record.getComponentByName("callReference")))

        if mcfcall_record.getComponentByName("calledLocation") is not None:
            called_location = mcfcall_record.getComponentByName("calledLocation")
            location_area = binascii.hexlify(str(called_location.getComponentByName("locationArea")))
            location_area_str = str(location_area)

            location_cellid_binascii = location_area_str[10:14]
            format_location_cellid_binascii = int(location_cellid_binascii, 16)
            called_location_cellid = format(format_location_cellid_binascii, '05')

            location_area_code_binascii = location_area_str[6:10]
            format_location_area_code_binascii = int(location_area_code_binascii, 16)
            called_location_area_code = format(format_location_area_code_binascii, '05')

            called_location_plmn = parseMcc(location_area_str[0:6]) + parseMnc(location_area_str[0:6])

            called_location_sac = location_area_str[-4:]
        else:
            called_location_cellid = ""
            called_location_area_code = ""
            called_location_plmn = ""
            called_location_sac = ""

        if mcfcall_record.getComponentByName("calledNumber") is None:
            called_number = ""
        else:
            called_number_binascii = binascii.hexlify(str(mcfcall_record.getComponentByName("calledNumber")))
            called_number_list = []
            called_number_data = list(called_number_binascii)
            for i in xrange(0, len(called_number_data) - 1, 2):
                called_number_list.append(called_number_data[i + 1] + "" + called_number_data[i])
            called_number_concatenated = ''.join(called_number_list)
            called_number = called_number_concatenated[2:]

        if mcfcall_record.getComponentByName("callingNumber") is None:
            calling_number = ""
        else:
            calling_number_binascii = binascii.hexlify(
                    str(mcfcall_record.getComponentByName("callingNumber")))
            calling_number_list = []
            calling_number_data = list(calling_number_binascii)
            for i in xrange(0, len(calling_number_data) - 1, 2):
                calling_number_list.append(calling_number_data[i + 1] + "" + calling_number_data[i])
            calling_number_concatenated = ''.join(calling_number_list)
            calling_number = calling_number_concatenated[2:]

        if mcfcall_record.getComponentByName("callingPartyRoamingInd") is None:
            calling_party_roamingind = ""
        else:
            calling_party_roamingind_int = str(mcfcall_record.getComponentByName("callingPartyRoamingInd"))
            if calling_party_roamingind_int == "1":
                calling_party_roamingind = "TRUE"
            else:
                calling_party_roamingind = "FALSE"

        if mcfcall_record.getComponentByName("carp") is None:
            carp = -255
        else:
            carp = long(str(mcfcall_record.getComponentByName("carp")))

        cause_for_termination_tmp = long(str(mcfcall_record.getComponentByName("causeForTerm")))
        cause_for_termination = ""
        if cause_for_termination_tmp == 0:
            cause_for_termination = "normalRelease"
        elif cause_for_termination_tmp == 1:
            cause_for_termination = "partialRecord"
        elif cause_for_termination_tmp == 2:
            cause_for_termination = "partialRecordCallReestablishment"
        elif cause_for_termination_tmp == 3:
            cause_for_termination = "unsuccessfulCallAttempt"
        elif cause_for_termination_tmp == 4:
            cause_for_termination = "stableCallAbnormalTermination"
        elif cause_for_termination_tmp == 5:
            cause_for_termination = "cAMELInitCallRelease"
        elif cause_for_termination_tmp == 52:
            cause_for_termination = "unauthorizedRequestingNetwork"
        elif cause_for_termination_tmp == 53:
            cause_for_termination = "unauthorizedLCSClient"
        elif cause_for_termination_tmp == 54:
            cause_for_termination = "positionMethodFailure"
        elif cause_for_termination_tmp == 58:
            cause_for_termination = "unknownOrUnreachableLCSClient"
        elif cause_for_termination_tmp == 101:
            cause_for_termination = "cAMELPlayTone"
        elif cause_for_termination_tmp == 102:
            cause_for_termination = "changeOfConfDueToCPH"
        elif cause_for_termination_tmp == 103:
            cause_for_termination = "falseAnswerCharge"
        elif cause_for_termination_tmp == 104:
            cause_for_termination = "failPlayTone"
        elif cause_for_termination_tmp == 105:
            cause_for_termination = "releaseForPreemption"

        if mcfcall_record.getComponentByName("connectedNumber") is None:
            connected_number = ""
        else:
            connected_number_binascii = binascii.hexlify(str(mcfcall_record.getComponentByName("connectedNumber")))
            connected_number_list = []
            connected_number_data = list(connected_number_binascii)
            for i in xrange(0, len(connected_number_data) - 1, 2):
                connected_number_list.append(connected_number_data[i + 1] + "" + connected_number_data[i])
            connected_number_concatenated = ''.join(connected_number_list)
            connected_number = connected_number_concatenated[2:]

        if mcfcall_record.getComponentByName("dataRate") is None:
            data_rate = -255
        else:
            data_rate = long(str(mcfcall_record.getComponentByName("dataRate")))

        if mcfcall_record.getComponentByName("dataVolume") is None:
            data_volume = -255
        else:
            data_volume = long(str(mcfcall_record.getComponentByName("dataVolume")))

        if mcfcall_record.getComponentByName("defaultCallHandling") is None:
            default_call_handling = ""
        else:
            default_call_handling_tmp = long(str(mcfcall_record.getComponentByName("defaultCallHandling")))
            default_call_handling = ""
            if default_call_handling_tmp == 0:
                default_call_handling = "continueCall"
            elif default_call_handling_tmp == 1:
                default_call_handling = "releaseCall"

        if mcfcall_record.getComponentByName("defaultCallHandling_2") is None:
            default_call_handling2 = ""
        else:
            default_call_handling2_tmp = long(str(mcfcall_record.getComponentByName("defaultCallHandling_2")))
            default_call_handling2 = ""
            if default_call_handling2_tmp == 0:
                default_call_handling2 = "continueCall"
            elif default_call_handling2_tmp == 1:
                default_call_handling2 = "releaseCall"

        if mcfcall_record.getComponentByName("defaultCallHandling_3") is None:
            default_call_handling3 = ""
        else:
            default_call_handling3_tmp = long(str(mcfcall_record.getComponentByName("defaultCallHandling_3")))
            default_call_handling3 = ""
            if default_call_handling3_tmp == 0:
                default_call_handling3 = "continueCall"
            elif default_call_handling3_tmp == 1:
                default_call_handling3 = "releaseCall"

        if mcfcall_record.getComponentByName("diagnostics") is None:
            diagnostics = ""
        else:
            diagnostics = mcfcall_record.getComponentByName("diagnostics").getName()

        if mcfcall_record.getComponentByName("exchangeIdentity") is None:
            exchange_identity = ""
        else:
            exchange_identity = str(mcfcall_record.getComponentByName("exchangeIdentity"))

        if mcfcall_record.getComponentByName("fnur") is None:
            fnur = ""
        else:
            fnur_tmp = long(str(mcfcall_record.getComponentByName("fnur")))
            if fnur_tmp == 0:
                fnur = "fnur9600-BitsPerSecond"
            elif fnur_tmp == 1:
                fnur = "fnur14400BitsPerSecond"
            elif fnur_tmp == 2:
                fnur = "fnur19200BitsPerSecond"
            elif fnur_tmp == 3:
                fnur = "fnur14400BitsPerSecond"
            elif fnur_tmp == 4:
                fnur = "fnur28800BitsPerSecond"
            elif fnur_tmp == 5:
                fnur = "fnur38400BitsPerSecond"
            elif fnur_tmp == 6:
                fnur = "fnur48000BitsPerSecond"
            elif fnur_tmp == 7:
                fnur = "fnur56000BitsPerSecond"
            elif fnur_tmp == 8:
                fnur = "fnur64000BitsPerSecond"
            elif fnur_tmp == 9:
                fnur = "fnur33600BitsPerSecond"
            elif fnur_tmp == 10:
                fnur = "fnur32000BitsPerSecond"

        if mcfcall_record.getComponentByName("fordwardedToIMSI") is None:
            forwarded_to_imsi = ""
        else:
            forwarded_to_imsi = str(mcfcall_record.getComponentByName("fordwardedToIMSI"))

        if mcfcall_record.getComponentByName("freeFormatData") is None:
            free_format_data = ""
        else:
            free_format_data = str(mcfcall_record.getComponentByName("freeFormatData"))

        if mcfcall_record.getComponentByName("freeFormatDataAppend") is None:
            free_format_data_append = ""
        else:
            free_format_data_append = str(mcfcall_record.getComponentByName("freeFormatDataAppend"))

        if mcfcall_record.getComponentByName("freeFormatDataAppend_2") is None:
            free_format_data_append_2 = ""
        else:
            free_format_data_append_2 = str(mcfcall_record.getComponentByName("freeFormatDataAppend_2"))

        if mcfcall_record.getComponentByName("freeFormatDataAppend_3") is None:
            free_format_data_append_3 = ""
        else:
            free_format_data_append_3 = str(mcfcall_record.getComponentByName("freeFormatDataAppend_3"))

        if mcfcall_record.getComponentByName("freeFormatData_2") is None:
            free_format_data_2 = ""
        else:
            free_format_data_2 = str(mcfcall_record.getComponentByName("freeFormatData_2"))

        if mcfcall_record.getComponentByName("freeFormatData_3") is None:
            free_format_data_3 = ""
        else:
            free_format_data_3 = str(mcfcall_record.getComponentByName("freeFormatData_3"))

        if mcfcall_record.getComponentByName("globalCallReference") is None:
            global_call_reference = ""
        else:
            global_call_reference = str(mcfcall_record.getComponentByName("globalCallReference"))

        if mcfcall_record.getComponentByName("gsm-SCFAddress") is not None:
            gsm_scfaddress_binascii = binascii.hexlify(str(mcfcall_record.getComponentByName("gsm-SCFAddress")))
            gsm_scfaddress_list = []
            gsm_scfaddress_data = list(gsm_scfaddress_binascii)
            for i in xrange(0, len(gsm_scfaddress_data) - 1, 2):
                gsm_scfaddress_list.append(gsm_scfaddress_data[i + 1] + "" + gsm_scfaddress_data[i])
                gsm_scfaddress_concatenated = ''.join(gsm_scfaddress_list)
                gsm_scfaddress = gsm_scfaddress_concatenated[2:].replace("f", "")
        else:
            gsm_scfaddress = ""

        if mcfcall_record.getComponentByName("gsm-SCFAddress_2") is not None:
            gsm_scfaddress_2_binascii = binascii.hexlify(str(mcfcall_record.getComponentByName("gsm-SCFAddress_2")))
            gsm_scfaddress_2_list = []
            gsm_scfaddress_2_data = list(gsm_scfaddress_2_binascii)
            for j in xrange(0, len(gsm_scfaddress_2_data) - 1, 2):
                gsm_scfaddress_2_list.append(gsm_scfaddress_2_data[j + 1] + "" + gsm_scfaddress_2_data[j])
                gsm_scfaddress_2_concatenated = ''.join(gsm_scfaddress_2_list)
                gsm_scfaddress_2 = gsm_scfaddress_2_concatenated[2:].replace("f", "")
        else:
            gsm_scfaddress_2 = ""

        if mcfcall_record.getComponentByName("gsm-SCFAddress_3") is not None:
            gsm_scfaddress_3_binascii = binascii.hexlify(str(mcfcall_record.getComponentByName("gsm-SCFAddress_3")))
            gsm_scfaddress_3_list = []
            gsm_scfaddress_3_data = list(gsm_scfaddress_3_binascii)
            for k in xrange(0, len(gsm_scfaddress_3_data) - 1, 2):
                gsm_scfaddress_3_list.append(gsm_scfaddress_3_data[k + 1] + "" + gsm_scfaddress_3_data[k])
                gsm_scfaddress_3_concatenated = ''.join(gsm_scfaddress_3_list)
                gsm_scfaddress_3 = gsm_scfaddress_3_concatenated[2:].replace("f", "")
        else:
            gsm_scfaddress_3 = ""

        if mcfcall_record.getComponentByName("hotBillingTag") is None:
            hot_billing_tag = -255
        else:
            hot_billing_tag = long(str(mcfcall_record.getComponentByName("hotBillingTag")))

        if mcfcall_record.getComponentByName("hotBillingTag2") is None:
            hot_billing_tag2 = -255
        else:
            hot_billing_tag2 = long(str(mcfcall_record.getComponentByName("hotBillingTag2")))

        if mcfcall_record.getComponentByName("iNAPMNPPortStatus") is None:
            inapmnpport_status = ""
        else:
            inapmnpport_status_tmp = long(str(mcfcall_record.getComponentByName("iNAPMNPPortStatus")))
            inapmnpport_status = ""
            if inapmnpport_status_tmp == 1:
                inapmnpport_status = "unkown"
            elif inapmnpport_status_tmp == 2:
                inapmnpport_status = "portedNumber"
            elif inapmnpport_status_tmp == 3:
                inapmnpport_status = "nonPortedNumber"

        if mcfcall_record.getComponentByName("iNAPMNPQueryMethod") is None:
            inapmnquerymethod = ""
        else:
            inapmnquerymethod_tmp = long(str(mcfcall_record.getComponentByName("iNAPMNPQueryMethod")))
            inapmnquerymethod = ""
            if inapmnquerymethod_tmp == 1:
                inapmnquerymethod = "unkown"
            elif inapmnquerymethod_tmp == 2:
                inapmnquerymethod = "iNSolution"
            elif inapmnquerymethod_tmp == 3:
                inapmnquerymethod = "sRFSolution"

        if mcfcall_record.getComponentByName("iNAPMNPRoutingNumber") is None:
            inapmn_routing_number = ""
        else:
            inapmn_routing_number = str(mcfcall_record.getComponentByName("iNAPMNPRoutingNumber"))

        incoming_cic = mcfcall_record.getComponentByName("incomingCic")

        if incoming_cic is None:
            incoming_cic_channel = -255
        else:
            incoming_cic_channel = long(str(incoming_cic.getComponentByName("channel")))

        if incoming_cic is None:
            incoming_cic_pcmunit = -255
        else:
            incoming_cic_pcmunit = long(str(incoming_cic.getComponentByName("pcmUnit")))

        if mcfcall_record.getComponentByName("incomingTKGPName") is None:
            incoming_tkgpname = ""
        else:
            incoming_tkgpname = str(mcfcall_record.getComponentByName("incomingTKGPName"))

        if mcfcall_record.getComponentByName("incomingTrafficType") is None:
            incoming_traffic_type = ""
        else:
            incoming_traffic_type_tmp = long(str(mcfcall_record.getComponentByName("incomingTrafficType")))
            incoming_traffic_type = ""
            if incoming_traffic_type_tmp == 0:
                incoming_traffic_type = "unknown"
            elif incoming_traffic_type_tmp == 1:
                incoming_traffic_type = "localNetworkMobile"
            elif incoming_traffic_type_tmp == 2:
                incoming_traffic_type = "localNetworkFixed"
            elif incoming_traffic_type_tmp == 3:
                incoming_traffic_type = "externalNetwork"

        is_camel_call_get_value = mcfcall_record.getComponentByName("isCAMELCall")
        is_camel_call = boolean_value(is_camel_call_get_value)

        is_cug_used_get_value = mcfcall_record.getComponentByName("isCUGUsed")
        is_cug_used = boolean_value(is_cug_used_get_value)

        is_inapmnquery_get_value = mcfcall_record.getComponentByName("isINAPMNPQuery")
        is_inapmnquery = boolean_value(is_inapmnquery_get_value)

        is_multi_media_call_get_value = mcfcall_record.getComponentByName("isMultiMediaCall")
        is_multi_media_call = boolean_value(is_multi_media_call_get_value)

        last_long_part_ind_get_value = mcfcall_record.getComponentByName("lastLongPartInd")
        last_long_part_ind = boolean_value(last_long_part_ind_get_value)

        if mcfcall_record.getComponentByName("levelOfCAMELService") is None:
            level_of_camel_service = ""
        else:
            level_of_camel_service_tmp = mcfcall_record.getComponentByName("levelOfCAMELService").prettyPrint()
            level_of_camel_service = level_of_camel_service_tmp[2:5]

        if mcfcall_record.getComponentByName("localOfficeForward") is None:
            local_office_forward = ""
        else:
            local_office_forward = str(mcfcall_record.getComponentByName("localOfficeForward"))

        if mcfcall_record.getComponentByName("location") is not None:
            location = mcfcall_record.getComponentByName("location")
            location_area = binascii.hexlify(str(location.getComponentByName("locationArea")))
            location_area_str = str(location_area)

            location_cellid_binascii = location_area_str[10:14]
            format_location_cellid_binascii = int(location_cellid_binascii, 16)
            location_cellid = format(format_location_cellid_binascii, '05')

            location_area_code_binascii = location_area_str[6:10]
            format_location_area_code_binascii = int(location_area_code_binascii, 16)
            location_area_code = format(format_location_area_code_binascii, '05')

            location_plmn = parseMcc(location_area_str[0:6]) + parseMnc(location_area_str[0:6])

            location_sac = location_area_str[-4:]
        else:
            location_cellid = ""
            location_area_code = ""
            location_plmn = ""
            location_sac = ""

        if mcfcall_record.getComponentByName("mNPNumber") is None:
            mnpnumber = ""
        else:
            mnpnumber = str(mcfcall_record.getComponentByName("mNPNumber"))

        if mcfcall_record.getComponentByName("mNPRoutingNumber") is None:
            mnproutingnumber = ""
        else:
            mnproutingnumber = str(mcfcall_record.getComponentByName("mNPRoutingNumber"))

        if mcfcall_record.getComponentByName("mSCAddress") is None:
            msc_address = ""
        else:
            msc_address_binascii = binascii.hexlify(str(mcfcall_record.getComponentByName("mSCAddress")))
            msc_address_list = []
            msc_address_data = list(msc_address_binascii)
            for i in xrange(0, len(msc_address_data) - 1, 2):
                msc_address_list.append(msc_address_data[i + 1] + "" + msc_address_data[i])
                msc_address_concatenated = ''.join(msc_address_list)
                msc_address = msc_address_concatenated[2:].replace("f", "")

        if mcfcall_record.getComponentByName("mcfType") is None:
            mcf_type = ""
        else:
            mcf_type_tmp = long(str(mcfcall_record.getComponentByName("mcfType")))
            mcf_type = ""
            if mcf_type_tmp == 0:
                mcf_type = "unconditional"
            elif mcf_type_tmp == 1:
                mcf_type = "busy"
            elif mcf_type_tmp == 2:
                mcf_type = "notReply"
            elif mcf_type_tmp == 3:
                mcf_type = "notReachable"
            elif mcf_type_tmp == 254:
                mcf_type = "callBack"

        if mcfcall_record.getComponentByName("millisecDuration") is None:
            milli_sec_duration = -255
        else:
            milli_sec_duration = long(str(mcfcall_record.getComponentByName("millisecDuration")))

        if mcfcall_record.getComponentByName("mscIncomingTKGP") is None:
            msc_incoming_tkgp = ""
        else:
            msc_incoming_tkgp = binascii.hexlify(str(mcfcall_record.getComponentByName("mscIncomingTKGP")))

        if mcfcall_record.getComponentByName("mscOutgoingTKGP") is None:
            msc_outgoing_tkgp = -255
        else:
            msc_outgoing_tkgp = binascii.hexlify(str(mcfcall_record.getComponentByName("mscOutgoingTKGP")))

        if mcfcall_record.getComponentByName("mscSPC14") is None:
            mscspc14 = ""
        else:
            mscspc14 = binascii.hexlify(str(mcfcall_record.getComponentByName("mscSPC14")))

        if mcfcall_record.getComponentByName("mscSPC24") is None:
            mscspc24 = ""
        else:
            mscspc24 = binascii.hexlify(str(mcfcall_record.getComponentByName("mscSPC24")))

        if mcfcall_record.getComponentByName("networkCallReference") is None:
            network_call_reference = ""
        else:
            network_call_reference = binascii.hexlify(str(mcfcall_record.getComponentByName("networkCallReference")))

        if mcfcall_record.getComponentByName("numberOfDPEncountered") is None:
            number_of_dp_encountered = -255
        else:
            number_of_dp_encountered = long(str(mcfcall_record.getComponentByName("numberOfDPEncountered")))

        if mcfcall_record.getComponentByName("numberOfForwarding") is None:
            number_of_forwarding = 0
        else:
            number_of_forwarding = long(str(mcfcall_record.getComponentByName("numberOfForwarding")))

        if mcfcall_record.getComponentByName("operatorId") is None:
            operator_id = -255
        else:
            operator_id = long(str(mcfcall_record.getComponentByName("operatorId")))

        if mcfcall_record.getComponentByName("originalCalledNumber") is None:
            original_called_number = ""
        else:
            original_called_number = str(mcfcall_record.getComponentByName("originalCalledNumber"))

        if mcfcall_record.getComponentByName("outPulsedNumber") is None:
            outpulsed_number = ""
        else:
            outpulsed_number = str(mcfcall_record.getComponentByName("outPulsedNumber"))

        outgoing_cic = mcfcall_record.getComponentByName("outgoingCic")

        if outgoing_cic is None:
            outgoing_cic_channel = -255
        else:
            outgoing_cic_channel = long(str(outgoing_cic.getComponentByName("channel")))

        if outgoing_cic is None:
            outgoing_cic_pcmunit = -255
        else:
            outgoing_cic_pcmunit = long(str(outgoing_cic.getComponentByName("pcmUnit")))

        if mcfcall_record.getComponentByName("outgoingTKGPName") is None:
            outgoing_tkgpname = ""
        else:
            outgoing_tkgpname = str(mcfcall_record.getComponentByName("outgoingTKGPName"))

        if mcfcall_record.getComponentByName("outgoingTrafficType") is None:
            outgoing_traffic_type = ""
        else:
            outgoing_traffic_type_tmp = long(str(mcfcall_record.getComponentByName("outgoingTrafficType")))
            outgoing_traffic_type = ""
            if outgoing_traffic_type_tmp == 0:
                outgoing_traffic_type = "unknown"
            elif outgoing_traffic_type_tmp == 1:
                outgoing_traffic_type = "localNetworkMobile"
            elif outgoing_traffic_type_tmp == 2:
                outgoing_traffic_type = "localNetworkFixed"
            elif outgoing_traffic_type_tmp == 3:
                outgoing_traffic_type = "externalNetwork"

        if mcfcall_record.getComponentByName("pbrt") is None:
            pbrt = -255
        else:
            pbrt = long(str(mcfcall_record.getComponentByName("pbrt")))

        if mcfcall_record.getComponentByName("rateIndication") is None:
            rate_indication = ""
        else:
            rate_indication = str(mcfcall_record.getComponentByName("rateIndication"))

        if mcfcall_record.getComponentByName("reasonForServiceChange") is None:
            reason_for_service_change = -255
        else:
            reason_for_service_change_tmp = long(str(mcfcall_record.getComponentByName("reasonForServiceChange")))
            reason_for_service_change = ""
            if reason_for_service_change_tmp == 0:
                reason_for_service_change = "msubInitiate"
            elif reason_for_service_change_tmp == 1:
                reason_for_service_change = "mscInitiated"
            elif reason_for_service_change_tmp == 2:
                reason_for_service_change = "callSetupFallBack"
            elif reason_for_service_change_tmp == 3:
                reason_for_service_change = "callSetupChangeOrder"

        if mcfcall_record.getComponentByName("partialRecordType") is None:
            partial_record_type = ""
        else:
            partial_record_type_tmp = long(str(mcfcall_record.getComponentByName("partialRecordType")))
            partial_record_type = ""
            if partial_record_type_tmp == 1:
                partial_record_type = "serviceChange"

        if mcfcall_record.getComponentByName("recordingEntity") is None:
            recording_entity = ""
        else:
            recording_entity_binascii = binascii.hexlify(str(mcfcall_record.getComponentByName("recordingEntity")))
            recording_entity_list = []
            recording_entity_data = list(recording_entity_binascii)
            for l in xrange(0, len(recording_entity_data) - 1, 2):
                recording_entity_list.append(recording_entity_data[l+1] + "" + recording_entity_data[l])
            recording_entity_concatenated = ''.join(recording_entity_list)
            recording_entity_replace_f = recording_entity_concatenated.replace("f", "")
            recording_entity = recording_entity_replace_f[2:7] + recording_entity_replace_f[7:]

        release_time_tmp = str(mcfcall_record.getComponentByName("releaseTime"))
        release_time_tmp_hexa = binascii.hexlify(str(release_time_tmp))
        if release_time_tmp is None:
            release_time = append_timezone_offset(parseTimestamp('1606151210022d0700'))
        else:
            release_time = append_timezone_offset(parseTimestamp(release_time_tmp_hexa))

        if mcfcall_record.getComponentByName("roamingNumber") is None:
            roaming_number = ""
        else:
            roaming_number_binascii = binascii.hexlify(str(mcfcall_record.getComponentByName("roamingNumber")))
            roaming_number_list = []
            roaming_number_data = list(roaming_number_binascii)
            for i in xrange(0, len(roaming_number_data) - 1, 2):
                roaming_number_list.append(roaming_number_data[i + 1] + "" + roaming_number_data[i])
            roaming_number_concatenated = ''.join(roaming_number_list)
            roaming_number = roaming_number_concatenated[2:]

        if mcfcall_record.getComponentByName("recordSequenceNumber") is None:
            record_sequence_number = ""
        else:
            record_sequence_number = binascii.hexlify(str(mcfcall_record.getComponentByName("recordSequenceNumber")))

        if mcfcall_record.getComponentByName("recordType") is None:
            record_type = -255
        else:
            record_type = long(str(mcfcall_record.getComponentByName("recordType")))

        if mcfcall_record.getComponentByName("routingCategory") is None:
            routing_category = ""
        else:
            routing_category = str(mcfcall_record.getComponentByName("routingCategory"))

        seizure_time_tmp = binascii.hexlify(str(mcfcall_record.getComponentByName("seizureTime")))
        seizure_time = append_timezone_offset(parseTimestamp(seizure_time_tmp))

        if mcfcall_record.getComponentByName("sequenceNumber") is None:
            sequence_number = -255
        else:
            sequence_number = long(str(mcfcall_record.getComponentByName("sequenceNumber")))

        if mcfcall_record.getComponentByName("servedIMEI") is None:
            served_imei = ""
        else:
            served_imei_binascii = binascii.hexlify(str(mcfcall_record.getComponentByName("servedIMEI")))
            served_imei_list = []
            served_imei_data = list(served_imei_binascii)
            for i in xrange(0, len(served_imei_data) - 1, 2):
                served_imei_list.append(served_imei_data[i + 1] + "" + served_imei_data[i])
            served_imei_concatenated = ''.join(served_imei_list)
            served_imei = served_imei_concatenated.replace("f", "")

        if mcfcall_record.getComponentByName("servedIMSI") is None:
            served_imsi = ""
        else:
            served_imsi_binascii = binascii.hexlify(str(mcfcall_record.getComponentByName("servedIMSI")))
            served_imsi_list = []
            served_imsi_data = list(served_imsi_binascii)
            for j in xrange(0, len(served_imsi_data) - 1, 2):
                served_imsi_list.append(served_imsi_data[j+1] + "" + served_imsi_data[j])
            served_imsi_concatenated = ''.join(served_imsi_list)
            served_imsi = served_imsi_concatenated.replace("f", "")

        if mcfcall_record.getComponentByName("servedMSISDN") is None:
            served_msisdn = ""
        else:
            served_msisdn_binascii = binascii.hexlify(str(mcfcall_record.getComponentByName("servedMSISDN")))
            served_msisdn_list = []
            served_msisdn_data = list(served_msisdn_binascii)
            for k in xrange(0, len(served_msisdn_data) - 1, 2):
                served_msisdn_list.append(served_msisdn_data[k+1] + "" + served_msisdn_data[k])
            served_msisdn_concatenated = ''.join(served_msisdn_list)
            served_msisdn_replace_f = served_msisdn_concatenated.replace("f", "")
            served_msisdn = served_msisdn_replace_f.replace(served_msisdn_replace_f[:3], '')

        if mcfcall_record.getComponentByName("serviceCategory") is None:
            service_category = ""
        else:
            service_category = binascii.hexlify(str(mcfcall_record.getComponentByName("serviceCategory")))

        if mcfcall_record.getComponentByName("serviceChangeInitiator") is None:
            service_change_initiator = -255
        else:
            service_change_initiator = long(str(mcfcall_record.getComponentByName("serviceChangeInitiator")))

        if mcfcall_record.getComponentByName("serviceKey") is None:
            service_key = -255
        else:
            service_key = long(str(mcfcall_record.getComponentByName("serviceKey")))

        if mcfcall_record.getComponentByName("serviceKey_2") is None:
            service_key_2 = -255
        else:
            service_key_2 = long(str(mcfcall_record.getComponentByName("serviceKey_2")))

        if mcfcall_record.getComponentByName("serviceKey_3") is None:
            service_key_3 = -255
        else:
            service_key_3 = long(str(mcfcall_record.getComponentByName("serviceKey_3")))

        start_time = append_timezone_offset(parseTimestamp('1606151209292d0700'))

        if mcfcall_record.getComponentByName("subscriberCategory") is None:
            subscriber_category = ""
        else:
            subscriber_category = binascii.hexlify(str(mcfcall_record.getComponentByName("subscriberCategory")))

        if mcfcall_record.getComponentByName("suppressCAMELInd") is None:
            suppress_camel_ind = ""
        else:
            suppress_camel_ind = str(mcfcall_record.getComponentByName("suppressCAMELInd"))

        if mcfcall_record.getComponentByName("systemType") is None:
            system_type = ""
        else:
            system_type_tmp = long(str(mcfcall_record.getComponentByName("systemType")))
            system_type = ""
            if system_type_tmp == 0:
                system_type = "unknown"
            elif system_type_tmp == 1:
                system_type = "iuUTRAN"
            elif system_type_tmp == 2:
                system_type = "gERAN"

        if mcfcall_record.getComponentByName("translatedNumber") is None:
            translated_number = ""
        else:
            translated_number_binascii = binascii.hexlify(str(mcfcall_record.getComponentByName("translatedNumber")))
            translated_number_list = []
            translated_number_data = list(translated_number_binascii)
            for l in xrange(0, len(translated_number_data) - 1, 2):
                translated_number_list.append(translated_number_data[l + 1] + "" + translated_number_data[l])
            translated_number_concatenated = ''.join(translated_number_list)
            translated_number = translated_number_concatenated[2:]

        if mcfcall_record.getComponentByName("transparencyIndicator") is None:
            transparency_indicator = ""
        else:
            transparency_indicator_tmp = long(str(mcfcall_record.getComponentByName("transparencyIndicator")))
            transparency_indicator = ""
            if transparency_indicator_tmp == 0:
                transparency_indicator = "transparent"
            elif transparency_indicator_tmp == 1:
                transparency_indicator = "nonTransparent"

        if mcfcall_record.getComponentByName("typeOfServiceChange") is None:
            types_of_service_change = ""
        else:
            types_of_service_change_tmp = long(str(mcfcall_record.getComponentByName("typeOfServiceChange")))
            types_of_service_change = ""
            if types_of_service_change_tmp == 0:
                types_of_service_change = "changeToSpeech"
            elif types_of_service_change_tmp == 1:
                types_of_service_change = "changeToMultimedia"

        if mcfcall_record.getComponentByName("wANAPPS") is None:
            wanapps = -255
        else:
            wanapps = long(str(mcfcall_record.getComponentByName("wANAPPS")))

        mcfcall_record = [charge_indicator, charged_party, answer_time, bsdidentification,
                          basic_service, bsdidentification_24, by_pass, by_pass_flag2, camel_initcf_indicator,
                          cug_category_calltype, cug_category_usertype, cug_index, cug_interlock_code,
                          cug_outgoing_accessind, cug_outgoing_accessused, call_duration,
                          call_reference,
                          called_location_cellid, called_location_area_code, called_location_plmn,
                          called_location_sac, called_number,
                          calling_number, calling_party_roamingind, carp, cause_for_termination,
                          connected_number, data_rate, data_volume, default_call_handling,
                          default_call_handling2, default_call_handling3, diagnostics,
                          exchange_identity,
                          file_id, fnur, forwarded_to_imsi, free_format_data, free_format_data_append,
                          free_format_data_append_2, free_format_data_append_3, free_format_data_2,
                          free_format_data_3, global_call_reference, gsm_scfaddress, gsm_scfaddress_2,
                          gsm_scfaddress_3, hot_billing_tag, hot_billing_tag2, inapmnpport_status,
                          inapmnquerymethod, inapmn_routing_number, incoming_cic_channel, incoming_cic_pcmunit,
                          incoming_tkgpname,
                          incoming_traffic_type, is_camel_call, is_cug_used, is_inapmnquery, is_multi_media_call,
                          last_long_part_ind,
                          level_of_camel_service, local_office_forward, location_cellid, location_area_code,
                          location_plmn, location_sac, mnpnumber, mnproutingnumber, msc_address,
                          mcf_type, milli_sec_duration, msc_incoming_tkgp, msc_outgoing_tkgp, mscspc14,
                          mscspc24, network_call_reference, number_of_dp_encountered, number_of_forwarding,
                          operator_id, original_called_number, outpulsed_number, outgoing_cic_channel,
                          outgoing_cic_pcmunit,
                          outgoing_tkgpname, outgoing_traffic_type, partial_record_type, pbrt,
                          rate_indication, reason_for_service_change, record_sequence_number, record_type,
                          recording_entity, release_time, roaming_number, routing_category, seizure_time,
                          sequence_number, served_imei, served_imsi, served_msisdn, service_category,
                          service_change_initiator, service_key, service_key_2, service_key_3, start_time,
                          subscriber_category, suppress_camel_ind, system_type, translated_number,
                          transparency_indicator, types_of_service_change, wanapps,
                          long(seizure_time.strftime("%Y%m%d")), long(seizure_time.strftime("%H"))
                          ]

        return mcfcall_record
    def process_mtsms_records(mtsms_record, file_id, file_name):

        if mtsms_record.getComponentByName("basicService") is None:
            basic_service = ""
        else:
            basic_service_choice = mtsms_record.getComponentByName(
                "basicService")
            basic_service_choice_hexvalue = basic_service_choice.getComponent(
            ).prettyPrint()
            if basic_service_choice_hexvalue == "0x11":
                basic_service = "teleservice"
            else:
                basic_service = "bearerservice"

        if mtsms_record.getComponentByName("cAMELSMSInformation") is not None:
            camel_sms_information = mtsms_record.getComponentByName(
                "cAMELSMSInformation")
            camel_smsc_address = str(
                camel_sms_information.getComponentByName("cAMELSMSCAddress"))
            calling_party_number = str(
                camel_sms_information.getComponentByName("callingPartyNumber"))
            if camel_sms_information is None:
                default_sms_handling = ""
            else:
                default_sms_handling_tmp = long(
                    str(
                        camel_sms_information.getComponentByName(
                            "defaultSMSHandling")))
                default_sms_handling = ""
                if default_sms_handling_tmp == 0:
                    default_sms_handling = "continueTransaction"
                elif default_sms_handling_tmp == 1:
                    default_sms_handling = "releaseTransaction"
            destination_subscriber_number = binascii.hexlify(
                str(
                    camel_sms_information.getComponentByName(
                        "destinationSubscriberNumber")))
            free_format_data = str(
                camel_sms_information.getComponentByName("freeFormatData"))
            gsm_scfaddress = str(
                camel_sms_information.getComponentByName("gsm-SCFAddress"))
            sms_reference_number = long(
                str(
                    camel_sms_information.getComponentByName(
                        "smsRefrenceNumber")))
            service_key = long(
                str(camel_sms_information.getComponentByName("serviceKey")))
        else:
            camel_smsc_address = ""
            calling_party_number = ""
            default_sms_handling = ""
            destination_subscriber_number = ""
            free_format_data = ""
            gsm_scfaddress = ""
            sms_reference_number = -255
            service_key = -255

        if mtsms_record.getComponentByName("callReference") is None:
            call_reference = ""
        else:
            call_reference = binascii.hexlify(
                str(mtsms_record.getComponentByName("callReference")))

        if mtsms_record.getComponentByName("concatenatedRecordNum") is None:
            concatenated_record_num = -255
        else:
            concatenated_record_num = long(
                str(mtsms_record.getComponentByName("concatenatedRecordNum")))

        if mtsms_record.getComponentByName("concatenatedRef") is None:
            concatenated_ref = -255
        else:
            concatenated_ref = long(
                str(mtsms_record.getComponentByName("concatenatedRef")))

        delivery_time_tmp = binascii.hexlify(
            str(mtsms_record.getComponentByName("deliveryTime")))
        delivery_time = append_timezone_offset(
            parseTimestamp(delivery_time_tmp))

        if mtsms_record.getComponentByName("directSmsFlag") is None:
            direct_sms_flag = -255
        else:
            direct_sms_flag = long(
                str(mtsms_record.getComponentByName("directSmsFlag")))

        if mtsms_record.getComponentByName("exchangeIdentity") is None:
            exchange_identity = ""
        else:
            exchange_identity = str(
                mtsms_record.getComponentByName("exchangeIdentity"))

        if mtsms_record.getComponentByName("hotBillingTag") is None:
            hot_billing_tag = -255
        else:
            hot_billing_tag = long(
                str(mtsms_record.getComponentByName("hotBillingTag")))

        if mtsms_record.getComponentByName("hotBillingTag2") is None:
            hot_billing_tag2 = -255
        else:
            hot_billing_tag2 = long(
                str(mtsms_record.getComponentByName("hotBillingTag2")))

        if mtsms_record.getComponentByName("locationExtension") is None:
            location_extension = ""
        else:
            location_extension = str(
                mtsms_record.getComponentByName("locationExtension"))

        location = mtsms_record.getComponentByName("location")
        if location is not None:
            location_area = binascii.hexlify(
                str(location.getComponentByName("locationArea")))
            location_area_str = str(location_area)
            location_cellid_binascii = location_area_str[10:14]
            format_location_cellid_binascii = int(location_cellid_binascii, 16)
            location_cellid = format(format_location_cellid_binascii, '05')
            location_area_code_binascii = location_area_str[6:10]
            format_location_area_code_binascii = int(
                location_area_code_binascii, 16)
            location_area_code = format(format_location_area_code_binascii,
                                        '05')
            location_plmn = parseMcc(location_area_str[0:6]) + parseMnc(
                location_area_str[0:6])
            location_sac = location_area_str[-4:]
        else:
            location_cellid = ""
            location_area_code = ""
            location_plmn = ""
            location_sac = ""

        if mtsms_record.getComponentByName("msClassmark") is None:
            ms_classmark = ""
        else:
            ms_classmark = binascii.hexlify(
                str(mtsms_record.getComponentByName("msClassmark")))

        if mtsms_record.getComponentByName("mscSPC14") is None:
            mscspc14 = ""
        else:
            mscspc14 = binascii.hexlify(
                str(mtsms_record.getComponentByName("mscSPC14")))

        if mtsms_record.getComponentByName("mscSPC24") is None:
            mscspc24 = ""
        else:
            mscspc24 = binascii.hexlify(
                str(mtsms_record.getComponentByName("mscSPC24")))

        if mtsms_record.getComponentByName("numOfConcatenated") is None:
            num_of_concatenated = -255
        else:
            num_of_concatenated = long(
                str(mtsms_record.getComponentByName("numOfConcatenated")))

        if mtsms_record.getComponentByName("operatorId") is None:
            operator_id = -255
        else:
            operator_id = long(
                str(mtsms_record.getComponentByName("operatorId")))

        if mtsms_record.getComponentByName("originationNumber") is None:
            origination_number = ""
        else:
            origination_number_binascii = binascii.hexlify(
                str(mtsms_record.getComponentByName("originationNumber")))
            origination_number_list = []
            origination_number_data = list(origination_number_binascii)
            for i in xrange(0, len(origination_number_data) - 1, 2):
                origination_number_list.append(origination_number_data[i + 1] +
                                               "" + origination_number_data[i])
            origination_number_concatenated = ''.join(origination_number_list)
            origination_number = origination_number_concatenated[2:].replace(
                "f", "")

        if mtsms_record.getComponentByName("recordSequenceNumber") is None:
            record_sequence_number = ""
        else:
            record_sequence_number = binascii.hexlify(
                str(mtsms_record.getComponentByName("recordSequenceNumber")))

        if mtsms_record.getComponentByName("recordType") is None:
            record_type = -255
        else:
            record_type = long(
                str(mtsms_record.getComponentByName("recordType")))

        if mtsms_record.getComponentByName("sMSLength") is None:
            sms_length = ""
        else:
            sms_length = binascii.hexlify(
                str(mtsms_record.getComponentByName("sMSLength")))

        if mtsms_record.getComponentByName("recordingEntity") is None:
            recording_entity = ""
        else:
            recording_entity_binascii = binascii.hexlify(
                str(mtsms_record.getComponentByName("recordingEntity")))
            recording_entity_list = []
            recording_entity_data = list(recording_entity_binascii)
            for l in xrange(0, len(recording_entity_data) - 1, 2):
                recording_entity_list.append(recording_entity_data[l + 1] +
                                             "" + recording_entity_data[l])
            recording_entity_concatenated = ''.join(recording_entity_list)
            recording_entity_replace_f = recording_entity_concatenated.replace(
                "f", "")
            recording_entity = recording_entity_replace_f[
                2:7] + recording_entity_replace_f[7:]

        if mtsms_record.getComponentByName("servedIMEI") is None:
            served_imei = ""
        else:
            served_imei_binascii = binascii.hexlify(
                str(mtsms_record.getComponentByName("servedIMEI")))
            served_imei_list = []
            served_imei_data = list(served_imei_binascii)
            for i in xrange(0, len(served_imei_data) - 1, 2):
                served_imei_list.append(served_imei_data[i + 1] + "" +
                                        served_imei_data[i])
            served_imei_concatenated = ''.join(served_imei_list)
            served_imei = served_imei_concatenated.replace("f", "")

        if mtsms_record.getComponentByName("servedIMSI") is None:
            served_imsi = ""
        else:
            served_imsi_binascii = binascii.hexlify(
                str(mtsms_record.getComponentByName("servedIMSI")))
            served_imsi_list = []
            served_imsi_data = list(served_imsi_binascii)
            for j in xrange(0, len(served_imsi_data) - 1, 2):
                served_imsi_list.append(served_imsi_data[j + 1] + "" +
                                        served_imsi_data[j])
            served_imsi_concatenated = ''.join(served_imsi_list)
            served_imsi = served_imsi_concatenated.replace("f", "")

        if mtsms_record.getComponentByName("servedMSISDN") is None:
            served_msisdn = ""
        else:
            served_msisdn_binascii = binascii.hexlify(
                str(mtsms_record.getComponentByName("servedMSISDN")))
            served_msisdn_list = []
            served_msisdn_data = list(served_msisdn_binascii)
            for k in xrange(0, len(served_msisdn_data) - 1, 2):
                served_msisdn_list.append(served_msisdn_data[k + 1] + "" +
                                          served_msisdn_data[k])
            served_msisdn_concatenated = ''.join(served_msisdn_list)
            served_msisdn_replace_f = served_msisdn_concatenated.replace(
                "f", "")
            served_msisdn = served_msisdn_replace_f.replace(
                served_msisdn_replace_f[:3], '')

        if mtsms_record.getComponentByName("serviceCentre") is None:
            service_centre = ""
        else:
            service_centre_binascii = binascii.hexlify(
                str(mtsms_record.getComponentByName("serviceCentre")))
            service_centre_list = []
            service_centre_data = list(service_centre_binascii)
            for l in xrange(0, len(service_centre_data) - 1, 2):
                service_centre_list.append(service_centre_data[l + 1] + "" +
                                           service_centre_data[l])
            service_centre_concatenated = ''.join(service_centre_list)
            service_centre_replace_f = service_centre_concatenated.replace(
                "f", "")
            service_centre = service_centre_replace_f[
                2:7] + service_centre_replace_f[7:]

        if mtsms_record.getComponentByName("smsResult") is None:
            sms_result = ""
        else:
            sms_result = mtsms_record.getComponentByName("smsResult").getName()

        if mtsms_record.getComponentByName("systemType") is None:
            system_type = ""
        else:
            system_type_tmp = long(
                str(mtsms_record.getComponentByName("systemType")))
            system_type = ""
            if system_type_tmp == 0:
                system_type = "unknown"
            elif system_type_tmp == 1:
                system_type = "iuUTRAN"
            elif system_type_tmp == 2:
                system_type = "gERAN"

        if mtsms_record.getComponentByName("tPMessageTypeIndicator") is None:
            tp_messagetype_indicator = ""
        else:
            tp_messagetype_indicator_tmp = long(
                str(mtsms_record.getComponentByName("tPMessageTypeIndicator")))
            tp_messagetype_indicator = ""
            if tp_messagetype_indicator_tmp == 0:
                tp_messagetype_indicator = "sMS-DELIVER-REPORT"
            elif tp_messagetype_indicator_tmp == 1:
                tp_messagetype_indicator = "sMS-SUBMIT"
            elif tp_messagetype_indicator_tmp == 2:
                tp_messagetype_indicator = "sMS-COMMAND"
            elif tp_messagetype_indicator_tmp == 3:
                tp_messagetype_indicator = "reserved"

        if mtsms_record.getComponentByName(
                "transactionIdentification") is None:
            transaction_identification = ""
        else:
            transaction_identification = str(
                mtsms_record.getComponentByName("transactionIdentification"))

        file_name = file_name

        mtsms_record = [
            basic_service, camel_smsc_address, calling_party_number,
            default_sms_handling, destination_subscriber_number,
            free_format_data, gsm_scfaddress, service_key,
            sms_reference_number, call_reference, concatenated_record_num,
            concatenated_ref, delivery_time, direct_sms_flag,
            exchange_identity, file_id, hot_billing_tag, hot_billing_tag2,
            location_cellid, location_extension, location_area_code,
            location_plmn, location_sac, ms_classmark, mscspc14, mscspc24,
            num_of_concatenated, operator_id, origination_number,
            record_sequence_number, record_type, recording_entity, sms_length,
            served_imei, served_imsi, served_msisdn, service_centre,
            sms_result, system_type, tp_messagetype_indicator,
            transaction_identification,
            long(delivery_time.strftime("%Y%m%d")),
            long(delivery_time.strftime("%H"))
        ]

        return mtsms_record
Exemple #5
0
    def process_mtcall_records(mtcall_record, file_id, file_name):

        if mtcall_record.getComponentByName("aReleaseCause") is None:
            a_release_cause = -255
        else:
            a_release_cause = long(
                str(mtcall_record.getComponentByName("aReleaseCause")))

        additional_chg_info = mtcall_record.getComponentByName(
            "additionalChgInfo")

        if additional_chg_info is None:
            charge_indicator = -255
        else:
            charge_indicator = long(
                str(additional_chg_info.getComponentByName("chargeIndicator")))

        if additional_chg_info is None:
            charged_party = ""
        else:
            charged_party_tmp = long(
                str(additional_chg_info.getComponentByName("chargedParty")))
            charged_party = ""
            if charged_party_tmp == 0:
                charged_party = "callingAsChargedParty"
            elif charged_party_tmp == 1:
                charged_party = "calledAsChargedParty"
            elif charged_party_tmp == 2:
                charged_party = "noCharging"
            elif charged_party_tmp == 3:
                charged_party = "anotherNumAsChargedParty"

        if mtcall_record.getComponentByName("aiurRequested") is None:
            aiur_requested = ""
        else:
            aiur_requested_tmp = long(
                str(mtcall_record.getComponentByName("aiurRequested")))
            aiur_requested = ""
            if aiur_requested_tmp == 1:
                aiur_requested = "aiur09600BitsPerSecond"
            elif aiur_requested_tmp == 2:
                aiur_requested = "aiur14400BitsPerSecond"
            elif aiur_requested_tmp == 3:
                aiur_requested = "aiur19200BitsPerSecond"
            elif aiur_requested_tmp == 5:
                aiur_requested = "aiur28800BitsPerSecond"
            elif aiur_requested_tmp == 6:
                aiur_requested = "aiur38400BitsPerSecond"
            elif aiur_requested_tmp == 7:
                aiur_requested = "aiur43200BitsPerSecond"
            elif aiur_requested_tmp == 8:
                aiur_requested = "aiur57600BitsPerSecond"
            elif aiur_requested_tmp == 9:
                aiur_requested = "aiur38400BitsPerSecond1"
            elif aiur_requested_tmp == 10:
                aiur_requested = "aiur38400BitsPerSecond2"
            elif aiur_requested_tmp == 11:
                aiur_requested = "aiur38400BitsPerSecond3"
            elif aiur_requested_tmp == 12:
                aiur_requested = "aiur38400BitsPerSecond4"

        answer_time_tmp = binascii.hexlify(
            str(mtcall_record.getComponentByName("answerTime")))
        answer_time = append_timezone_offset(parseTimestamp(answer_time_tmp))

        if mtcall_record.getComponentByName("aocParameters") is not None:
            aoc_parameter = str(
                mtcall_record.getComponentByName("aocParameters"))
            aoc_parametere1 = str(
                aoc_parameter.getComponentByName("aocParameters"))
            aoc_parametere2 = str(
                aoc_parameter.getComponentByName("aocParameters"))
            aoc_parametere3 = str(
                aoc_parameter.getComponentByName("aocParameters"))
            aoc_parametere4 = str(
                aoc_parameter.getComponentByName("aocParameters"))
            aoc_parametere5 = str(
                aoc_parameter.getComponentByName("aocParameters"))
            aoc_parametere6 = str(
                aoc_parameter.getComponentByName("aocParameters"))
            aoc_parametere7 = str(
                aoc_parameter.getComponentByName("aocParameters"))
        else:
            aoc_parametere1 = ""
            aoc_parametere2 = ""
            aoc_parametere3 = ""
            aoc_parametere4 = ""
            aoc_parametere5 = ""
            aoc_parametere6 = ""
            aoc_parametere7 = ""

        if mtcall_record.getComponentByName("bSCIdentification") is None:
            bsdidentification = ""
        else:
            bsdidentification = binascii.hexlify(
                str(mtcall_record.getComponentByName("bSCIdentification")))

        if mtcall_record.getComponentByName("basicService") is None:
            basic_service = ""
        else:
            basic_service_choice = mtcall_record.getComponentByName(
                "basicService")
            basic_service_choice_hexvalue = basic_service_choice.getComponent(
            ).prettyPrint()
            if basic_service_choice_hexvalue == "0x11":
                basic_service = "teleservice"
            else:
                basic_service = "bearerservice"

        if mtcall_record.getComponentByName("bscIdentification24") is None:
            bsdidentification_24 = ""
        else:
            bsdidentification_24 = binascii.hexlify(
                str(mtcall_record.getComponentByName("bscIdentification24")))

        csfbmt_indicator_get_value = mtcall_record.getComponentByName(
            "cSFBMTIndicator")
        csfbmt_indicator = boolean_value(csfbmt_indicator_get_value)

        cug_category = mtcall_record.getComponentByName("cUGCategory")

        if cug_category is None:
            cug_category_calltype = -255
        else:
            cug_category_calltype = long(
                str(cug_category.getComponentByName("callType")))

        if cug_category is None:
            cug_category_usertype = -255
        else:
            cug_category_usertype = long(
                str(cug_category.getComponentByName("userType")))

        if cug_category is None:
            cug_index = -255
        else:
            cug_index = long(str(cug_category.getComponentByName("cUGIndex")))

        if mtcall_record.getComponentByName("cUGInterLockCode") is None:
            cug_interlock_code = ""
        else:
            cug_interlock_code = str(
                mtcall_record.getComponentByName("cUGInterLockCode"))

        cug_incoming_accessind_get_value = mtcall_record.getComponentByName(
            "cUGIncomingAccessUsed")
        cug_incoming_accessind = boolean_value(
            cug_incoming_accessind_get_value)

        cug_incoming_accessused_get_value = mtcall_record.getComponentByName(
            "cUGIncomingAccessInd")
        cug_incoming_accessused = boolean_value(
            cug_incoming_accessused_get_value)

        if mtcall_record.getComponentByName("callDuration") is None:
            call_duration = -255
        else:
            call_duration = long(
                str(mtcall_record.getComponentByName("callDuration")))

        if mtcall_record.getComponentByName("callReference") is None:
            call_reference = ""
        else:
            call_reference = binascii.hexlify(
                str(mtcall_record.getComponentByName("callReference")))

        if mtcall_record.getComponentByName("calledPartyRoamingInd") is None:
            called_party_roamingind = ""
        else:
            calling_party_roamingind_int = str(
                mtcall_record.getComponentByName("calledPartyRoamingInd"))
            if calling_party_roamingind_int == "1":
                called_party_roamingind = "TRUE"
            else:
                called_party_roamingind = "FALSE"

        if mtcall_record.getComponentByName("callingLocation") is None:
            calling_location = ""
        else:
            calling_location = str(
                mtcall_record.getComponentByName("callingLocation"))

        if mtcall_record.getComponentByName("callingNumber") is None:
            calling_number = ""
        else:
            calling_number_binascii = binascii.hexlify(
                str(mtcall_record.getComponentByName("callingNumber")))
            calling_number_list = []
            calling_number_data = list(calling_number_binascii)
            for i in xrange(0, len(calling_number_data) - 1, 2):
                calling_number_list.append(calling_number_data[i + 1] + "" +
                                           calling_number_data[i])
            calling_number_concatenated = ''.join(calling_number_list)
            calling_number = calling_number_concatenated[2:]

        if mtcall_record.getComponentByName("carp") is None:
            carp = -255
        else:
            carp = long(str(mtcall_record.getComponentByName("carp")))

        if mtcall_record.getComponentByName("causeForTerm") is None:
            cause_for_termination = ""
        else:
            cause_for_termination_tmp = long(
                str(mtcall_record.getComponentByName("causeForTerm")))
            cause_for_termination = ""
            if cause_for_termination_tmp == 0:
                cause_for_termination = "normalRelease"
            elif cause_for_termination_tmp == 1:
                cause_for_termination = "partialRecord"
            elif cause_for_termination_tmp == 2:
                cause_for_termination = "partialRecordCallReestablishment"
            elif cause_for_termination_tmp == 3:
                cause_for_termination = "unsuccessfulCallAttempt"
            elif cause_for_termination_tmp == 4:
                cause_for_termination = "stableCallAbnormalTermination"
            elif cause_for_termination_tmp == 5:
                cause_for_termination = "cAMELInitCallRelease"
            elif cause_for_termination_tmp == 52:
                cause_for_termination = "unauthorizedRequestingNetwork"
            elif cause_for_termination_tmp == 53:
                cause_for_termination = "unauthorizedLCSClient"
            elif cause_for_termination_tmp == 54:
                cause_for_termination = "positionMethodFailure"
            elif cause_for_termination_tmp == 58:
                cause_for_termination = "unknownOrUnreachableLCSClient"
            elif cause_for_termination_tmp == 101:
                cause_for_termination = "cAMELPlayTone"
            elif cause_for_termination_tmp == 102:
                cause_for_termination = "changeOfConfDueToCPH"
            elif cause_for_termination_tmp == 103:
                cause_for_termination = "falseAnswerCharge"
            elif cause_for_termination_tmp == 104:
                cause_for_termination = "failPlayTone"
            elif cause_for_termination_tmp == 105:
                cause_for_termination = "releaseForPreemption"

        if mtcall_record.getComponentByName("chanCodingUsed") is None:
            chan_coding_used = ""
        else:
            chan_coding_used_tmp = long(
                str(mtcall_record.getComponentByName("chanCodingUsed")))
            chan_coding_used = ""
            if chan_coding_used_tmp == 1:
                chan_coding_used = "tchF4800"
            elif chan_coding_used_tmp == 2:
                chan_coding_used = "tchF9600"
            elif chan_coding_used_tmp == 3:
                chan_coding_used = "tchF14400"

        if mtcall_record.getComponentByName("changeOfRadioChan") is not None:
            change_of_radio_chan = mtcall_record.getComponentByName(
                "changeOfRadioChan")
            if change_of_radio_chan.getComponentByName("changeTime") is None:
                change_time = parse_start_time(file_name)
            else:
                change_time_tmp = binascii.hexlify(
                    str(change_of_radio_chan.getComponentByName("changeTime")))
                change_time = append_timezone_offset(
                    parseTimestamp(change_time_tmp))
            if change_of_radio_chan.getComponentByName("radioChannel") is None:
                radio_channel = ""
            else:
                radio_channel_tmp = long(
                    str(change_of_radio_chan.getComponentByName(
                        "radioChannel")))
                radio_channel = ""
                if radio_channel_tmp == 0:
                    radio_channel = "fullRate"
                elif radio_channel_tmp == 1:
                    radio_channel = "halfRate"
            if change_of_radio_chan.getComponentByName(
                    "speechVersionUsed") is None:
                changeofradiochan_speech_version_used = ""
            else:
                changeofradiochan_speech_version_used = str(
                    change_of_radio_chan.getComponentByName(
                        "speechVersionUsed"))
        else:
            radio_channel = ""
            change_time = parse_start_time(file_name)
            changeofradiochan_speech_version_used = ""

        if mtcall_record.getComponentByName("channelType") is None:
            channel_type = ""
        else:
            channel_type = str(mtcall_record.getComponentByName("channelType"))

        if mtcall_record.getComponentByName("connectedNumber") is None:
            connected_number = ""
        else:
            connected_number_binascii = binascii.hexlify(
                str(mtcall_record.getComponentByName("connectedNumber")))
            connected_number_list = []
            connected_number_data = list(connected_number_binascii)
            for i in xrange(0, len(connected_number_data) - 1, 2):
                connected_number_list.append(connected_number_data[i + 1] +
                                             "" + connected_number_data[i])
            connected_number_concatenated = ''.join(connected_number_list)
            connected_number = connected_number_concatenated[2:]

        if mtcall_record.getComponentByName("dataRate") is None:
            data_rate = -255
        else:
            data_rate = long(str(mtcall_record.getComponentByName("dataRate")))

        if mtcall_record.getComponentByName("dataVolume") is None:
            data_volume = -255
        else:
            data_volume = long(
                str(mtcall_record.getComponentByName("dataVolume")))

        if mtcall_record.getComponentByName("dDCFlag") is None:
            ddcflag = -255
        else:
            ddcflag = long(str(mtcall_record.getComponentByName("dDCFlag")))

        if mtcall_record.getComponentByName("defaultCallHandling") is None:
            default_call_handling = ""
        else:
            default_call_handling_tmp = long(
                str(mtcall_record.getComponentByName("defaultCallHandling")))
            default_call_handling = ""
            if default_call_handling_tmp == 0:
                default_call_handling = "continueCall"
            elif default_call_handling_tmp == 1:
                default_call_handling = "releaseCall"

        if mtcall_record.getComponentByName("diagnostics") is None:
            diagnostics = ""
        else:
            diagnostics = mtcall_record.getComponentByName(
                "diagnostics").getName()

        if mtcall_record.getComponentByName("eMLPPPriorityLevel") is None:
            emlpp_priority_level = -255
        else:
            emlpp_priority_level = long(
                str(mtcall_record.getComponentByName("eMLPPPriorityLevel")))

        if mtcall_record.getComponentByName(
                "eMLPPRequestPriorityLevel") is None:
            emlpp_request_priority_level = -255
        else:
            emlpp_request_priority_level = long(
                str(
                    mtcall_record.getComponentByName(
                        "eMLPPRequestPriorityLevel")))

        if mtcall_record.getComponentByName("exchangeIdentity") is None:
            exchange_identity = ""
        else:
            exchange_identity = str(
                mtcall_record.getComponentByName("exchangeIdentity"))

        if mtcall_record.getComponentByName("fnur") is None:
            fnur = ""
        else:
            fnur_tmp = long(str(mtcall_record.getComponentByName("fnur")))
            if fnur_tmp == 0:
                fnur = "fnur9600-BitsPerSecond"
            elif fnur_tmp == 1:
                fnur = "fnur14400BitsPerSecond"
            elif fnur_tmp == 2:
                fnur = "fnur19200BitsPerSecond"
            elif fnur_tmp == 3:
                fnur = "fnur14400BitsPerSecond"
            elif fnur_tmp == 4:
                fnur = "fnur28800BitsPerSecond"
            elif fnur_tmp == 5:
                fnur = "fnur38400BitsPerSecond"
            elif fnur_tmp == 6:
                fnur = "fnur48000BitsPerSecond"
            elif fnur_tmp == 7:
                fnur = "fnur56000BitsPerSecond"
            elif fnur_tmp == 8:
                fnur = "fnur64000BitsPerSecond"
            elif fnur_tmp == 9:
                fnur = "fnur33600BitsPerSecond"
            elif fnur_tmp == 10:
                fnur = "fnur32000BitsPerSecond"

        if mtcall_record.getComponentByName("freeFormatData") is None:
            free_format_data = ""
        else:
            free_format_data = str(
                mtcall_record.getComponentByName("freeFormatData"))

        if mtcall_record.getComponentByName("globalCallReference") is None:
            global_call_reference = ""
        else:
            global_call_reference = str(
                mtcall_record.getComponentByName("globalCallReference"))

        if mtcall_record.getComponentByName("gsm-SCFAddress") is not None:
            gsm_scfaddress_binascii = binascii.hexlify(
                str(mtcall_record.getComponentByName("gsm-SCFAddress")))
            gsm_scfaddress_list = []
            gsm_scfaddress_data = list(gsm_scfaddress_binascii)
            for i in xrange(0, len(gsm_scfaddress_data) - 1, 2):
                gsm_scfaddress_list.append(gsm_scfaddress_data[i + 1] + "" +
                                           gsm_scfaddress_data[i])
                gsm_scfaddress_concatenated = ''.join(gsm_scfaddress_list)
                gsm_scfaddress = gsm_scfaddress_concatenated[2:].replace(
                    "f", "")
        else:
            gsm_scfaddress = ""

        if mtcall_record.getComponentByName("guaranteedBitRate") is None:
            guaranteed_bit_rate = ""
        else:
            guaranteed_bit_rate_tmp = long(
                str(mtcall_record.getComponentByName("guaranteedBitRate")))
            guaranteed_bit_rate = ""
            if guaranteed_bit_rate_tmp == 1:
                guaranteed_bit_rate = "gBR14400BitsPerSecond"
            elif guaranteed_bit_rate_tmp == 2:
                guaranteed_bit_rate = "gBR28800BitsPerSecond"
            elif guaranteed_bit_rate_tmp == 3:
                guaranteed_bit_rate = "gBR32000BitsPerSecond"
            elif guaranteed_bit_rate_tmp == 4:
                guaranteed_bit_rate = "gBR33600BitsPerSecond"
            elif guaranteed_bit_rate_tmp == 5:
                guaranteed_bit_rate = "gBR56000BitsPerSecond"
            elif guaranteed_bit_rate_tmp == 6:
                guaranteed_bit_rate = "gBR57600BitsPerSecond"
            elif guaranteed_bit_rate_tmp == 7:
                guaranteed_bit_rate = "gBR64000BitsPerSecond"
            elif guaranteed_bit_rate_tmp == 8:
                guaranteed_bit_rate = "gBR31200BitsPerSecond"
            elif guaranteed_bit_rate_tmp == 9:
                guaranteed_bit_rate = "gBR38400BitsPerSecond"

        if mtcall_record.getComponentByName("hSCSDChanAllocated") is None:
            hscsd_chan_allocated = -255
        else:
            hscsd_chan_allocated = long(
                str(mtcall_record.getComponentByName("hSCSDChanAllocated")))

        if mtcall_record.getComponentByName("hSCSDChanRequested") is None:
            hscsd_chan_requested = -255
        else:
            hscsd_chan_requested = long(
                str(mtcall_record.getComponentByName("hSCSDChanRequested")))

        if mtcall_record.getComponentByName("hotBillingTag") is None:
            hot_billing_tag = -255
        else:
            hot_billing_tag = long(
                str(mtcall_record.getComponentByName("hotBillingTag")))

        if mtcall_record.getComponentByName("hotBillingTag2") is None:
            hot_billing_tag2 = -255
        else:
            hot_billing_tag2 = long(
                str(mtcall_record.getComponentByName("hotBillingTag2")))

        ics_flag_get_value = mtcall_record.getComponentByName("iCSFlag")
        ics_flag = boolean_value(ics_flag_get_value)

        incoming_cic = mtcall_record.getComponentByName("incomingCic")

        if incoming_cic is None:
            incoming_cic_channel = -255
        else:
            incoming_cic_channel = long(
                str(incoming_cic.getComponentByName("channel")))

        if incoming_cic is None:
            incoming_cic_pcmunit = -255
        else:
            incoming_cic_pcmunit = long(
                str(incoming_cic.getComponentByName("pcmUnit")))

        if mtcall_record.getComponentByName("incomingTKGPName") is None:
            incoming_tkgpname = ""
        else:
            incoming_tkgpname = str(
                mtcall_record.getComponentByName("incomingTKGPName"))

        if mtcall_record.getComponentByName("incomingTrafficType") is None:
            incoming_traffic_type = ""
        else:
            incoming_traffic_type_tmp = long(
                str(mtcall_record.getComponentByName("incomingTrafficType")))
            incoming_traffic_type = ""
            if incoming_traffic_type_tmp == 0:
                incoming_traffic_type = "unknown"
            elif incoming_traffic_type_tmp == 1:
                incoming_traffic_type = "localNetworkMobile"
            elif incoming_traffic_type_tmp == 2:
                incoming_traffic_type = "localNetworkFixed"
            elif incoming_traffic_type_tmp == 3:
                incoming_traffic_type = "externalNetwork"

        is_camel_call_get_value = mtcall_record.getComponentByName(
            "isCAMELCall")
        is_camel_call = boolean_value(is_camel_call_get_value)

        is_cug_used_get_value = mtcall_record.getComponentByName("isCUGUsed")
        is_cug_used = boolean_value(is_cug_used_get_value)

        is_hscsd_used_get_value = mtcall_record.getComponentByName(
            "isHSCSDUsed")
        is_hscsd_used = boolean_value(is_hscsd_used_get_value)

        is_multi_media_call_get_value = mtcall_record.getComponentByName(
            "isMultiMediaCall")
        is_multi_media_call = boolean_value(is_multi_media_call_get_value)

        if mtcall_record.getComponentByName("iuReleaseCause") is None:
            iu_release_cause = -255
        else:
            iu_release_cause = long(
                str(mtcall_record.getComponentByName("iuReleaseCause")))

        last_long_part_ind_get_value = mtcall_record.getComponentByName(
            "lastLongPartInd")
        last_long_part_ind = boolean_value(last_long_part_ind_get_value)

        if mtcall_record.getComponentByName("location") is not None:
            location = mtcall_record.getComponentByName("location")
            location_area = binascii.hexlify(
                str(location.getComponentByName("locationArea")))
            location_area_str = str(location_area)

            location_cellid_binascii = location_area_str[10:14]
            format_location_cellid_binascii = int(location_cellid_binascii, 16)
            location_cellid = format(format_location_cellid_binascii, '05')

            location_area_code_binascii = location_area_str[6:10]
            format_location_area_code_binascii = int(
                location_area_code_binascii, 16)
            location_area_code = format(format_location_area_code_binascii,
                                        '05')

            location_plmn = parseMcc(location_area_str[0:6]) + parseMnc(
                location_area_str[0:6])

            location_sac = location_area_str[-4:]
        else:
            location_cellid = ""
            location_area_code = ""
            location_plmn = ""
            location_sac = ""

        if mtcall_record.getComponentByName("mSCAddress") is None:
            msc_address = ""
        else:
            msc_address_binascii = binascii.hexlify(
                str(mtcall_record.getComponentByName("mSCAddress")))
            msc_address_list = []
            msc_address_data = list(msc_address_binascii)
            for i in xrange(0, len(msc_address_data) - 1, 2):
                msc_address_list.append(msc_address_data[i + 1] + "" +
                                        msc_address_data[i])
                msc_address_concatenated = ''.join(msc_address_list)
                msc_address = msc_address_concatenated[2:].replace("f", "")

        if mtcall_record.getComponentByName("maximumBitRate") is None:
            maximumbitrate = ""
        else:
            maximumbitrate_tmp = long(
                str(mtcall_record.getComponentByName("maximumBitRate")))
            maximumbitrate = ""
            if maximumbitrate_tmp == 1:
                maximumbitrate = "mBR14400BitsPerSecond"
            elif maximumbitrate_tmp == 2:
                maximumbitrate = "mBR28800BitsPerSecond"
            elif maximumbitrate_tmp == 3:
                maximumbitrate = "mBR32000BitsPerSecond"
            elif maximumbitrate_tmp == 4:
                maximumbitrate = "mBR33600BitsPerSecond"
            elif maximumbitrate_tmp == 5:
                maximumbitrate = "mBR56000BitsPerSecond"
            elif maximumbitrate_tmp == 6:
                maximumbitrate = "mBR57600BitsPerSecond"
            elif maximumbitrate_tmp == 7:
                maximumbitrate = "mBR64000BitsPerSecond"
            elif maximumbitrate_tmp == 8:
                maximumbitrate = "mBR67200BitsPerSecond"

        if mtcall_record.getComponentByName("millisecDuration") is None:
            milli_sec_duration = -255
        else:
            milli_sec_duration = long(
                str(mtcall_record.getComponentByName("millisecDuration")))

        if mtcall_record.getComponentByName("msClassmark") is None:
            ms_classmark = ""
        else:
            ms_classmark = binascii.hexlify(
                str(mtcall_record.getComponentByName("msClassmark")))

        if mtcall_record.getComponentByName("mscIncomingTKGP") is None:
            msc_incoming_tkgp = ""
        else:
            msc_incoming_tkgp = binascii.hexlify(
                str(mtcall_record.getComponentByName("mscIncomingTKGP")))

        if mtcall_record.getComponentByName("mscOutgoingTKGP") is None:
            msc_outgoing_tkgp = ""
        else:
            msc_outgoing_tkgp = binascii.hexlify(
                str(mtcall_record.getComponentByName("mscOutgoingTKGP")))

        if mtcall_record.getComponentByName("mscSPC14") is None:
            mscspc14 = ""
        else:
            mscspc14 = binascii.hexlify(
                str(mtcall_record.getComponentByName("mscSPC14")))

        if mtcall_record.getComponentByName("mscSPC24") is None:
            mscspc24 = ""
        else:
            mscspc24 = binascii.hexlify(
                str(mtcall_record.getComponentByName("mscSPC24")))

        if mtcall_record.getComponentByName("networkCallReference") is None:
            network_call_reference = ""
        else:
            network_call_reference = binascii.hexlify(
                str(mtcall_record.getComponentByName("networkCallReference")))

        if mtcall_record.getComponentByName("operatorId") is None:
            operator_id = -255
        else:
            operator_id = long(
                str(mtcall_record.getComponentByName("operatorId")))

        if mtcall_record.getComponentByName("operatorId") is None:
            original_called_number = ""
        else:
            original_called_number = str(
                mtcall_record.getComponentByName("originalCalledNumber"))

        outgoing_cic = mtcall_record.getComponentByName("outgoingCic")

        if outgoing_cic is None:
            outgoing_cic_channel = -255
        else:
            outgoing_cic_channel = long(
                str(outgoing_cic.getComponentByName("channel")))

        if outgoing_cic is None:
            outgoing_cic_pcmunit = -255
        else:
            outgoing_cic_pcmunit = long(
                str(outgoing_cic.getComponentByName("pcmUnit")))

        if mtcall_record.getComponentByName("outgoingTKGPName") is None:
            outgoing_tkgpname = ""
        else:
            outgoing_tkgpname = str(
                mtcall_record.getComponentByName("outgoingTKGPName"))

        if mtcall_record.getComponentByName("outgoingTrafficType") is None:
            outgoing_traffic_type = ""
        else:
            outgoing_traffic_type_tmp = long(
                str(mtcall_record.getComponentByName("outgoingTrafficType")))
            outgoing_traffic_type = ""
            if outgoing_traffic_type_tmp == 0:
                outgoing_traffic_type = "unknown"
            elif outgoing_traffic_type_tmp == 1:
                outgoing_traffic_type = "localNetworkMobile"
            elif outgoing_traffic_type_tmp == 2:
                outgoing_traffic_type = "localNetworkFixed"
            elif outgoing_traffic_type_tmp == 3:
                outgoing_traffic_type = "externalNetwork"

        if mtcall_record.getComponentByName("partialRecordType") is None:
            partial_record_type = ""
        else:
            partial_record_type_tmp = long(
                str(mtcall_record.getComponentByName("partialRecordType")))
            partial_record_type = ""
            if partial_record_type_tmp == 1:
                partial_record_type = "serviceChange"

        if mtcall_record.getComponentByName("pbrt") is None:
            pbrt = -255
        else:
            pbrt = long(str(mtcall_record.getComponentByName("pbrt")))

        if mtcall_record.getComponentByName("radioChanRequested") is None:
            radio_chan_requested = ""
        else:

            radio_chan_requested_tmp = long(
                str(mtcall_record.getComponentByName("radioChanRequested")))
            radio_chan_requested = ""
            if radio_chan_requested_tmp == 0:
                radio_chan_requested = "halfRateChannel"
            elif radio_chan_requested_tmp == 1:
                radio_chan_requested = "fullRateChannel"
            elif radio_chan_requested_tmp == 2:
                radio_chan_requested = "dualHalfRatePreferred"
            elif radio_chan_requested_tmp == 3:
                radio_chan_requested = "dualFullRatePreferred"

        if mtcall_record.getComponentByName("radioChanUsed") is None:
            radio_chan_used = ""
        else:
            radio_chan_used_tmp = long(
                str(mtcall_record.getComponentByName("radioChanUsed")))
            radio_chan_used = ""
            if radio_chan_used_tmp == 0:
                radio_chan_used = "fullRate"
            elif radio_chan_used_tmp == 1:
                radio_chan_used = "halfRate"

        if mtcall_record.getComponentByName("rateIndication") is None:
            rate_indication = ""
        else:
            rate_indication = str(
                mtcall_record.getComponentByName("rateIndication"))

        if mtcall_record.getComponentByName("reasonForServiceChange") is None:
            reason_for_service_change = ""
        else:
            reason_for_service_change_tmp = long(
                str(mtcall_record.getComponentByName(
                    "reasonForServiceChange")))
            reason_for_service_change = ""
            if reason_for_service_change_tmp == 0:
                reason_for_service_change = "msubInitiate"
            elif reason_for_service_change_tmp == 1:
                reason_for_service_change = "mscInitiated"
            elif reason_for_service_change_tmp == 2:
                reason_for_service_change = "callSetupFallBack"
            elif reason_for_service_change_tmp == 3:
                reason_for_service_change = "callSetupChangeOrder"

        if mtcall_record.getComponentByName("recordSequenceNumber") is None:
            record_sequence_number = ""
        else:
            record_sequence_number = binascii.hexlify(
                str(mtcall_record.getComponentByName("recordSequenceNumber")))

        if mtcall_record.getComponentByName("recordType") is None:
            record_type = -255
        else:
            record_type = long(
                str(mtcall_record.getComponentByName("recordType")))

        if mtcall_record.getComponentByName("recordingEntity") is None:
            recording_entity = ""
        else:
            recording_entity_binascii = binascii.hexlify(
                str(mtcall_record.getComponentByName("recordingEntity")))
            recording_entity_list = []
            recording_entity_data = list(recording_entity_binascii)
            for l in xrange(0, len(recording_entity_data) - 1, 2):
                recording_entity_list.append(recording_entity_data[l + 1] +
                                             "" + recording_entity_data[l])
            recording_entity_concatenated = ''.join(recording_entity_list)
            recording_entity_replace_f = recording_entity_concatenated.replace(
                "f", "")
            recording_entity = recording_entity_replace_f[
                2:7] + recording_entity_replace_f[7:]

        if mtcall_record.getComponentByName("redirectNumber") is None:
            redirect_number = ""
        else:
            redirecting_number_binascii = binascii.hexlify(
                str(mtcall_record.getComponentByName("redirectNumber")))
            redirecting_number_list = []
            redirecting_number_data = list(redirecting_number_binascii)
            for i in xrange(0, len(redirecting_number_data) - 1, 2):
                redirecting_number_list.append(redirecting_number_data[i + 1] +
                                               "" + redirecting_number_data[i])
            redirecting_number_concatenated = ''.join(redirecting_number_list)
            redirect_number = redirecting_number_concatenated[2:].replace(
                "f", "")

        if mtcall_record.getComponentByName("redirectingNumber") is None:
            redirecting_number = ""
        else:
            redirecting_number = str(
                mtcall_record.getComponentByName("redirectingNumber"))

        release_time_tmp = binascii.hexlify(
            str(mtcall_record.getComponentByName("releaseTime")))
        release_time = append_timezone_offset(parseTimestamp(release_time_tmp))

        if mtcall_record.getComponentByName("routingCategory") is None:
            routing_category = ""
        else:
            routing_category = str(
                mtcall_record.getComponentByName("routingCategory"))

        seizure_time_tmp = binascii.hexlify(
            str(mtcall_record.getComponentByName("seizureTime")))
        seizure_time = append_timezone_offset(parseTimestamp(seizure_time_tmp))

        if mtcall_record.getComponentByName("sequenceNumber") is None:
            sequence_number = -255
        else:
            sequence_number = long(
                str(mtcall_record.getComponentByName("sequenceNumber")))

        if mtcall_record.getComponentByName("servedIMEI") is None:
            served_imei = ""
        else:
            served_imei_binascii = binascii.hexlify(
                str(mtcall_record.getComponentByName("servedIMEI")))
            served_imei_list = []
            served_imei_data = list(served_imei_binascii)
            for i in xrange(0, len(served_imei_data) - 1, 2):
                served_imei_list.append(served_imei_data[i + 1] + "" +
                                        served_imei_data[i])
            served_imei_concatenated = ''.join(served_imei_list)
            served_imei = served_imei_concatenated.replace("f", "")

        if mtcall_record.getComponentByName("servedIMSI") is None:
            served_imsi = ""
        else:
            served_imsi_binascii = binascii.hexlify(
                str(mtcall_record.getComponentByName("servedIMSI")))
            served_imsi_list = []
            served_imsi_data = list(served_imsi_binascii)
            for j in xrange(0, len(served_imsi_data) - 1, 2):
                served_imsi_list.append(served_imsi_data[j + 1] + "" +
                                        served_imsi_data[j])
            served_imsi_concatenated = ''.join(served_imsi_list)
            served_imsi = served_imsi_concatenated.replace("f", "")

        if mtcall_record.getComponentByName("servedMSISDN") is None:
            served_msisdn = ""
        else:
            served_msisdn_binascii = binascii.hexlify(
                str(mtcall_record.getComponentByName("servedMSISDN")))
            served_msisdn_list = []
            served_msisdn_data = list(served_msisdn_binascii)
            for k in xrange(0, len(served_msisdn_data) - 1, 2):
                served_msisdn_list.append(served_msisdn_data[k + 1] + "" +
                                          served_msisdn_data[k])
            served_msisdn_concatenated = ''.join(served_msisdn_list)
            served_msisdn_replace_f = served_msisdn_concatenated.replace(
                "f", "")
            served_msisdn = served_msisdn_replace_f.replace(
                served_msisdn_replace_f[:3], '')

        if mtcall_record.getComponentByName("serviceCategory") is None:
            service_category = ""
        else:
            service_category = binascii.hexlify(
                str(mtcall_record.getComponentByName("serviceCategory")))

        if mtcall_record.getComponentByName("serviceChangeInitiator") is None:
            service_change_initiator = -255
        else:
            service_change_initiator = long(
                str(mtcall_record.getComponentByName(
                    "serviceChangeInitiator")))

        if mtcall_record.getComponentByName("serviceKey") is None:
            service_key = ""
        else:
            service_key = long(
                str(mtcall_record.getComponentByName("serviceKey")))

        if mtcall_record.getComponentByName("speechVersionSupported") is None:
            speech_version_supported = ""
        else:
            speech_version_supported = binascii.hexlify(
                str(mtcall_record.getComponentByName(
                    "speechVersionSupported")))

        if mtcall_record.getComponentByName("speechVersionUsed") is None:
            speech_version_used = ""
        else:
            speech_version_used = binascii.hexlify(
                str(mtcall_record.getComponentByName("speechVersionUsed")))

        if mtcall_record.getComponentByName("startTime") is None:
            start_time = parse_start_time(file_name)
        else:
            start_time_tmp = binascii.hexlify(
                str(mtcall_record.getComponentByName("startTime")))
            start_time = append_timezone_offset(parseTimestamp(start_time_tmp))

        if mtcall_record.getComponentByName("subscriberCategory") is None:
            subscriber_category = ""
        else:
            subscriber_category = binascii.hexlify(
                str(mtcall_record.getComponentByName("subscriberCategory")))

        if mtcall_record.getComponentByName("systemType") is None:
            system_type = ""
        else:
            system_type_tmp = long(
                str(mtcall_record.getComponentByName("systemType")))
            system_type = ""
            if system_type_tmp == 0:
                system_type = "unknown"
            elif system_type_tmp == 1:
                system_type = "iuUTRAN"
            elif system_type_tmp == 2:
                system_type = "gERAN"

        if mtcall_record.getComponentByName("terminatingRecordType") is None:
            terminating_record_type = ""
        else:
            terminating_record_type_tmp = long(
                str(mtcall_record.getComponentByName("terminatingRecordType")))
            terminating_record_type = ""
            if terminating_record_type_tmp == 0:
                terminating_record_type = "ordinaryTerminating"
            elif terminating_record_type_tmp == 1:
                terminating_record_type = "forwardOnUnconditionalTerminating"
            elif terminating_record_type_tmp == 2:
                terminating_record_type = "forwardOnBusyTerminating"
            elif terminating_record_type_tmp == 3:
                terminating_record_type = "forwardOnNotReplyTerminating"
            elif terminating_record_type_tmp == 4:
                terminating_record_type = "forwardOnMsNotReachableTerminating"
            elif terminating_record_type_tmp == 255:
                terminating_record_type = "forwardOnOtherReasonTerminating"

        if mtcall_record.getComponentByName(
                "transactionIdentification") is None:
            transaction_identification = -255
        else:
            transaction_identification = long(
                str(
                    mtcall_record.getComponentByName(
                        "transactionIdentification")))

        if mtcall_record.getComponentByName("transparencyIndicator") is None:
            transparency_indicator = ""
        else:
            transparency_indicator_tmp = long(
                str(mtcall_record.getComponentByName("transparencyIndicator")))
            transparency_indicator = ""
            if transparency_indicator_tmp == 0:
                transparency_indicator = "transparent"
            elif transparency_indicator_tmp == 1:
                transparency_indicator = "nonTransparent"

        if mtcall_record.getComponentByName("typeOfServiceChange") is None:
            types_of_service_change = ""
        else:
            types_of_service_change_tmp = long(
                str(mtcall_record.getComponentByName("typeOfServiceChange")))
            types_of_service_change = ""
            if types_of_service_change_tmp == 0:
                types_of_service_change = "changeToSpeech"
            elif types_of_service_change_tmp == 1:
                types_of_service_change = "changeToMultimedia"

        mtcall_record = [
            a_release_cause, charge_indicator, charged_party, aiur_requested,
            answer_time, aoc_parametere1, aoc_parametere2, aoc_parametere3,
            aoc_parametere4, aoc_parametere5, aoc_parametere6, aoc_parametere7,
            bsdidentification, basic_service, bsdidentification_24,
            csfbmt_indicator, cug_category_calltype, cug_category_usertype,
            cug_incoming_accessind, cug_incoming_accessused, cug_index,
            cug_interlock_code, call_duration, call_reference,
            called_party_roamingind, calling_location, calling_number, carp,
            cause_for_termination, chan_coding_used, change_time,
            radio_channel, changeofradiochan_speech_version_used, channel_type,
            connected_number, ddcflag, data_rate, data_volume,
            default_call_handling, diagnostics, emlpp_priority_level,
            emlpp_request_priority_level, exchange_identity, file_id, fnur,
            free_format_data, global_call_reference, gsm_scfaddress,
            guaranteed_bit_rate, hscsd_chan_allocated, hscsd_chan_requested,
            hot_billing_tag, hot_billing_tag2, ics_flag, incoming_cic_channel,
            incoming_cic_pcmunit, incoming_tkgpname, incoming_traffic_type,
            is_camel_call, is_cug_used, is_hscsd_used, is_multi_media_call,
            iu_release_cause, last_long_part_ind, location_cellid,
            location_area_code, location_plmn, location_sac, msc_address,
            maximumbitrate, milli_sec_duration, ms_classmark,
            msc_incoming_tkgp, msc_outgoing_tkgp, mscspc14, mscspc24,
            network_call_reference, operator_id, original_called_number,
            outgoing_cic_channel, outgoing_cic_pcmunit, outgoing_tkgpname,
            outgoing_traffic_type, partial_record_type, pbrt,
            radio_chan_requested, radio_chan_used, rate_indication,
            reason_for_service_change, record_sequence_number, record_type,
            recording_entity, redirect_number, redirecting_number,
            release_time, routing_category, seizure_time, sequence_number,
            served_imei, served_imsi, served_msisdn, service_category,
            service_change_initiator, service_key, speech_version_supported,
            speech_version_used, start_time, subscriber_category, system_type,
            terminating_record_type, transaction_identification,
            transparency_indicator, types_of_service_change,
            long(seizure_time.strftime("%Y%m%d")),
            long(seizure_time.strftime("%H"))
        ]

        return mtcall_record
    def process_mtlcs_records(mtlcs_record, file_id, file_name):

        additional_chg_info = mtlcs_record.getComponentByName("additionalChgInfo")

        if additional_chg_info is None:
            charge_indicator = -255
        else:
            charge_indicator = long(str(additional_chg_info.getComponentByName("chargeIndicator")))

        if additional_chg_info is None:
            charged_party = ""
        else:
            charged_party_tmp = long(str(additional_chg_info.getComponentByName("chargedParty")))
            charged_party = ""
            if charged_party_tmp == 0:
                charged_party = "callingAsChargedParty"
            elif charged_party_tmp == 1:
                charged_party = "calledAsChargedParty"
            elif charged_party_tmp == 2:
                charged_party = "noCharging"
            elif charged_party_tmp == 3:
                charged_party = "anotherNumAsChargedParty"

        if mtlcs_record.getComponentByName("causeForTerm") is None:
            cause_for_termination = ""
        else:
            cause_for_termination_tmp = long(str(mtlcs_record.getComponentByName("causeForTerm")))
            cause_for_termination = ""
            if cause_for_termination_tmp == 0:
                cause_for_termination = "normalRelease"
            elif cause_for_termination_tmp == 1:
                cause_for_termination = "partialRecord"
            elif cause_for_termination_tmp == 2:
                cause_for_termination = "partialRecordCallReestablishment"
            elif cause_for_termination_tmp == 3:
                cause_for_termination = "unsuccessfulCallAttempt"
            elif cause_for_termination_tmp == 4:
                cause_for_termination = "stableCallAbnormalTermination"
            elif cause_for_termination_tmp == 5:
                cause_for_termination = "cAMELInitCallRelease"
            elif cause_for_termination_tmp == 52:
                cause_for_termination = "unauthorizedRequestingNetwork"
            elif cause_for_termination_tmp == 53:
                cause_for_termination = "unauthorizedLCSClient"
            elif cause_for_termination_tmp == 54:
                cause_for_termination = "positionMethodFailure"
            elif cause_for_termination_tmp == 58:
                cause_for_termination = "unknownOrUnreachableLCSClient"
            elif cause_for_termination_tmp == 101:
                cause_for_termination = "cAMELPlayTone"
            elif cause_for_termination_tmp == 102:
                cause_for_termination = "changeOfConfDueToCPH"
            elif cause_for_termination_tmp == 103:
                cause_for_termination = "falseAnswerCharge"
            elif cause_for_termination_tmp == 104:
                cause_for_termination = "failPlayTone"
            elif cause_for_termination_tmp == 105:
                cause_for_termination = "releaseForPreemption"

        if mtlcs_record.getComponentByName("diagnostics") is None:
            diagnostics = ""
        else:
            diagnostics = mtlcs_record.getComponentByName("diagnostics").getName()

        event_timestamp_tmp = binascii.hexlify(str(mtlcs_record.getComponentByName("eventTimeStamp")))
        event_timestamp = append_timezone_offset(parseTimestamp(event_timestamp_tmp))

        if mtlcs_record.getComponentByName("hotBillingTag") is None:
            hot_billing_tag = -255
        else:
            hot_billing_tag = long(str(mtlcs_record.getComponentByName("hotBillingTag")))

        if mtlcs_record.getComponentByName("hotBillingTag2") is None:
            hot_billing_tag2 = -255
        else:
            hot_billing_tag2 = long(str(mtlcs_record.getComponentByName("hotBillingTag2")))

        if mtlcs_record.getComponentByName("lcsCause") is None:
            lcs_cause = ""
        else:
            lcs_cause = str(mtlcs_record.getComponentByName("lcsCause"))

        lcs_client_identity = mtlcs_record.getComponentByName("lcsClientIdentity")

        if lcs_client_identity is None:
            lcs_client_external_address = ""
        else:
            lcs_client_external_id = lcs_client_identity.getComponentByName("lcsClientExternalID")
            lcs_client_external_address_binascii = binascii.hexlify(
                    str(lcs_client_external_id.getComponentByName("externalAddress")))
            lcs_client_external_address_list = []
            lcs_client_external_address_data = list(lcs_client_external_address_binascii)
            for k in xrange(0, len(lcs_client_external_address_data) - 1, 2):
                lcs_client_external_address_list.append(
                        lcs_client_external_address_data[k + 1] + "" + lcs_client_external_address_data[k])
            lcs_client_external_address_concatenated = ''.join(lcs_client_external_address_list)
            lcs_client_external_address = lcs_client_external_address_concatenated[2:].replace("f", "")

        if lcs_client_identity is None:
            lcs_client_dialedbyms = ""
        else:
            if lcs_client_identity.getComponentByName("lcsClientDialedByMS") is None:
                lcs_client_dialedbyms = ""
            else:
                lcs_client_dialedbyms = str(lcs_client_identity.getComponentByName("lcsClientDialedByMS"))

        if lcs_client_identity is None:
            lcs_client_internalid = ""
        else:
            if lcs_client_identity.getComponentByName("lcsClientInternalID") is None:
                lcs_client_internalid = ""
            else:
                lcs_client_internalid = str(lcs_client_identity.getComponentByName("lcsClientInternalID"))

        if mtlcs_record.getComponentByName("lcsClientType") is None:
            lcs_clienttype = ""
        else:
            lcs_clienttype_tmp = long(str(mtlcs_record.getComponentByName("lcsClientType")))
            lcs_clienttype = ""
            if lcs_clienttype_tmp == 0:
                lcs_clienttype = "emergencyServices"
            elif lcs_clienttype_tmp == 1:
                lcs_clienttype = "valueAddedServices"
            elif lcs_clienttype_tmp == 2:
                lcs_clienttype = "plmnOperatorServices"
            elif lcs_clienttype_tmp == 3:
                lcs_clienttype = "lawfulInterceptServices"

        if mtlcs_record.getComponentByName("lcsPriority") is None:
            lcs_priority = ""
        else:
            lcs_priority_tmp = binascii.hexlify(str(mtlcs_record.getComponentByName("lcsPriority")))
            lcs_priority = lcs_priority_tmp[:2]

        if mtlcs_record.getComponentByName("lcsQos") is None:
            lcs_qos = ""
        else:
            lcs_qos = binascii.hexlify(str(mtlcs_record.getComponentByName("lcsQos")))

        if mtlcs_record.getComponentByName("locationEstimate") is None:
            location_estimate = ""
        else:
            location_estimate = str(mtlcs_record.getComponentByName("locationEstimate"))

        location = mtlcs_record.getComponentByName("location")
        if location is not None:
            location_area = binascii.hexlify(str(location.getComponentByName("locationArea")))
            location_area_str = str(location_area)
            location_cellid_binascii = location_area_str[10:14]
            format_location_cellid_binascii = int(location_cellid_binascii, 16)
            location_cellid = format(format_location_cellid_binascii, '05')
            location_area_code_binascii = location_area_str[6:10]
            format_location_area_code_binascii = int(location_area_code_binascii, 16)
            location_area_code = format(format_location_area_code_binascii, '05')
            location_plmn = parseMcc(location_area_str[0:6]) + parseMnc(location_area_str[0:6])
            location_sac = location_area_str[-4:]
        else:
            location_cellid = ""
            location_area_code = ""
            location_plmn = ""
            location_sac = ""

        location_type = mtlcs_record.getComponentByName("locationType")

        if location_type is None:
            deferred_location_eventtype = ""
        else:
            if location_type.getComponentByName("deferredLocationEventType") is None:
                deferred_location_eventtype = ""
            else:
                deferred_location_eventtype = str(location_type.getComponentByName("deferredLocationEventType"))

        if location_type is None:
            location_estimate_type = ""
        else:
            location_estimate_type_tmp = long(str(location_type.getComponentByName("locationEstimateType")))
            location_estimate_type = ""
            if location_estimate_type_tmp == 0:
                location_estimate_type = "currentLocation"
            elif location_estimate_type == 1:
                location_estimate_type = "currentOrLastKnownLocation"
            elif location_estimate_type == 2:
                location_estimate_type = "initialLocation"
            elif location_estimate_type_tmp == 3:
                location_estimate_type = "activateDeferredLocation"
            elif location_estimate_type_tmp == 4:
                location_estimate_type = "cancelDeferredLocation"

        if mtlcs_record.getComponentByName("measureDuration") is None:
            measure_duration = -255
        else:
            measure_duration = long(str(mtlcs_record.getComponentByName("measureDuration")))

        if mtlcs_record.getComponentByName("mlc-Number") is None:
            mlc_number = ""
        else:
            mlc_number_binascii = binascii.hexlify(str(mtlcs_record.getComponentByName("mlc-Number")))
            mlc_number_list = []
            mlc_number_data = list(mlc_number_binascii)
            for k in xrange(0, len(mlc_number_data) - 1, 2):
                mlc_number_list.append(mlc_number_data[k + 1] + "" + mlc_number_data[k])
            mlc_number_concatenated = ''.join(mlc_number_list)
            mlc_number = mlc_number_concatenated[2:].replace("f", "")

        if mtlcs_record.getComponentByName("notificationToMSUser") is None:
            notification_to_msuser = ""
        else:
            notification_to_msuser_tmp = long(str(mtlcs_record.getComponentByName("notificationToMSUser")))
            notification_to_msuser = ""
            if notification_to_msuser_tmp == 0:
                notification_to_msuser = "******"
            elif notification_to_msuser_tmp == 1:
                notification_to_msuser = "******"
            elif notification_to_msuser_tmp == 2:
                notification_to_msuser = "******"
            elif notification_to_msuser_tmp == 3:
                notification_to_msuser = "******"

        if mtlcs_record.getComponentByName("operatorId") is None:
            operator_id = -255
        else:
            operator_id = long(str(mtlcs_record.getComponentByName("operatorId")))

        if mtlcs_record.getComponentByName("positioningData") is None:
            positioning_data = ""
        else:
            positioning_data = str(mtlcs_record.getComponentByName("positioningData"))

        privacy_override_get_value = mtlcs_record.getComponentByName("privacyOverride")
        privacy_override = boolean_value(privacy_override_get_value)

        if mtlcs_record.getComponentByName("recordingEntity") is None:
            recording_entity = ""
        else:
            recording_entity_binascii = binascii.hexlify(str(mtlcs_record.getComponentByName("recordingEntity")))
            recording_entity_list = []
            recording_entity_data = list(recording_entity_binascii)
            for l in xrange(0, len(recording_entity_data) - 1, 2):
                recording_entity_list.append(recording_entity_data[l + 1] + "" + recording_entity_data[l])
            recording_entity_concatenated = ''.join(recording_entity_list)
            recording_entity_replace_f = recording_entity_concatenated.replace("f", "")
            recording_entity = recording_entity_replace_f[2:7] + recording_entity_replace_f[7:]

        if mtlcs_record.getComponentByName("recordSequenceNumber") is None:
            record_sequence_number = ""
        else:
            record_sequence_number = binascii.hexlify(str(mtlcs_record.getComponentByName("recordSequenceNumber")))

        if mtlcs_record.getComponentByName("recordType") is None:
            record_type = -255
        else:
            record_type = long(str(mtlcs_record.getComponentByName("recordType")))

        if mtlcs_record.getComponentByName("servedIMSI") is None:
            served_imsi = ""
        else:
            served_imsi_binascii = binascii.hexlify(str(mtlcs_record.getComponentByName("servedIMSI")))
            served_imsi_list = []
            served_imsi_data = list(served_imsi_binascii)
            for j in xrange(0, len(served_imsi_data) - 1, 2):
                served_imsi_list.append(served_imsi_data[j + 1] + "" + served_imsi_data[j])
            served_imsi_concatenated = ''.join(served_imsi_list)
            served_imsi = served_imsi_concatenated.replace("f", "")

        if mtlcs_record.getComponentByName("servedMSISDN") is None:
            served_msisdn = ""
        else:
            served_msisdn_binascii = binascii.hexlify(str(mtlcs_record.getComponentByName("servedMSISDN")))
            served_msisdn_list = []
            served_msisdn_data = list(served_msisdn_binascii)
            for k in xrange(0, len(served_msisdn_data) - 1, 2):
                served_msisdn_list.append(served_msisdn_data[k + 1] + "" + served_msisdn_data[k])
            served_msisdn_concatenated = ''.join(served_msisdn_list)
            served_msisdn_replace_f = served_msisdn_concatenated.replace("f", "")
            served_msisdn = served_msisdn_replace_f.replace(served_msisdn_replace_f[:3], '')

        if mtlcs_record.getComponentByName("systemType") is None:
            system_type = ""
        else:
            system_type_tmp = long(str(mtlcs_record.getComponentByName("systemType")))
            system_type = ""
            if system_type_tmp == 0:
                system_type = "unknown"
            elif system_type_tmp == 1:
                system_type = "iuUTRAN"
            elif system_type_tmp == 2:
                system_type = "gERAN"

        mtlcs_record = [charge_indicator, charged_party, cause_for_termination, diagnostics,
                        event_timestamp, file_id, hot_billing_tag, hot_billing_tag2, lcs_cause,
                        lcs_client_external_address, lcs_client_dialedbyms, lcs_client_internalid,
                        lcs_clienttype, lcs_priority, lcs_qos, location_cellid, location_estimate,
                        location_area_code, location_plmn, location_sac, deferred_location_eventtype,
                        location_estimate_type, measure_duration, mlc_number, notification_to_msuser,
                        operator_id, positioning_data, privacy_override, record_sequence_number,
                        record_type, recording_entity, served_imsi, served_msisdn, system_type,
                        long(event_timestamp.strftime("%Y%m%d")),
                        long(event_timestamp.strftime("%H"))]

        return mtlcs_record
Exemple #7
0
    def process_ssaction_records(ssaction_record, file_id, file_name):

        if ssaction_record.getComponentByName("callReference") is None:
            call_reference = ""
        else:
            call_reference = binascii.hexlify(
                str(ssaction_record.getComponentByName("callReference")))

        if ssaction_record.getComponentByName("exchangeIdentity") is None:
            exchange_identity = ""
        else:
            exchange_identity = str(
                ssaction_record.getComponentByName("exchangeIdentity"))

        if ssaction_record.getComponentByName("forwardedSubNumber") is None:
            forwarded_subnumber = ""
        else:
            forwarded_subnumber = str(
                ssaction_record.getComponentByName("forwardedSubNumber"))

        if ssaction_record.getComponentByName("globalCallReference") is None:
            global_call_reference = ""
        else:
            global_call_reference = str(
                ssaction_record.getComponentByName("globalCallReference"))

        if ssaction_record.getComponentByName("hotBillingTag2") is None:
            hot_billing_tag2 = -255
        else:
            hot_billing_tag2 = long(
                str(ssaction_record.getComponentByName("hotBillingTag2")))

        if ssaction_record.getComponentByName("location") is not None:
            location = ssaction_record.getComponentByName("location")
            location_area = binascii.hexlify(
                str(location.getComponentByName("locationArea")))
            location_area_str = str(location_area)

            location_cellid_binascii = location_area_str[10:14]
            format_location_cellid_binascii = int(location_cellid_binascii, 16)
            location_cellid = format(format_location_cellid_binascii, '05')

            location_area_code_binascii = location_area_str[6:10]
            format_location_area_code_binascii = int(
                location_area_code_binascii, 16)
            location_area_code = format(format_location_area_code_binascii,
                                        '05')

            location_plmn = parseMcc(location_area_str[0:6]) + parseMnc(
                location_area_str[0:6])

            location_sac = location_area_str[-4:]
        else:
            location_cellid = ""
            location_area_code = ""
            location_plmn = ""
            location_sac = ""

        if ssaction_record.getComponentByName("msClassmark") is None:
            ms_classmark = ""
        else:
            ms_classmark = binascii.hexlify(
                str(ssaction_record.getComponentByName("msClassmark")))

        if ssaction_record.getComponentByName("mscSPC14") is None:
            mscspc14 = ""
        else:
            mscspc14 = binascii.hexlify(
                str(ssaction_record.getComponentByName("mscSPC14")))

        if ssaction_record.getComponentByName("mscSPC24") is None:
            mscspc24 = ""
        else:
            mscspc24 = binascii.hexlify(
                str(ssaction_record.getComponentByName("mscSPC24")))

        if ssaction_record.getComponentByName("noReplyCondTime") is None:
            no_reply_condtime = -255
        else:
            no_reply_condtime = long(
                str(ssaction_record.getComponentByName("noReplyCondTime")))

        if ssaction_record.getComponentByName("operatorId") is None:
            operator_id = -255
        else:
            operator_id = long(
                str(ssaction_record.getComponentByName("operatorId")))

        if ssaction_record.getComponentByName("recordSequenceNumber") is None:
            record_sequence_number = ""
        else:
            record_sequence_number = binascii.hexlify(
                str(ssaction_record.getComponentByName(
                    "recordSequenceNumber")))

        if ssaction_record.getComponentByName("recordType") is None:
            record_type = -255
        else:
            record_type = long(
                str(ssaction_record.getComponentByName("recordType")))

        if ssaction_record.getComponentByName("recordingEntity") is None:
            recording_entity = ""
        else:
            recording_entity_binascii = binascii.hexlify(
                str(ssaction_record.getComponentByName("recordingEntity")))
            recording_entity_list = []
            recording_entity_data = list(recording_entity_binascii)
            for l in xrange(0, len(recording_entity_data) - 1, 2):
                recording_entity_list.append(recording_entity_data[l + 1] +
                                             "" + recording_entity_data[l])
            recording_entity_concatenated = ''.join(recording_entity_list)
            recording_entity_replace_f = recording_entity_concatenated.replace(
                "f", "")
            recording_entity = recording_entity_replace_f[
                2:7] + recording_entity_replace_f[7:]

        if ssaction_record.getComponentByName("servedIMEI") is None:
            served_imei = ""
        else:
            served_imei_binascii = binascii.hexlify(
                str(ssaction_record.getComponentByName("servedIMEI")))
            served_imei_list = []
            served_imei_data = list(served_imei_binascii)
            for i in xrange(0, len(served_imei_data) - 1, 2):
                served_imei_list.append(served_imei_data[i + 1] + "" +
                                        served_imei_data[i])
            served_imei_concatenated = ''.join(served_imei_list)
            served_imei = served_imei_concatenated.replace("f", "")

        if ssaction_record.getComponentByName("servedIMSI") is None:
            served_imsi = ""
        else:
            served_imsi_binascii = binascii.hexlify(
                str(ssaction_record.getComponentByName("servedIMSI")))
            served_imsi_list = []
            served_imsi_data = list(served_imsi_binascii)
            for j in xrange(0, len(served_imsi_data) - 1, 2):
                served_imsi_list.append(served_imsi_data[j + 1] + "" +
                                        served_imsi_data[j])
            served_imsi_concatenated = ''.join(served_imsi_list)
            served_imsi = served_imsi_concatenated.replace("f", "")

        if ssaction_record.getComponentByName("servedMSISDN") is None:
            served_msisdn = ""
        else:
            served_msisdn_binascii = binascii.hexlify(
                str(ssaction_record.getComponentByName("servedMSISDN")))
            served_msisdn_list = []
            served_msisdn_data = list(served_msisdn_binascii)
            for k in xrange(0, len(served_msisdn_data) - 1, 2):
                served_msisdn_list.append(served_msisdn_data[k + 1] + "" +
                                          served_msisdn_data[k])
            served_msisdn_concatenated = ''.join(served_msisdn_list)
            served_msisdn_replace_f = served_msisdn_concatenated.replace(
                "f", "")
            served_msisdn = served_msisdn_replace_f.replace(
                served_msisdn_replace_f[:3], '')

        if ssaction_record.getComponentByName("ssAction") is None:
            ssaction = ""
        else:
            ssaction_tmp = long(
                str(ssaction_record.getComponentByName("ssAction")))
            ssaction = ""
            if ssaction_tmp == 0:
                ssaction = "registration"
            elif ssaction_tmp == 1:
                ssaction = "erasure"
            elif ssaction_tmp == 2:
                ssaction = "activation"
            elif ssaction_tmp == 3:
                ssaction = "deactivation"
            elif ssaction_tmp == 4:
                ssaction = "interrogation"
            elif ssaction_tmp == 5:
                ssaction = "invocation"
            elif ssaction_tmp == 6:
                ssaction = "passwordRegistration"

        if ssaction_record.getComponentByName("ssActionResult") is None:
            ssaction_result = ""
        else:
            ssaction_result = ssaction_record.getComponentByName(
                "ssActionResult").getName()

        ssaction_time_tmp = binascii.hexlify(
            str(ssaction_record.getComponentByName("ssActionTime")))
        ssaction_time = append_timezone_offset(
            parseTimestamp(ssaction_time_tmp))

        if ssaction_record.getComponentByName("ssParameters") is None:
            ss_parameters = ""
        else:
            ss_parameters = str(
                ssaction_record.getComponentByName("ssParameters"))

        if ssaction_record.getComponentByName("supplService") is None:
            suppl_service = ""
        else:
            suppl_service = binascii.hexlify(
                str(ssaction_record.getComponentByName("supplService")))

        if ssaction_record.getComponentByName("systemType") is None:
            system_type = ""
        else:
            system_type_tmp = long(
                str(ssaction_record.getComponentByName("systemType")))
            system_type = ""
            if system_type_tmp == 0:
                system_type = "unknown"
            elif system_type_tmp == 1:
                system_type = "iuUTRAN"
            elif system_type_tmp == 2:
                system_type = "gERAN"

        if ssaction_record.getComponentByName(
                "transactionIdentification") is None:
            transaction_identification = ""
        else:
            transaction_identification = str(
                ssaction_record.getComponentByName(
                    "transactionIdentification"))

        ssaction_record = [
            call_reference, exchange_identity, file_id, forwarded_subnumber,
            global_call_reference, hot_billing_tag2, location_cellid,
            location_area_code, location_plmn, location_sac, ms_classmark,
            mscspc14, mscspc24, no_reply_condtime, operator_id,
            record_sequence_number, record_type, recording_entity, served_imei,
            served_imsi, served_msisdn, ssaction, ssaction_result,
            ssaction_time, ss_parameters, suppl_service, system_type,
            transaction_identification,
            long(ssaction_time.strftime("%Y%m%d")),
            long(ssaction_time.strftime("%H"))
        ]

        return ssaction_record