always flush formatter after calling a command

This commit is contained in:
Romain Bignon 2011-08-12 09:54:11 +02:00
commit 18dd9e2b8f
2 changed files with 16 additions and 10 deletions

View file

@ -77,6 +77,9 @@ class TableFormatter(IFormatter):
s += table.get_html_string() s += table.get_html_string()
else: else:
s += table.get_string() s += table.get_string()
self.queue = []
if self.return_only: if self.return_only:
return s return s
else: else:

View file

@ -303,16 +303,19 @@ class ReplApplication(Cmd, ConsoleApplication):
self.set_formatter(formatter_name) self.set_formatter(formatter_name)
try: try:
return super(ReplApplication, self).onecmd(line) try:
except CallErrors, e: return super(ReplApplication, self).onecmd(line)
self.bcall_errors_handler(e) except CallErrors, e:
except BackendNotGiven, e: self.bcall_errors_handler(e)
print >>sys.stderr, 'Error: %s' % str(e) except BackendNotGiven, e:
except NotEnoughArguments, e: print >>sys.stderr, 'Error: %s' % str(e)
print >>sys.stderr, 'Error: not enough arguments. %s' % str(e) except NotEnoughArguments, e:
except (KeyboardInterrupt, EOFError): print >>sys.stderr, 'Error: not enough arguments. %s' % str(e)
# ^C during a command process doesn't exit application. except (KeyboardInterrupt, EOFError):
print '\nAborted.' # ^C during a command process doesn't exit application.
print '\nAborted.'
finally:
self.flush()
def emptyline(self): def emptyline(self):
""" """