26 Jun 2012 03:07
[PATCH] boottool: Don't fail if can't parse an index entry
Lucas Meneghel Rodrigues <lmr <at> redhat.com>
2012-06-26 01:07:42 GMT
2012-06-26 01:07:42 GMT
Running autotest on a OpenSUSE client (12.1), that is
grub-based, I've found that boottool would fail with:
Traceback (most recent call last):
File "/usr/local/autotest/tools/boottool", line 1994, in <module>
app.run()
File "/usr/local/autotest/tools/boottool", line 1804, in run
result = action_method()
File "/usr/local/autotest/tools/boottool", line 1885, in action_info
entries = self.grubby.get_entries()
File "/usr/local/autotest/tools/boottool", line 1010, in get_entries
entries[entry["index"]] = entry
KeyError: 'index'
Turns out that the code is assuming that we can always
parse an index from the raw grubby output, leading to
the above error when the assumption does not hold true.
Fortunately, this is easy to fix, just handle KeyErrors
and continue on to parse the rest of the split parts
of the raw output.
CC: Cleber Rosa <crosa <at> redhat.com>
Signed-off-by: Lucas Meneghel Rodrigues <lmr <at> redhat.com>
---
client/tools/boottool | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/client/tools/boottool b/client/tools/boottool
index d0e8ce0..794377b 100755
--- a/client/tools/boottool
+++ b/client/tools/boottool
<at> <at> -1006,7 +1006,10 <at> <at> class Grubby(object):
if 'non linux entry' in entry_str:
continue
entry = parse_entry("index" + entry_str)
- entries[entry["index"]] = entry
+ try:
+ entries[entry["index"]] = entry
+ except KeyError:
+ continue
return entries
--
--
1.7.10.2
RSS Feed