Bugger API Documentation¶
bugger.console¶
A Collection of InteractiveConsoles made available through various interfaces
- class bugger.console.StreamInteractiveConsole(input_stream, output_stream, locals=None)¶
Interactive console that works off an input and output stream
- async_init(banner=None, ps1=None, ps2=None)¶
Initialize the interpreter when operating in async mode
This will push out the banner and other intro items. After this call returns, further input that comes in through whatever channel should be piped through async_input(), the result will be written back out the output channel when there is something to write.
- async_recv(bytes='')¶
Notify this console that there is data to receive
- close()¶
Close the input and output streams
- raw_input(prompt='')¶
Override the default behaviour of raw_input to write to the stream
- write(data)¶
Write the specified data to the output stream
- class bugger.console.TelnetInteractiveConsoleServer(host='0.0.0.0', port=7070, locals=None, select_timeout=5.0)¶
Make an interactive console available via telnet which can interact with your app
- accept_interactions()¶
Accept and interact with clients via telnet
This is the main beef of the application and a blocking call. If you desire to run your telnet session inside of a separate thread, you can do something like the following...
>>> >>> import threading >>> from bugger.console import TelnetInteractiveConsole >>> console = TelnetInteractiveConsole(port=7070) >>> t = threading.Thread(name="Telnet Interactive Session", target=console.accept_interactions) >>> # ... >>> console.stop() # this will end the target method and thread
- client_connect(client)¶
Called when a client successfully connected to the server
Might be overridden in subclasses. client is the socket object of the client connection.
- client_disconnect(client)¶
Called when a client is about to disconnected from the server
Might be overridden in subclasses. client is the socket object of the client connection.
- stop()¶
Cleanly shutdown and kill this console session