Package flumotion :: Package extern :: Package command :: Package command :: Module manholecmd :: Class ManholeInterpreter
[hide private]

type ManholeInterpreter

source code

                 object --+    
                          |    
                Interpreter --+
                              |
code.InteractiveInterpreter --+
                              |
                             ManholeInterpreter

Interactive Interpreter with special output and Deferred support.

Aside from the features provided by code.InteractiveInterpreter, this class captures sys.stdout output and redirects it to the appropriate location (the Manhole protocol instance). It also treats Deferreds which reach the top-level specially: each is formatted to the user with a unique identifier and a new callback and errback added to it, each of which will format the unique identifier and the result with which the Deferred fires and then pass it on to the next participant in the callback chain.

Instance Methods [hide private]
 
__init__(self, handler, locals=None, filename='<console>')
Constructor.
source code
 
runcode(self, *a, **kw)
Execute a code object.
source code
 
write(self, data, async=False)
Write a string.
source code
 
resetBuffer(self)
Reset the input buffer.
source code
 
push(self, line)
Push a line to the interpreter.
source code
 
displayhook(self, obj) source code
 
_cbDisplayDeferred(self, result, k, obj) source code
 
_ebDisplayDeferred(self, failure, k, obj) source code

Inherited from code.InteractiveInterpreter: runsource, showsyntaxerror, showtraceback

Class Variables [hide private]
  numDeferreds = 0
  buffer = None
Method Details [hide private]

__init__(self, handler, locals=None, filename='<console>')
(Constructor)

source code 

Constructor.

The optional 'locals' argument specifies the dictionary in which code will be executed; it defaults to a newly created dictionary with key "__name__" set to "__console__" and key "__doc__" set to None.

Overrides: code.InteractiveInterpreter.__init__
(inherited documentation)

runcode(self, *a, **kw)

source code 

Execute a code object.

When an exception occurs, self.showtraceback() is called to display a traceback. All exceptions are caught except SystemExit, which is reraised.

A note about KeyboardInterrupt: this exception may occur elsewhere in this code, and may not always be caught. The caller should be prepared to deal with it.

Overrides: code.InteractiveInterpreter.runcode
(inherited documentation)

write(self, data, async=False)

source code 

Write a string.

The base implementation writes to sys.stderr; a subclass may replace this with a different implementation.

Overrides: code.InteractiveInterpreter.write
(inherited documentation)

push(self, line)

source code 

Push a line to the interpreter.

The line should not have a trailing newline; it may have internal newlines. The line is appended to a buffer and the interpreter's runsource() method is called with the concatenated contents of the buffer as source. If this indicates that the command was executed or invalid, the buffer is reset; otherwise, the command is incomplete, and the buffer is left as it was after the line was appended. The return value is 1 if more input is required, 0 if the line was dealt with in some way (this is the same as runsource()).

Overrides: Interpreter.push