1
0
Fork 0

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: Stefan Raspl <raspl@linux.vnet.ibm.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
hifive-unleashed-5.1
Stefan Raspl 2018-02-05 13:59:58 +01:00 committed by Paolo Bonzini
parent 3df33a0f34
commit 1cd8bfb1ed
1 changed files with 3 additions and 0 deletions

View File

@ -1176,6 +1176,7 @@ class Tui(object):
Asks for a valid regex and sets the fields filter accordingly.
"""
msg = ''
while True:
self.screen.erase()
self.screen.addstr(0, 0,
@ -1184,6 +1185,7 @@ class Tui(object):
self.screen.addstr(2, 0,
"Current regex: {0}"
.format(self.stats.fields_filter))
self.screen.addstr(5, 0, msg)
self.screen.addstr(3, 0, "New regex: ")
curses.echo()
regex = self.screen.getstr().decode(ENCODING)
@ -1198,6 +1200,7 @@ class Tui(object):
self.refresh_header()
return
except re.error:
msg = '"' + regex + '": Not a valid regular expression'
continue
def show_vm_selection_by_pid(self):