]> code.ossystems Code Review - openembedded-core.git/commitdiff
wic: Check for external modules
authorDarren Hart <dvhart@linux.intel.com>
Tue, 15 Oct 2013 21:46:24 +0000 (14:46 -0700)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Wed, 16 Oct 2013 12:27:15 +0000 (13:27 +0100)
Since eight unique files import rpm, perform a check at the top level
for the existence of the rpm module print a sensible error message if it
is not. This may be able to be removed if some of the core rpm
dependencies are removed from the mic libs.

Also check for urlgrabber.

This avoids a bracktrace in the event the modules are not installed
which can be very off-putting to would-be users.

Signed-off-by: Darren Hart <dvhart@linux.intel.com>
Cc: Tom Zanussi <tom.zanussi@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
scripts/wic

index 425b665861902e79ddbe6a6bec0c4b347fe4b276..a7221c361070a4ef0a700e522bb9aad5aa11ac44 100755 (executable)
 
 __version__ = "0.1.0"
 
+# Python Standard Library modules
 import os
 import sys
 import optparse
 import logging
 
+# External modules
+try:
+    import rpm
+    import urlgrabber
+except ImportError:
+    print("ERROR: failed to import necessary modules.")
+    print("Please ensure the following modules are installed:")
+    print("\trpm");
+    print("\turlgrabber");
+    sys.exit(1)
+
 scripts_path = os.path.abspath(os.path.dirname(os.path.abspath(sys.argv[0])))
 lib_path = scripts_path + '/lib'
 sys.path = sys.path + [lib_path]