From 9bf76f4b581c37b03bac49636447325146531dc9 Mon Sep 17 00:00:00 2001 From: Narayan Desai Date: Wed, 21 Oct 2009 02:55:12 +0000 Subject: bcfg2-info: simplify codepaths for debug mode git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@5489 ce84e21b-d406-0410-9b95-82705330c041 --- src/sbin/bcfg2-info | 34 +--------------------------------- 1 file changed, 1 insertion(+), 33 deletions(-) (limited to 'src/sbin') diff --git a/src/sbin/bcfg2-info b/src/sbin/bcfg2-info index 93f417d89..2dad05fd4 100755 --- a/src/sbin/bcfg2-info +++ b/src/sbin/bcfg2-info @@ -24,38 +24,6 @@ logger = logging.getLogger('bcfg2-info') class dummyError(Exception): pass -class debug_fcacher: - "Cache the stdout text so we can analyze it before returning it" - def __init__(self): self.reset() - def reset(self): self.out = [] - def write(self, line): self.out.append(line) - def flush(self): - output = '\n'.join(self.out) - self.reset() - return output - -class debug_shell(InteractiveConsole): - "Wrapper around Python that can filter input/output to the shell" - def __init__(self, mylocals): - self.stdout = sys.stdout - self.cache = debug_fcacher() - InteractiveConsole.__init__(self, mylocals) - - def get_output(self): sys.stdout = self.cache - def return_output(self): sys.stdout = self.stdout - - def push(self, line): - self.get_output() - # you can filter input here by doing something like - # line = filter(line) - rc = InteractiveConsole.push(self, line) - self.return_output() - output = self.cache.flush() - # you can filter the output here by doing something like - # output = filter(output) - sys.stdout.write(output) - return rc - class ConfigFileNotBuilt(Exception): ''' Thrown when ConfigFile entry contains no content''' def __init__(self, value): @@ -139,7 +107,7 @@ class infoCore(cmd.Cmd, Bcfg2.Server.Core.Core): def do_debug(self, _): self.cont = False print("dropping to python interpreter; press ^D to resume") - sh = debug_shell(locals()) + sh = InteractiveConsole(locals()) sh.interact() def do_quit(self, _): -- cgit v1.2.3-1-g7c22