From 637bc5c3d62a8ad4bccf9cb567eb43eedc15fa4e Mon Sep 17 00:00:00 2001
From: Daniel Hokka Zakrisson <daniel@hozac.com>
Date: Thu, 14 Feb 2013 12:14:20 +0100
Subject: [PATCH] Fix Python 2.6-isms in sysctl module

---
 sysctl | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/sysctl b/sysctl
index d39cc2035e6..c92df256907 100644
--- a/sysctl
+++ b/sysctl
@@ -161,8 +161,9 @@ def sysctl_check(current_step, **sysctl_args):
     # TODO choose if prefered to use os.access() instead try/catch on open
     if current_step == 'before':
         try:
-            with open(sysctl_args['sysctl_file']) as f: pass
-        except IOError as e:
+            f = open(sysctl_args['sysctl_file'])
+            f.close()
+        except IOError, e:
             return 1, 'unable to open supplied sysctl.conf'
    
     # no smart checks at this step ?
@@ -184,11 +185,12 @@ def sysctl_check(current_step, **sysctl_args):
     if current_step == 'after' and sysctl_args['checks'] in ['after', 'both']:
 
         if sysctl_args['value'] is not None:
-            with open(sysctl_args['key_path'],'r') as f:
-                output = f.read()
-                output = output.strip(' \t\n\r')
-                if output != sysctl_args['value']:
-                    return 1, 'key seems not set to value even after update/sysctl, founded : <%s>, wanted : <%s>' % (output, sysctl_args['value'])
+            f = open(sysctl_args['key_path'],'r')
+            output = f.read()
+            f.close()
+            output = output.strip(' \t\n\r')
+            if output != sysctl_args['value']:
+                return 1, 'key seems not set to value even after update/sysctl, founded : <%s>, wanted : <%s>' % (output, sysctl_args['value'])
         
         return 0, ''