<s> import logging <EOL> import os <EOL> import re <EOL> from jasmin . vendor . smpp . pdu . pdu_types import ( EsmClass , EsmClassMode , EsmClassType , <EOL> RegisteredDelivery , RegisteredDeliveryReceipt , <EOL> AddrTon , AddrNpi , <EOL> PriorityFlag , ReplaceIfPresentFlag ) <EOL> from jasmin . config . tools import ConfigFile <EOL> ROOT_PATH = os . getenv ( '<STR_LIT>' , '<STR_LIT:/>' ) <EOL> class ConfigUndefinedIdError ( Exception ) : <EOL> """<STR_LIT>""" <EOL> class ConfigInvalidIdError ( Exception ) : <EOL> """<STR_LIT>""" <EOL> class TypeMismatch ( Exception ) : <EOL> """<STR_LIT>""" <EOL> class UnknownValue ( Exception ) : <EOL> """<STR_LIT>""" <EOL> class SMPPClientConfig ( object ) : <EOL> def __init__ ( self , ** kwargs ) : <EOL> if kwargs . get ( '<STR_LIT:id>' , None ) == None : <EOL> raise ConfigUndefinedIdError ( '<STR_LIT>' ) <EOL> idcheck = re . compile ( r'<STR_LIT>' ) <EOL> if idcheck . match ( str ( kwargs . get ( '<STR_LIT:id>' ) ) ) == None : <EOL> raise ConfigInvalidIdError ( '<STR_LIT>' ) <EOL> self . id = str ( kwargs . get ( '<STR_LIT:id>' ) ) <EOL> self . port = kwargs . get ( '<STR_LIT:port>' , <NUM_LIT> ) <EOL> if not isinstance ( self . port , int ) : <EOL> raise TypeMismatch ( '<STR_LIT>' ) <EOL> self . log_file = kwargs . get ( '<STR_LIT>' , '<STR_LIT>' % ( ROOT_PATH , self . id ) ) <EOL> self . log_rotate = kwargs . get ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . log_level = kwargs . get ( '<STR_LIT>' , logging . INFO ) <EOL> self . log_format = kwargs . get ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . log_date_format = kwargs . get ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . sessionInitTimerSecs = kwargs . get ( '<STR_LIT>' , <NUM_LIT:30> ) <EOL> if ( not isinstance ( self . sessionInitTimerSecs , int ) <EOL> and not isinstance ( self . sessionInitTimerSecs , float ) ) : <EOL> raise TypeMismatch ( '<STR_LIT>' ) <EOL> self . enquireLinkTimerSecs = kwargs . get ( '<STR_LIT>' , <NUM_LIT:30> ) <EOL> if ( not isinstance ( self . enquireLinkTimerSecs , int ) <EOL> and not isinstance ( self . enquireLinkTimerSecs , float ) ) : <EOL> raise TypeMismatch ( '<STR_LIT>' ) <EOL> self . inactivityTimerSecs = kwargs . get ( '<STR_LIT>' , <NUM_LIT> ) <EOL> if not isinstance ( self . inactivityTimerSecs , int ) and not isinstance ( self . inactivityTimerSecs , float ) : <EOL> raise TypeMismatch ( '<STR_LIT>' ) <EOL> self . responseTimerSecs = kwargs . get ( '<STR_LIT>' , <NUM_LIT> ) <EOL> if not isinstance ( self . responseTimerSecs , int ) and not isinstance ( self . responseTimerSecs , float ) : <EOL> raise TypeMismatch ( '<STR_LIT>' ) <EOL> self . pduReadTimerSecs = kwargs . get ( '<STR_LIT>' , <NUM_LIT:10> ) <EOL> if not isinstance ( self . pduReadTimerSecs , int ) and not isinstance ( self . pduReadTimerSecs , float ) : <EOL> raise TypeMismatch ( '<STR_LIT>' ) <EOL> self . dlr_expiry = kwargs . get ( '<STR_LIT>' , <NUM_LIT> ) <EOL> if not isinstance ( self . dlr_expiry , int ) and not isinstance ( self . dlr_expiry , float ) : <EOL> raise TypeMismatch ( '<STR_LIT>' ) <EOL> self . host = kwargs . get ( '<STR_LIT:host>' , '<STR_LIT:127.0.0.1>' ) <EOL> if not isinstance ( self . host , str ) : <EOL> raise TypeMismatch ( '<STR_LIT>' ) <EOL> self . username = kwargs . get ( '<STR_LIT:username>' , '<STR_LIT>' ) <EOL> if len ( self . username ) > <NUM_LIT:15> : <EOL> raise TypeMismatch ( '<STR_LIT>' ) <EOL> self . password = kwargs . get ( '<STR_LIT:password>' , '<STR_LIT:password>' ) <EOL> if len ( self . password ) > <NUM_LIT:8> : <EOL> raise TypeMismatch ( '<STR_LIT>' ) <EOL> self . systemType = kwargs . get ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . reconnectOnConnectionLoss = kwargs . get ( '<STR_LIT>' , True ) <EOL> if not isinstance ( self . reconnectOnConnectionLoss , bool ) : <EOL> raise TypeMismatch ( '<STR_LIT>' ) <EOL> self . reconnectOnConnectionFailure = kwargs . get ( '<STR_LIT>' , True ) <EOL> if not isinstance ( self . reconnectOnConnectionFailure , bool ) : <EOL> raise TypeMismatch ( '<STR_LIT>' ) <EOL> self . reconnectOnConnectionLossDelay = kwargs . get ( '<STR_LIT>' , <NUM_LIT:10> ) <EOL> if ( not isinstance ( self . reconnectOnConnectionLossDelay , int ) <EOL> and not isinstance ( self . reconnectOnConnectionLossDelay , float ) ) : <EOL> raise TypeMismatch ( '<STR_LIT>' ) <EOL> self . reconnectOnConnectionFailureDelay = kwargs . get ( '<STR_LIT>' , <NUM_LIT:10> ) <EOL> if ( not isinstance ( self . reconnectOnConnectionFailureDelay , int ) <EOL> and not isinstance ( self . reconnectOnConnectionFailureDelay , float ) ) : <EOL> raise TypeMismatch ( '<STR_LIT>' ) <EOL> self . useSSL = kwargs . get ( '<STR_LIT>' , False ) <EOL> self . SSLCertificateFile = kwargs . get ( '<STR_LIT>' , None ) <EOL> self . bindOperation = kwargs . get ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> if self . bindOperation not in [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] : <EOL> raise UnknownValue ( '<STR_LIT>' % self . bindOperation ) <EOL> self . service_type = kwargs . get ( '<STR_LIT>' , None ) <EOL> self . addressTon = kwargs . get ( '<STR_LIT>' , AddrTon . UNKNOWN ) <EOL> self . addressNpi = kwargs . get ( '<STR_LIT>' , AddrNpi . UNKNOWN ) <EOL> self . source_addr_ton = kwargs . get ( '<STR_LIT>' , AddrTon . NATIONAL ) <EOL> self . source_addr_npi = kwargs . get ( '<STR_LIT>' , AddrNpi . ISDN ) <EOL> self . dest_addr_ton = kwargs . get ( '<STR_LIT>' , AddrTon . INTERNATIONAL ) <EOL> self . dest_addr_npi = kwargs . get ( '<STR_LIT>' , AddrNpi . ISDN ) <EOL> self . addressRange = kwargs . get ( '<STR_LIT>' , None ) <EOL> self . source_addr = kwargs . get ( '<STR_LIT>' , None ) <EOL> self . esm_class = kwargs . get ( '<STR_LIT>' , <EOL> EsmClass ( EsmClassMode . STORE_AND_FORWARD , EsmClassType . DEFAULT ) ) <EOL> self . protocol_id = kwargs . get ( '<STR_LIT>' , None ) <EOL> self . priority_flag = kwargs . get ( '<STR_LIT>' , PriorityFlag . LEVEL_0 ) <EOL> self . schedule_delivery_time = kwargs . get ( '<STR_LIT>' , None ) <EOL> self . validity_period = kwargs . get ( '<STR_LIT>' , None ) <EOL> self . registered_delivery = kwargs . get ( <EOL> '<STR_LIT>' , <EOL> RegisteredDelivery ( RegisteredDeliveryReceipt . NO_SMSC_DELIVERY_RECEIPT_REQUESTED ) ) <EOL> self . replace_if_present_flag = kwargs . get ( <EOL> '<STR_LIT>' , ReplaceIfPresentFlag . DO_NOT_REPLACE ) <EOL> self . sm_default_msg_id = kwargs . get ( '<STR_LIT>' , <NUM_LIT:0> ) <EOL> self . data_coding = kwargs . get ( '<STR_LIT>' , <NUM_LIT:0> ) <EOL> if self . data_coding not in [ <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:4> , <NUM_LIT:5> , <NUM_LIT:6> , <NUM_LIT:7> , <NUM_LIT:8> , <NUM_LIT:9> , <NUM_LIT:10> , <NUM_LIT> , <NUM_LIT> ] : <EOL> raise UnknownValue ( '<STR_LIT>' % self . data_coding ) <EOL> self . requeue_delay = kwargs . get ( '<STR_LIT>' , <NUM_LIT> ) <EOL> if not isinstance ( self . requeue_delay , int ) and not isinstance ( self . requeue_delay , float ) : <EOL> raise TypeMismatch ( '<STR_LIT>' ) <EOL> self . submit_sm_throughput = kwargs . get ( '<STR_LIT>' , <NUM_LIT:1> ) <EOL> if ( not isinstance ( self . submit_sm_throughput , int ) <EOL> and not isinstance ( self . submit_sm_throughput , float ) ) : <EOL> raise TypeMismatch ( '<STR_LIT>' ) <EOL> self . dlr_msg_id_bases = kwargs . get ( '<STR_LIT>' , <NUM_LIT:0> ) <EOL> if self . dlr_msg_id_bases not in [ <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:2> ] : <EOL> raise UnknownValue ( '<STR_LIT>' % self . dlr_msg_id_bases ) <EOL> class SMPPClientServiceConfig ( ConfigFile ) : <EOL> def __init__ ( self , config_file ) : <EOL> ConfigFile . __init__ ( self , config_file ) <EOL> self . log_level = logging . getLevelName ( self . _get ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> self . log_file = self . _get ( <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' % ROOT_PATH ) <EOL> self . log_rotate = self . _get ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . log_format = self . _get ( <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . log_date_format = self . _get ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> class SMPPServerConfig ( ConfigFile ) : <EOL> def __init__ ( self , config_file = None ) : <EOL> ConfigFile . __init__ ( self , config_file ) <EOL> self . id = self . _get ( '<STR_LIT>' , '<STR_LIT:id>' , '<STR_LIT>' ) <EOL> self . bind = self . _get ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . port = self . _getint ( '<STR_LIT>' , '<STR_LIT:port>' , <NUM_LIT> ) <EOL> self . log_level = logging . getLevelName ( self . _get ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> self . log_file = self . _get ( <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' % ( ROOT_PATH , self . id ) ) <EOL> self . log_rotate = self . _get ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . log_format = self . _get ( <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . log_date_format = self . _get ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . sessionInitTimerSecs = self . _getint ( '<STR_LIT>' , '<STR_LIT>' , <NUM_LIT:30> ) <EOL> self . enquireLinkTimerSecs = self . _getint ( '<STR_LIT>' , '<STR_LIT>' , <NUM_LIT:30> ) <EOL> self . inactivityTimerSecs = self . _getint ( '<STR_LIT>' , '<STR_LIT>' , <NUM_LIT> ) <EOL> self . responseTimerSecs = self . _getint ( '<STR_LIT>' , '<STR_LIT>' , <NUM_LIT> ) <EOL> self . pduReadTimerSecs = self . _getint ( '<STR_LIT>' , '<STR_LIT>' , <NUM_LIT:10> ) <EOL> self . dlr_expiry = self . _getint ( '<STR_LIT>' , '<STR_LIT>' , <NUM_LIT> ) </s>
