aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/sos/plugins/cluster.py8
-rw-r--r--src/lib/sos/plugintools.py35
-rwxr-xr-xsrc/lib/sos/policyredhat.py8
3 files changed, 21 insertions, 30 deletions
diff --git a/src/lib/sos/plugins/cluster.py b/src/lib/sos/plugins/cluster.py
index 0d31fbc2..f291c077 100644
--- a/src/lib/sos/plugins/cluster.py
+++ b/src/lib/sos/plugins/cluster.py
@@ -37,11 +37,7 @@ class cluster(sos.plugintools.PluginBase):
return sos.plugintools.PluginBase.checkenabled(self)
def has_gfs(self):
- try:
- if len(self.doRegexFindAll(r'^\S+\s+\S+\s+gfs\s+.*$', "/etc/mtab")):
- return True
- except:
- return False
+ return (len(self.doRegexFindAll(r'^\S+\s+\S+\s+gfs\s+.*$', "/etc/mtab")) > 0)
def diagnose(self):
rhelver = self.policy().rhelVersion()
@@ -224,8 +220,6 @@ class cluster(sos.plugintools.PluginBase):
# command somehow failed
return False
- import re
-
rhelver = self.get_redhat_release()
if rhelver == "4":
diff --git a/src/lib/sos/plugintools.py b/src/lib/sos/plugintools.py
index 7272bb96..684cd9eb 100644
--- a/src/lib/sos/plugintools.py
+++ b/src/lib/sos/plugintools.py
@@ -42,12 +42,9 @@ class PluginBase:
Base class for plugins
"""
def __init__(self, pluginname, commons):
- # pylint: disable-msg = E0203
- try:
- len(self.optionList)
- except:
+ if not getattr(self, "optionList", False):
self.optionList = []
- # pylint: enable-msg = E0203
+
self.copiedFiles = []
self.copiedDirs = []
self.executedCommands = []
@@ -113,18 +110,14 @@ class PluginBase:
break
return False
- def doRegexFindAll(self,regex,fname):
+ def doRegexFindAll(self, regex, fname):
''' Return a list of all non overlapping matches in the string(s)
'''
- out=[]
- f=open(fname,'r')
- content=f.read()
- f.close()
- reg=re.compile(regex,re.MULTILINE)
- for i in reg.findall(content):
- out.append(i)
- return out
-
+ try:
+ return re.findall(regex, open(fname, 'r').read(), re.MULTILINE)
+ except: # IOError, AttributeError, etc.
+ return []
+
# Methods for copying files and shelling out
def doCopyFileOrDir(self, srcpath):
# pylint: disable-msg = R0912
@@ -311,14 +304,10 @@ class PluginBase:
self.collectProgs.append( (exe, suggest_filename, root_symlink, timeout) )
def fileGrep(self, regexp, fname):
- results = []
-
- fp = open(fname, "r")
- for line in fp.readlines():
- if re.match(regexp, line):
- results.append(line)
- fp.close()
- return results
+ try:
+ return [l for l in open(fname).readlines() if re.match(regexp, l)]
+ except: # IOError, AttributeError, etc.
+ return []
def mangleCommand(self, exe):
# FIXME: this can be improved
diff --git a/src/lib/sos/policyredhat.py b/src/lib/sos/policyredhat.py
index dc0a9823..26004140 100755
--- a/src/lib/sos/policyredhat.py
+++ b/src/lib/sos/policyredhat.py
@@ -209,6 +209,14 @@ class SosPolicy:
if len(self.reportName) == 0:
self.reportName = localname
+
+ if self.cInfo['cmdlineopts'].customerName:
+ self.reportName = self.cInfo['cmdlineopts'].customerName
+ self.reportName = re.sub(r"[^a-zA-Z.0-9]", "", self.reportName)
+
+ if self.cInfo['cmdlineopts'].ticketNumber:
+ self.ticketNumber = self.cInfo['cmdlineopts'].ticketNumber
+ self.ticketNumber = re.sub(r"[^0-9]", "", self.ticketNumber)
return