From e436513dd9001055a50235fa031816f23a63a08b Mon Sep 17 00:00:00 2001 From: shnavid Date: Wed, 18 Jul 2007 09:44:49 +0000 Subject: * added three helpers: pkgDictByName() runlevelByService() and runlevelDefault() git-svn-id: svn+ssh://svn.fedorahosted.org/svn/sos/trunk@212 ef72aa8b-4018-0410-8976-d6e080ef94d8 --- src/lib/sos/policyredhat.py | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/lib/sos/policyredhat.py b/src/lib/sos/policyredhat.py index e31900d7..b3c887f3 100755 --- a/src/lib/sos/policyredhat.py +++ b/src/lib/sos/policyredhat.py @@ -69,6 +69,28 @@ class SosPolicy: return pkg + def pkgDictByName(self, name): + pkgName = self.pkgByName(name) + if pkgName and len(pkgName) > len(name): + return pkgName[len(name)+1:].split("-") + else: + return None + + def runlevelByService(self, name): + ret = [] + try: + for tabs in commands.getoutput("/sbin/chkconfig --list %s" % name).split(): + (runlevel, onoff) = tabs.split(":") + if onoff == "on": + ret.append(int(runlevel)) + except: + pass + return ret + + def runlevelDefault(self): + # FIXME: get this from /etc/inittab + return 3 + def pkgNVRA(self, pkg): fields = pkg.split("-") version, release, arch = fields[-3:] @@ -84,7 +106,7 @@ class SosPolicy: ticketNumber = raw_input("Please enter the case number that you are generating this report for: ") except KeyboardInterrupt: print "" - print + return if len(ticketNumber): namestr = name + "." + ticketNumber -- cgit