catch exception in cmds

This commit is contained in:
Wolfgang Hottgenroth 2019-07-18 14:55:27 +02:00
parent 5c8b2599a6
commit 2a704738b2
Signed by: wn
GPG Key ID: B586EAFCDF2F65F4

View File

@ -31,6 +31,12 @@ class CmdInterpreter(cmd.Cmd):
self.splitterRe = re.compile('\s+')
self.logger = logging.getLogger('CmdInterpreter')
def onecmd(self, line):
try:
return self.onecmd(line)
except Exception as e:
msg = 'Caught exception in cmd "{0}": {1!s}'.format(line, e)
def __print(self, text):
self.stdout.write(text)