[virt-tools-list] [PATCH v2 virt-manager] osdict: handle libosinfo lookup failure

Giuseppe Scrivano gscrivan at redhat.com
Wed Mar 26 12:51:45 UTC 2014


Signed-off-by: Giuseppe Scrivano <gscrivan at redhat.com>
---
OK to include this patch into the series?

 virtinst/osdict.py | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/virtinst/osdict.py b/virtinst/osdict.py
index 13f6670..f37ccab 100644
--- a/virtinst/osdict.py
+++ b/virtinst/osdict.py
@@ -165,9 +165,12 @@ def get_recommended_resources(variant, arch):
 
 
 def lookup_os_by_media(location):
-    media = libosinfo.Media.create_from_location(location, None)
+    try:
+        media = libosinfo.Media.create_from_location(location, None)
+    except:
+        return None
     ret = loader.get_db().guess_os_from_media(media)
-    if len(ret) > 0:
+    if ret and len(ret) > 0:
         return ret[0].get_short_id()
     return None
 
-- 
1.8.5.3




More information about the virt-tools-list mailing list