From 58620ca4771a5ff214bd0215323c595525452a39 Mon Sep 17 00:00:00 2001 From: David Stygstra Date: Thu, 19 Sep 2013 00:04:20 -0400 Subject: [PATCH] Add Python 2.4 support to modprobe module --- library/system/modprobe | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/library/system/modprobe b/library/system/modprobe index 017b6eaa47..90537c2f79 100755 --- a/library/system/modprobe +++ b/library/system/modprobe @@ -57,9 +57,14 @@ def main(): # Check if module is present try: - with open('/proc/modules') as modules: - present = any(module.startswith(args['name'] + ' ') for module in modules) - except IOError as e: + modules = open('/proc/modules') + present = False + for line in modules: + if line.startswith(args['name'] + ' '): + present = True + break + modules.close() + except IOError, e: module.fail_json(msg=str(e), **args) # Check only; don't modify