diff options
author | Andy Grover <agrover@redhat.com> | 2015-11-16 10:09:30 -0800 |
---|---|---|
committer | Andy Grover <agrover@redhat.com> | 2015-11-16 10:09:30 -0800 |
commit | bddfe573e553b9e6777880e973bc664e018a9414 (patch) | |
tree | 7f5ac4e7585c90bd4f11b5578057b71ab746e613 /rtslib | |
parent | 290738c20213a9fabff1d0a0d8eb726706473aad (diff) | |
download | rtslib-fb-bddfe573e553b9e6777880e973bc664e018a9414.tar.gz |
Handle errors from kmod.modprobe()
If a module fails to load it can throw KmodError. Catch this and convert
to RTSLibError.
Signed-off-by: Andy Grover <agrover@redhat.com>
Diffstat (limited to 'rtslib')
-rw-r--r-- | rtslib/utils.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/rtslib/utils.py b/rtslib/utils.py index 79a4d9d..286dbc1 100644 --- a/rtslib/utils.py +++ b/rtslib/utils.py @@ -382,7 +382,6 @@ def modprobe(module): try: import kmod - kmod.Kmod().modprobe(module) except ImportError: process = subprocess.Popen(("modprobe", module), stdout=subprocess.PIPE, @@ -390,6 +389,12 @@ def modprobe(module): (stdoutdata, stderrdata) = process.communicate() if process.returncode != 0: raise RTSLibError(stderrdata) + return + + try: + kmod.Kmod().modprobe(module) + except kmod.error.KmodError: + raise RTSLibError("Could not load module: %s" % module) def mount_configfs(): if not os.path.ismount("/sys/kernel/config"): |