<s> import logging <EOL> from twisted . internet import reactor , defer <EOL> from smpp . twisted . client import SMPPClientTransceiver , SMPPClientService <EOL> from smpp . twisted . config import SMPPClientConfig <EOL> class SMPP ( object ) : <EOL> def __init__ ( self , config = None ) : <EOL> if config is None : <EOL> config = SMPPClientConfig ( host = '<STR_LIT:localhost>' , port = <NUM_LIT> , username = '<STR_LIT>' , password = '<STR_LIT>' ) <EOL> self . config = config <EOL> @ defer . inlineCallbacks <EOL> def run ( self ) : <EOL> try : <EOL> smpp = yield SMPPClientTransceiver ( self . config , self . handleMsg ) . connectAndBind ( ) <EOL> yield smpp . getDisconnectedDeferred ( ) <EOL> except Exception , e : <EOL> print "<STR_LIT>" % str ( e ) <EOL> finally : <EOL> reactor . stop ( ) <EOL> def handleMsg ( self , smpp , pdu ) : <EOL> """<STR_LIT>""" <EOL> print "<STR_LIT>" % pdu <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> logging . basicConfig ( level = logging . DEBUG ) <EOL> SMPP ( ) . run ( ) <EOL> reactor . run ( ) </s>
