aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorastokes <astokes@ef72aa8b-4018-0410-8976-d6e080ef94d8>2009-06-22 18:42:09 +0000
committerastokes <astokes@ef72aa8b-4018-0410-8976-d6e080ef94d8>2009-06-22 18:42:09 +0000
commite995436c588e3e7af4864cf8a751ee1d4bcc8111 (patch)
treeb1d8da91dbf9b45518fc9510b92c9ae4a27c10f7
parente7e62717a0ef875cf97896b70e8288f4e5eeeff6 (diff)
downloadsos-e995436c588e3e7af4864cf8a751ee1d4bcc8111.tar.gz
fixed all deprecation warnings, using an exception class rather than catching string exceptions
git-svn-id: svn+ssh://svn.fedorahosted.org/svn/sos/trunk@585 ef72aa8b-4018-0410-8976-d6e080ef94d8
-rw-r--r--src/lib/sos/plugins/dhcp.py6
-rw-r--r--src/lib/sos/plugintools.py8
-rwxr-xr-xsrc/lib/sos/policyredhat.py2
3 files changed, 9 insertions, 7 deletions
diff --git a/src/lib/sos/plugins/dhcp.py b/src/lib/sos/plugins/dhcp.py
index 7866f4e9..b7e5cbd9 100644
--- a/src/lib/sos/plugins/dhcp.py
+++ b/src/lib/sos/plugins/dhcp.py
@@ -18,9 +18,9 @@ class dhcp(sos.plugintools.PluginBase):
"""DHCP related information
"""
def checkenabled(self):
- if self.cInfo["policy"].pkgByName("dhcp") or os.path.exists("/etc/rc.d/init.d/dhcpd"):
- return True
- return False
+ self.files ['/etc/rc.d/init.d/dhcpd']
+ self.packages = ['dhcp']
+ return sos.plugintools.PluginBase.checkenabled(self)
def setup(self):
self.addCopySpec("/etc/sysconfig/dhcrelay")
diff --git a/src/lib/sos/plugintools.py b/src/lib/sos/plugintools.py
index e00fa0f0..7272bb96 100644
--- a/src/lib/sos/plugintools.py
+++ b/src/lib/sos/plugintools.py
@@ -35,6 +35,8 @@ import shutil
from stat import *
from time import time
+class PluginException(Exception): pass
+
class PluginBase:
"""
Base class for plugins
@@ -192,8 +194,8 @@ class PluginBase:
self.soslog.log(logging.VERBOSE3, "copying file %s" % srcpath)
try:
tdstpath, abspath = self.__copyFile(srcpath)
- except "AlreadyExists":
- self.soslog.log(logging.DEBUG, "error copying file %s (already exists)" % (srcpath))
+ except PluginException, e:
+ self.soslog.log(logging.DEBUG, "%s: %s" % (srcpath,e))
return
except IOError:
self.soslog.log(logging.VERBOSE2, "error copying file %s (IOError)" % (srcpath))
@@ -225,7 +227,7 @@ class PluginBase:
else:
shutil.copy2(src, new_dir)
else:
- raise "AlreadyExists"
+ raise PluginException('Error copying file: already exists')
abspath = os.path.join(self.cInfo['dstroot'], src.lstrip(os.path.sep))
relpath = sosRelPath(self.cInfo['rptdir'], abspath)
diff --git a/src/lib/sos/policyredhat.py b/src/lib/sos/policyredhat.py
index de0dfa49..dc0a9823 100755
--- a/src/lib/sos/policyredhat.py
+++ b/src/lib/sos/policyredhat.py
@@ -275,7 +275,7 @@ class SosPolicy:
# calculate md5
fp = open(self.report_file, "r")
- self.report_md5 = hashlib.md5(fp.read()).digest()
+ self.report_md5 = hashlib.md5(fp.read()).hexdigest()
fp.close()
self.renameResults("sosreport-%s-%s-%s.tar.bz2" % (self.reportName, time.strftime("%Y%m%d%H%M%S"), self.report_md5[-4:]))