On Sun, Jun 13, 2010 at 05:33:42PM +0300, Michael Goldish wrote: > This module should replace vm.send_monitor_cmd(). Instead of connecting to the > monitor each time a command is issued, this module maintains a continuous > connection to the monitor. It disconnects when a test terminates and > reconnects as soon as the next test begins (upon unpickling). > > It currently contains only an interface to the human monitor. A QMP interface > will be introduced in a future patch. > > Signed-off-by: Michael Goldish <mgoldish@xxxxxxxxxx> > --- > client/tests/kvm/kvm_monitor.py | 356 +++++++++++++++++++++++++++++++++++++++ > 1 files changed, 356 insertions(+), 0 deletions(-) > create mode 100644 client/tests/kvm/kvm_monitor.py > > diff --git a/client/tests/kvm/kvm_monitor.py b/client/tests/kvm/kvm_monitor.py > new file mode 100644 > index 0000000..c5cf9c3 > --- /dev/null > +++ b/client/tests/kvm/kvm_monitor.py > @@ -0,0 +1,356 @@ > +""" > +Interfaces to the QEMU monitor. > + > +@copyright: 2008-2010 Red Hat Inc. > +""" > + ... > +class HumanMonitor(Monitor): > + """ > + Wraps "human monitor" commands. > + """ > + > + def __init__(self, filename, suppress_exceptions=False): > + """ > + Connect to the monitor socket and find the (qemu) prompt. > + > + @param filename: Monitor socket filename > + @raise MonitorConnectError: Raised if the connection fails and > + suppress_exceptions is False > + @raise MonitorProtocolError: Raised if the initial (qemu) prompt isn't > + found and suppress_exceptions is False > + """ > + try: > + Monitor.__init__(self, filename) > + > + self.protocol = "human" > + > + # Find the initial (qemu) prompt > + s, o = self._read_up_to_qemu_prompt(20) > + if not s: > + raise MonitorProtocolError("Could not find (qemu) prompt " > + "after connecting to monitor. " > + "Output so far: %r" % o) > + > + # Save the output of 'help' for future use > + self.help = self._get_command_output("help") Hi Michael, Here, self.help is a string type. But you repeatedly define a sub function self.help() below. If I call vm.monitor.help() in testcase, will touch this err: TypeError: 'str' object is not callable How about using self.help_str = self._get_command_output("help")? and remove help sub function, Not only repeated name, but repeated function. Amos > + > + except MonitorError, e: > + if suppress_exceptions: > + logging.warn(e) > + else: > + raise > + ... > + > + def help(self): > + """ > + Send "help" and return the output. > + """ > + return self._get_command_output("help") ... -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html