diff options
author | Doug Zongker <dougz@android.com> | 2009-06-24 14:34:57 -0700 |
---|---|---|
committer | Doug Zongker <dougz@android.com> | 2009-06-24 14:34:57 -0700 |
commit | 8e2f2b9b207ba4615cb0fb49d29ff65203aad279 (patch) | |
tree | b20903fded7291839f59e63e77f00ccb04d3a905 /tools/releasetools/common.py | |
parent | a4ebcbb929d8f86ff8b89fa05e1ef371cabf7ddc (diff) | |
download | build-8e2f2b9b207ba4615cb0fb49d29ff65203aad279.zip build-8e2f2b9b207ba4615cb0fb49d29ff65203aad279.tar.gz build-8e2f2b9b207ba4615cb0fb49d29ff65203aad279.tar.bz2 |
ignore missing/bad device-specific releasetools modules
If we fail to load the device-specific releasetools module (ie, if -s
is specified but the file is missing), issue an error message but
continue without any device-specific code.
Diffstat (limited to 'tools/releasetools/common.py')
-rw-r--r-- | tools/releasetools/common.py | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/tools/releasetools/common.py b/tools/releasetools/common.py index 033e80e..4174db5 100644 --- a/tools/releasetools/common.py +++ b/tools/releasetools/common.py @@ -432,17 +432,18 @@ class DeviceSpecificParams(object): if self.module is None: path = OPTIONS.device_specific if path is None: return - if os.path.isdir(path): - info = imp.find_module("releasetools", [path]) - else: - d, f = os.path.split(path) - b, x = os.path.splitext(f) - if x == ".py": - f = b - info = imp.find_module(f, [d]) - if not info or info[0] is None: - raise ValueError("unable to find device-specific module") - self.module = imp.load_module("device_specific", *info) + try: + if os.path.isdir(path): + info = imp.find_module("releasetools", [path]) + else: + d, f = os.path.split(path) + b, x = os.path.splitext(f) + if x == ".py": + f = b + info = imp.find_module(f, [d]) + self.module = imp.load_module("device_specific", *info) + except ImportError: + print "unable to load device-specific module; assuming none" def _DoCall(self, function_name, *args, **kwargs): """Call the named function in the device-specific module, passing |