From 70c9bf49df5a3d4739afee5a05749d2a02c521a7 Mon Sep 17 00:00:00 2001 From: Rob Austein Date: Tue, 6 Apr 2010 23:47:33 +0000 Subject: Don't bomb out of command processor if we see an exception. svn path=/rpkid/rpki/cli.py; revision=3165 --- rpkid/rpki/cli.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/rpkid/rpki/cli.py b/rpkid/rpki/cli.py index 80f8587f..10ace337 100644 --- a/rpkid/rpki/cli.py +++ b/rpkid/rpki/cli.py @@ -18,7 +18,7 @@ OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. """ -import cmd, glob, os.path +import cmd, glob, os.path, traceback try: import readline @@ -46,6 +46,18 @@ class Cmd(cmd.Cmd): else: self.cmdloop_with_history() + def onecmd(self, line): + """ + Wrap error handling around cmd.Cmd.onecmd(). Might want to do + something kinder than showing a traceback, eventually. + """ + try: + return cmd.Cmd.onecmd(self, line) + except SystemExit: + raise + except: + traceback.print_exc() + def do_EOF(self, arg): """ Exit program. -- cgit v1.2.3