SMPPSessionStates = Enum( 'NONE', 'OPEN', 'BIND_TX_PENDING', 'BOUND_TX', 'BIND_RX_PENDING', 'BOUND_RX', 'BIND_TRX_PENDING', 'BOUND_TRX', 'UNBIND_PENDING', 'UNBIND_RECEIVED', 'UNBOUND' ) SMPPOutboundTxn = namedtuple('SMPPOutboundTxn', 'request, timer, ackDeferred') SMPPOutboundTxnResult = namedtuple('SMPPOutboundTxnResult', 'smpp, request, response') def _safelylogOutPdu(content): try: return binascii.b2a_hex(content) except exceptions.UnicodeEncodeError: return "Couldn't log out the pdu content due to non-ascii characters." class DataHandlerResponse(object): def __init__(self, status, **params): self.status = status self.params = params
limitations under the License. """ """ Updated code parts are marked with "Jasmin update" comment """ from jasmin.vendor.enum import Enum from jasmin.vendor.smpp.pdu.namedtuple import namedtuple from jasmin.vendor.smpp.pdu import constants CommandId = Enum(*constants.command_id_name_map.keys()) CommandStatus = Enum(*constants.command_status_name_map.keys()) Tag = Enum(*constants.tag_name_map.keys()) Option = namedtuple('Option', 'tag, value') EsmClassMode = Enum(*constants.esm_class_mode_name_map.keys()) EsmClassType = Enum(*constants.esm_class_type_name_map.keys()) EsmClassGsmFeatures = Enum(*constants.esm_class_gsm_features_name_map.keys()) EsmClassBase = namedtuple('EsmClass', 'mode, type, gsmFeatures') class EsmClass(EsmClassBase): def __new__(cls, mode, type, gsmFeatures=[]): return EsmClassBase.__new__(cls, mode, type, set(gsmFeatures)) def __repr__(self): return 'EsmClass[mode: %s, type: %s, gsmFeatures: %s]' % (self.mode, self.type, self.gsmFeatures)
# Jasmin update, #267 def __init__(self, offsetMin=0, name=None): self.__offset = timedelta(minutes=offsetMin) self.__name = name def utcoffset(self, dt): return self.__offset def tzname(self, dt): return self.__name def dst(self, dt): return timedelta(0) SMPPRelativeTime = namedtuple('SMPPRelativeTime', 'years, months, days, hours, minutes, seconds') YYMMDDHHMMSS_FORMAT = "%y%m%d%H%M%S" def parse_t(t_str): if len(t_str) != 1: raise ValueError("tenths of second must be one digit") return int(t_str) def unparse_t(t): if t < 0 or t > 9: raise ValueError("tenths of second must be one digit") return '%1d' % t def parse_nn(nn_str): if len(nn_str) != 2:
http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either expressed or implied. See the License for the specific language governing permissions and limitations under the License. """ import struct, StringIO from jasmin.vendor.smpp.pdu.operations import DeliverSM, DataSM from jasmin.vendor.smpp.pdu.pdu_types import * from jasmin.vendor.smpp.pdu.namedtuple import namedtuple from jasmin.vendor.smpp.pdu.gsm_types import InformationElementIdentifier from jasmin.vendor.smpp.pdu.gsm_encoding import UserDataHeaderEncoder ShortMessageString = namedtuple('ShortMessageString', 'bytes, unicode, udh') class SMStringEncoder(object): userDataHeaderEncoder = UserDataHeaderEncoder() def decodeSM(self, pdu): data_coding = pdu.params['data_coding'] #TODO - when to look for message_payload instead of short_message?? (smBytes, udhBytes, smStrBytes) = self.splitSM(pdu) udh = self.decodeUDH(udhBytes) if data_coding.scheme == DataCodingScheme.DEFAULT: unicodeStr = None if data_coding.schemeData == DataCodingDefault.SMSC_DEFAULT_ALPHABET: unicodeStr = unicode(smStrBytes, 'ascii')
http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either expressed or implied. See the License for the specific language governing permissions and limitations under the License. """ import struct, StringIO from jasmin.vendor.smpp.pdu.operations import DeliverSM, DataSM from jasmin.vendor.smpp.pdu.pdu_types import * from jasmin.vendor.smpp.pdu.namedtuple import namedtuple from jasmin.vendor.smpp.pdu.gsm_types import InformationElementIdentifier from jasmin.vendor.smpp.pdu.gsm_encoding import UserDataHeaderEncoder ShortMessageString = namedtuple('ShortMessageString', 'bytes, unicode, udh') class SMStringEncoder(object): userDataHeaderEncoder = UserDataHeaderEncoder() def decodeSM(self, pdu): data_coding = pdu.params['data_coding'] #TODO - when to look for message_payload instead of short_message?? (smBytes, udhBytes, smStrBytes) = self.splitSM(pdu) udh = self.decodeUDH(udhBytes) if data_coding.scheme == DataCodingScheme.DEFAULT: unicodeStr = None if data_coding.schemeData == DataCodingDefault.SMSC_DEFAULT_ALPHABET: unicodeStr = unicode(smStrBytes, 'ascii') elif data_coding.schemeData == DataCodingDefault.IA5_ASCII:
limitations under the License. """ """ Updated code parts are marked with "Jasmin update" comment """ from jasmin.vendor.enum import Enum from jasmin.vendor.smpp.pdu.namedtuple import namedtuple from jasmin.vendor.smpp.pdu import constants CommandId = Enum(*constants.command_id_name_map.keys()) CommandStatus = Enum(*constants.command_status_name_map.keys()) Tag = Enum(*constants.tag_name_map.keys()) Option = namedtuple('Option', 'tag, value') EsmClassMode = Enum(*constants.esm_class_mode_name_map.keys()) EsmClassType = Enum(*constants.esm_class_type_name_map.keys()) EsmClassGsmFeatures = Enum(*constants.esm_class_gsm_features_name_map.keys()) EsmClassBase = namedtuple('EsmClass', 'mode, type, gsmFeatures') class EsmClass(EsmClassBase): def __new__(cls, mode, type, gsmFeatures=[]): return EsmClassBase.__new__(cls, mode, type, set(gsmFeatures)) def __repr__(self): return 'EsmClass[mode: %s, type: %s, gsmFeatures: %s]' % ( self.mode, self.type, self.gsmFeatures)
""" Copyright 2009-2010 Mozes, Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either expressed or implied. See the License for the specific language governing permissions and limitations under the License. """ from jasmin.vendor.enum import Enum from jasmin.vendor.smpp.pdu.namedtuple import namedtuple from jasmin.vendor.smpp.pdu import gsm_constants InformationElementIdentifier = Enum( *gsm_constants.information_element_identifier_name_map.keys()) InformationElement = namedtuple('InformationElement', 'identifier, data') IEConcatenatedSM = namedtuple('IEConcatenatedSM', 'referenceNum, maximumNum, sequenceNum')
# Jasmin update, #267 def __init__(self, offsetMin = 0, name = None): self.__offset = timedelta(minutes = offsetMin) self.__name = name def utcoffset(self, dt): return self.__offset def tzname(self, dt): return self.__name def dst(self, dt): return timedelta(0) SMPPRelativeTime = namedtuple('SMPPRelativeTime', 'years, months, days, hours, minutes, seconds') YYMMDDHHMMSS_FORMAT = "%y%m%d%H%M%S" def parse_t(t_str): if len(t_str) != 1: raise ValueError("tenths of second must be one digit") return int(t_str) def unparse_t(t): if t < 0 or t > 9: raise ValueError("tenths of second must be one digit") return '%1d' % t def parse_nn(nn_str): if len(nn_str) != 2:
""" Copyright 2009-2010 Mozes, Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either expressed or implied. See the License for the specific language governing permissions and limitations under the License. """ from enum import Enum from jasmin.vendor.smpp.pdu.namedtuple import namedtuple from jasmin.vendor.smpp.pdu import gsm_constants InformationElementIdentifier = Enum(*gsm_constants.information_element_identifier_name_map.keys()) InformationElement = namedtuple('InformationElement', 'identifier, data') IEConcatenatedSM = namedtuple('IEConcatenatedSM', 'referenceNum, maximumNum, sequenceNum')
""" Copyright 2009-2010 Mozes, Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either expressed or implied. See the License for the specific language governing permissions and limitations under the License. """ from jasmin.vendor.enum import Enum from jasmin.vendor.smpp.pdu.namedtuple import namedtuple from jasmin.vendor.smpp.pdu import gsm_constants InformationElementIdentifier = Enum(*gsm_constants.information_element_identifier_name_map.keys()) InformationElement = namedtuple("InformationElement", "identifier, data") IEConcatenatedSM = namedtuple("IEConcatenatedSM", "referenceNum, maximumNum, sequenceNum")