# HG changeset patch # User catherine@dellzilla # Date 1237916905 14400 # Node ID 78ad20c2eed0ab10455f4bf28d77a2901d5ab280 # Parent ff99b39259d57312f2a90067a799c3f114f6c81a py working better now; still needs a iscomplete=True on onecmd diff -r ff99b39259d5 -r 78ad20c2eed0 cmd2.py --- a/cmd2.py Tue Mar 24 13:29:54 2009 -0400 +++ b/cmd2.py Tue Mar 24 13:48:25 2009 -0400 @@ -26,7 +26,8 @@ flagReader.py options are still supported for backward compatibility """ import cmd, re, os, sys, optparse, subprocess, tempfile, pyparsing, doctest -import unittest, string, datetime, urllib, inspect, code +import unittest, string, datetime, urllib, inspect +from code import InteractiveConsole, InteractiveInterpreter, softspace from optparse import make_option __version__ = '0.4.8' @@ -225,7 +226,7 @@ class EmbeddedConsoleExit(Exception): pass -class InteractiveConsole(code.InteractiveConsole): +class MyInteractiveConsole(InteractiveConsole): def runcode(self, code): """Execute a code object. @@ -247,7 +248,7 @@ except: self.showtraceback() else: - if code.softspace(sys.stdout, 0): + if softspace(sys.stdout, 0): print class Cmd(cmd.Cmd): @@ -796,17 +797,20 @@ Non-python commands can be issued with cmd('your non-python command here'). ''' if arg.strip(): - interp = code.InteractiveInterpreter(locals=self.pystate) + interp = InteractiveInterpreter(locals=self.pystate) interp.runcode(arg) else: - interp = InteractiveConsole(locals=self.pystate) + interp = MyInteractiveConsole(locals=self.pystate) def quit(): raise EmbeddedConsoleExit self.pystate['quit'] = quit self.pystate['exit'] = quit + self.pystate[self.nonpythoncommand] = self.onecmd try: interp.interact() - except (EmbeddedConsoleExit, SystemExit): + except SystemExit: + quit() + except EmbeddedConsoleExit: return def do_history(self, arg):