aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sos/policies/ubuntu.py7
1 files changed, 3 insertions, 4 deletions
diff --git a/sos/policies/ubuntu.py b/sos/policies/ubuntu.py
index c841b22b..d0ecae0f 100644
--- a/sos/policies/ubuntu.py
+++ b/sos/policies/ubuntu.py
@@ -2,6 +2,7 @@ from sos import _sos as _
from sos.plugins import UbuntuPlugin, IndependentPlugin
from sos.policies.debian import DebianPolicy, DebianPackageManager
from sos.utilities import shell_out
+from __future__ import with_statement
import os
@@ -19,10 +20,8 @@ class UbuntuPolicy(DebianPolicy):
It returns True or False."""
if os.path.isfile('/etc/lsb-release'):
try:
- fp = open('/etc/lsb-release', 'r')
- if "Ubuntu" in fp.read():
- fp.close()
- return True
+ with open('/etc/lsb-release', 'r') as fp:
+ return "Ubuntu" in fp.read()
except:
return False
return False