diff options
author | Narayan Desai <desai@mcs.anl.gov> | 2009-10-26 01:17:57 +0000 |
---|---|---|
committer | Narayan Desai <desai@mcs.anl.gov> | 2009-10-26 01:17:57 +0000 |
commit | 10139d9609e13ba3ac5a5cf8bd10907581e9eda0 (patch) | |
tree | b9646f62f47fbf03ec035843c9d0e17ba6c8836d /src/sbin/bcfg2-info | |
parent | 1ab7b6e110dbdf4d7ae5758913a29c065076579f (diff) | |
download | bcfg2-10139d9609e13ba3ac5a5cf8bd10907581e9eda0.tar.gz bcfg2-10139d9609e13ba3ac5a5cf8bd10907581e9eda0.tar.bz2 bcfg2-10139d9609e13ba3ac5a5cf8bd10907581e9eda0.zip |
bcfg2-info: Implement debug script mode
git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@5504 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'src/sbin/bcfg2-info')
-rwxr-xr-x | src/sbin/bcfg2-info | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/src/sbin/bcfg2-info b/src/sbin/bcfg2-info index 2dad05fd4..801fb1fc1 100755 --- a/src/sbin/bcfg2-info +++ b/src/sbin/bcfg2-info @@ -5,6 +5,7 @@ __revision__ = '$Revision$' from code import InteractiveConsole import cmd import errno +import getopt import logging import lxml.etree import os @@ -104,11 +105,29 @@ class infoCore(cmd.Cmd, Bcfg2.Server.Core.Core): except: logger.error("command failure", exc_info=1) - def do_debug(self, _): + def do_debug(self, args): + try: + opts, _ = getopt.getopt(args.split(), 'nf:') + except: + print "Usage: debug [-n] [-f <command list>]" + return self.cont = False - print("dropping to python interpreter; press ^D to resume") + scriptmode = False + interactive = True + for opt in opts: + if opt[0] == '-f': + scriptmode = True + spath = opt[1] + elif opt[0] == '-n': + interactive = False sh = InteractiveConsole(locals()) - sh.interact() + if scriptmode: + for command in [c.strip() for c in open(spath).readlines()]: + if command: + sh.push(command) + if interactive: + print("dropping to python interpreter; press ^D to resume") + sh.interact() def do_quit(self, _): """Exit program. |