Commit 1cd8bfb1 authored by Stefan Raspl's avatar Stefan Raspl Committed by Paolo Bonzini

tools/kvm_stat: print error on invalid regex

Entering an invalid regular expression did not produce any indication of an
error so far.
To reproduce, press 'f' and enter 'foo(' (with an unescaped bracket).
Signed-off-by: default avatarStefan Raspl <raspl@linux.vnet.ibm.com>
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
parent 3df33a0f
...@@ -1176,6 +1176,7 @@ class Tui(object): ...@@ -1176,6 +1176,7 @@ class Tui(object):
Asks for a valid regex and sets the fields filter accordingly. Asks for a valid regex and sets the fields filter accordingly.
""" """
msg = ''
while True: while True:
self.screen.erase() self.screen.erase()
self.screen.addstr(0, 0, self.screen.addstr(0, 0,
...@@ -1184,6 +1185,7 @@ class Tui(object): ...@@ -1184,6 +1185,7 @@ class Tui(object):
self.screen.addstr(2, 0, self.screen.addstr(2, 0,
"Current regex: {0}" "Current regex: {0}"
.format(self.stats.fields_filter)) .format(self.stats.fields_filter))
self.screen.addstr(5, 0, msg)
self.screen.addstr(3, 0, "New regex: ") self.screen.addstr(3, 0, "New regex: ")
curses.echo() curses.echo()
regex = self.screen.getstr().decode(ENCODING) regex = self.screen.getstr().decode(ENCODING)
...@@ -1198,6 +1200,7 @@ class Tui(object): ...@@ -1198,6 +1200,7 @@ class Tui(object):
self.refresh_header() self.refresh_header()
return return
except re.error: except re.error:
msg = '"' + regex + '": Not a valid regular expression'
continue continue
def show_vm_selection_by_pid(self): def show_vm_selection_by_pid(self):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment