<s> """<STR_LIT>""" <EOL> import sys <EOL> import asyncore <EOL> from . debugging import bacpypes_debugging , ModuleLogger <EOL> from . core import deferred <EOL> from . comm import PDU , Client , Server <EOL> _debug = <NUM_LIT:0> <EOL> _log = ModuleLogger ( globals ( ) ) <EOL> try : <EOL> asyncore . file_dispatcher <EOL> except : <EOL> class _barf : <EOL> def __init__ ( self , * args ) : <EOL> pass <EOL> asyncore . file_dispatcher = _barf <EOL> @ bacpypes_debugging <EOL> class ConsoleClient ( asyncore . file_dispatcher , Client ) : <EOL> def __init__ ( self , cid = None ) : <EOL> if _debug : ConsoleClient . _debug ( "<STR_LIT>" , cid ) <EOL> asyncore . file_dispatcher . __init__ ( self , sys . stdin ) <EOL> Client . __init__ ( self , cid ) <EOL> def readable ( self ) : <EOL> return True <EOL> def writable ( self ) : <EOL> return False <EOL> def handle_read ( self ) : <EOL> if _debug : deferred ( ConsoleClient . _debug , "<STR_LIT>" ) <EOL> data = sys . stdin . read ( ) <EOL> if _debug : deferred ( ConsoleClient . _debug , "<STR_LIT>" , data ) <EOL> deferred ( self . request , PDU ( data ) ) <EOL> def confirmation ( self , pdu ) : <EOL> if _debug : deferred ( ConsoleClient . _debug , "<STR_LIT>" , pdu ) <EOL> try : <EOL> sys . stdout . write ( pdu . pduData ) <EOL> except Exception as err : <EOL> ConsoleClient . _exception ( "<STR_LIT>" , err ) <EOL> @ bacpypes_debugging <EOL> class ConsoleServer ( asyncore . file_dispatcher , Server ) : <EOL> def __init__ ( self , sid = None ) : <EOL> if _debug : ConsoleServer . _debug ( "<STR_LIT>" , sid ) <EOL> asyncore . file_dispatcher . __init__ ( self , sys . stdin ) <EOL> Server . __init__ ( self , sid ) <EOL> def readable ( self ) : <EOL> return True <EOL> def writable ( self ) : <EOL> return False <EOL> def handle_read ( self ) : <EOL> if _debug : deferred ( ConsoleServer . _debug , "<STR_LIT>" ) <EOL> data = sys . stdin . read ( ) <EOL> if _debug : deferred ( ConsoleServer . _debug , "<STR_LIT>" , data ) <EOL> deferred ( self . response , PDU ( data ) ) <EOL> def indication ( self , pdu ) : <EOL> if _debug : deferred ( ConsoleServer . _debug , "<STR_LIT>" , pdu ) <EOL> try : <EOL> sys . stdout . write ( pdu . pduData ) <EOL> except Exception as err : <EOL> ConsoleServer . _exception ( "<STR_LIT>" , err ) </s>
