summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSol Jerome <sol.jerome@gmail.com>2010-10-17 20:43:16 -0500
committerSol Jerome <sol.jerome@gmail.com>2010-10-17 20:43:16 -0500
commitb056804f3d3e3a2d92dac42062527873255d14c7 (patch)
tree0685c311e66f75064b5f651219a488e6ee4634d8
parentff01b4e6ad3dcf7fdae92adc16c1a3481a37d8db (diff)
downloadbcfg2-b056804f3d3e3a2d92dac42062527873255d14c7.tar.gz
bcfg2-b056804f3d3e3a2d92dac42062527873255d14c7.tar.bz2
bcfg2-b056804f3d3e3a2d92dac42062527873255d14c7.zip
Client Tools: Pylint/PEP8 fixes
Signed-off-by: Sol Jerome <sol.jerome@gmail.com>
-rw-r--r--src/lib/Client/Tools/Action.py23
-rw-r--r--src/lib/Client/Tools/Blast.py5
-rw-r--r--src/lib/Client/Tools/Chkconfig.py8
-rw-r--r--src/lib/Client/Tools/DebInit.py10
-rw-r--r--src/lib/Client/Tools/FreeBSDInit.py1
-rw-r--r--src/lib/Client/Tools/FreeBSDPackage.py3
-rw-r--r--src/lib/Client/Tools/IPS.py5
-rw-r--r--src/lib/Client/Tools/MacPorts.py1
-rw-r--r--src/lib/Client/Tools/POSIX.py13
-rw-r--r--src/lib/Client/Tools/Portage.py8
-rw-r--r--src/lib/Client/Tools/RcUpdate.py4
-rw-r--r--src/lib/Client/Tools/SMF.py17
-rw-r--r--src/lib/Client/Tools/SYSV.py6
-rw-r--r--src/lib/Client/Tools/YUMng.py89
-rw-r--r--src/lib/Client/Tools/launchd.py18
15 files changed, 133 insertions, 78 deletions
diff --git a/src/lib/Client/Tools/Action.py b/src/lib/Client/Tools/Action.py
index 3610d9015..452788f94 100644
--- a/src/lib/Client/Tools/Action.py
+++ b/src/lib/Client/Tools/Action.py
@@ -3,23 +3,34 @@ __revision__ = '$Revision$'
import Bcfg2.Client.Tools
-# <Action timing='pre|post|both' name='name' command='cmd text' when='always|modified'
-# status='ignore|check'/>
-# <PostInstall name='foo'/>
-# => <Action timing='post' when='modified' name='n' command='foo' status='ignore'/>
+"""
+<Action timing='pre|post|both'
+ name='name'
+ command='cmd text'
+ when='always|modified'
+ status='ignore|check'/>
+<PostInstall name='foo'/>
+ => <Action timing='post'
+ when='modified'
+ name='n'
+ command='foo'
+ status='ignore'/>
+"""
+
class Action(Bcfg2.Client.Tools.Tool):
"""Implement Actions"""
name = 'Action'
__handles__ = [('PostInstall', None), ('Action', None)]
__req__ = {'PostInstall': ['name'],
- 'Action':['name', 'timing', 'when', 'command', 'status']}
+ 'Action': ['name', 'timing', 'when', 'command', 'status']}
def RunAction(self, entry):
"""This method handles command execution and status return."""
if not self.setup['dryrun']:
if self.setup['interactive']:
- prompt = 'Run Action %s, %s: (y/N): ' % (entry.get('name'), entry.get('command'))
+ prompt = ('Run Action %s, %s: (y/N): ' %
+ (entry.get('name'), entry.get('command')))
if raw_input(prompt) not in ['y', 'Y']:
return False
if self.setup['servicemode'] == 'build':
diff --git a/src/lib/Client/Tools/Blast.py b/src/lib/Client/Tools/Blast.py
index 737c6924e..4f2891fd6 100644
--- a/src/lib/Client/Tools/Blast.py
+++ b/src/lib/Client/Tools/Blast.py
@@ -2,7 +2,9 @@
"""This provides bcfg2 support for blastwave"""
__revision__ = '$Revision$'
-import Bcfg2.Client.Tools.SYSV, tempfile
+import tempfile
+import Bcfg2.Client.Tools.SYSV
+
class Blast(Bcfg2.Client.Tools.SYSV.SYSV):
"""Support for Blastwave packages"""
@@ -27,7 +29,6 @@ class Blast(Bcfg2.Client.Tools.SYSV.SYSV):
# Install comes from Bcfg2.Client.Tools.PkgTool
# Extra comes from Bcfg2.Client.Tools.Tool
# Remove comes from Bcfg2.Client.Tools.SYSV
-
def FindExtraPackages(self):
"""Pass through to null FindExtra call."""
return []
diff --git a/src/lib/Client/Tools/Chkconfig.py b/src/lib/Client/Tools/Chkconfig.py
index 5dbb7b345..b7227ec3d 100644
--- a/src/lib/Client/Tools/Chkconfig.py
+++ b/src/lib/Client/Tools/Chkconfig.py
@@ -81,7 +81,9 @@ class Chkconfig(Bcfg2.Client.Tools.SvcTool):
self.logger.info("Installing Service %s" % (entry.get('name')))
pass1 = True
if entry.get('status') == 'off':
- rc = self.cmd.run(rcmd % (entry.get('name'), entry.get('status')) + " --level 0123456")[0]
+ rc = self.cmd.run(rcmd % (entry.get('name'),
+ entry.get('status')) + \
+ " --level 0123456")[0]
pass1 = rc == 0
rc = self.cmd.run(rcmd % (entry.get('name'), entry.get('status')))[0]
return pass1 and rc == 0
@@ -93,5 +95,7 @@ class Chkconfig(Bcfg2.Client.Tools.SvcTool):
self.logger.debug('Found active services:')
self.logger.debug(allsrv)
specified = [srv.get('name') for srv in self.getSupportedEntries()]
- return [Bcfg2.Client.XML.Element('Service', type='chkconfig', name=name) \
+ return [Bcfg2.Client.XML.Element('Service',
+ type='chkconfig',
+ name=name) \
for name in allsrv if name not in specified]
diff --git a/src/lib/Client/Tools/DebInit.py b/src/lib/Client/Tools/DebInit.py
index 0185f420c..aee8ffd65 100644
--- a/src/lib/Client/Tools/DebInit.py
+++ b/src/lib/Client/Tools/DebInit.py
@@ -1,16 +1,18 @@
"""Debian Init Support for Bcfg2"""
__revision__ = '$Revision$'
-import glob, os, re
+import glob
+import os
+import re
import Bcfg2.Client.Tools
-
# Debian squeeze and beyond uses a dependecy based boot sequence
DEBIAN_OLD_STYLE_BOOT_SEQUENCE = (
'etch', '4.0',
'lenny', '5.0', '5.0.1', '5.0.2', '5.0.3', '5.0.4', '5.0.4', '5.0.5',
)
+
class DebInit(Bcfg2.Client.Tools.SvcTool):
"""Debian Service Support for Bcfg2."""
name = 'DebInit'
@@ -35,7 +37,9 @@ class DebInit(Bcfg2.Client.Tools.SvcTool):
start_sequence = int(entry.get('sequence'))
kill_sequence = 100 - start_sequence
else:
- self.logger.warning("Your debian version boot sequence is dependency based \"sequence\" attribute wil be ignored.")
+ self.logger.warning("Your debian version boot sequence is "
+ "dependency based \"sequence\" attribute "
+ "will be ignored.")
else:
start_sequence = None
diff --git a/src/lib/Client/Tools/FreeBSDInit.py b/src/lib/Client/Tools/FreeBSDInit.py
index e597a294b..10f0f2e93 100644
--- a/src/lib/Client/Tools/FreeBSDInit.py
+++ b/src/lib/Client/Tools/FreeBSDInit.py
@@ -8,6 +8,7 @@ __revision__ = '$Rev$'
import os
import Bcfg2.Client.Tools
+
class FreeBSDInit(Bcfg2.Client.Tools.SvcTool):
"""FreeBSD service support for Bcfg2."""
name = 'FreeBSDInit'
diff --git a/src/lib/Client/Tools/FreeBSDPackage.py b/src/lib/Client/Tools/FreeBSDPackage.py
index 49cfa5bd2..04c05adaa 100644
--- a/src/lib/Client/Tools/FreeBSDPackage.py
+++ b/src/lib/Client/Tools/FreeBSDPackage.py
@@ -8,6 +8,7 @@ __revision__ = '$Rev$'
import re
import Bcfg2.Client.Tools
+
class FreeBSDPackage(Bcfg2.Client.Tools.PkgTool):
"""The FreeBSD toolset implements package operations and inherits
the rest from Toolset.Toolset."""
@@ -24,7 +25,7 @@ class FreeBSDPackage(Bcfg2.Client.Tools.PkgTool):
pattern = re.compile('(.*)-(\d.*)')
for pkg in packages:
if pattern.match(pkg):
- name = pattern.match(pkg).group(1)
+ name = pattern.match(pkg).group(1)
version = pattern.match(pkg).group(2)
self.installed[name] = version
diff --git a/src/lib/Client/Tools/IPS.py b/src/lib/Client/Tools/IPS.py
index d7d84617f..9afd23143 100644
--- a/src/lib/Client/Tools/IPS.py
+++ b/src/lib/Client/Tools/IPS.py
@@ -1,11 +1,12 @@
"""This is the Bcfg2 support for OpenSolaris packages."""
__revision__ = '$Revision$'
-import Bcfg2.Client.Tools
-
import pkg.client.image as image
import pkg.client.progress as progress
+import Bcfg2.Client.Tools
+
+
class IPS(Bcfg2.Client.Tools.PkgTool):
"""The IPS driver implements OpenSolaris package operations."""
name = 'IPS'
diff --git a/src/lib/Client/Tools/MacPorts.py b/src/lib/Client/Tools/MacPorts.py
index 70285fa3a..23b536451 100644
--- a/src/lib/Client/Tools/MacPorts.py
+++ b/src/lib/Client/Tools/MacPorts.py
@@ -3,6 +3,7 @@ __revision__ = '$Revision$'
import Bcfg2.Client.Tools
+
class MacPorts(Bcfg2.Client.Tools.PkgTool):
"""macports package support."""
name = 'MacPorts'
diff --git a/src/lib/Client/Tools/POSIX.py b/src/lib/Client/Tools/POSIX.py
index 9d37b77d3..a4417297a 100644
--- a/src/lib/Client/Tools/POSIX.py
+++ b/src/lib/Client/Tools/POSIX.py
@@ -44,6 +44,7 @@ def calcPerms(initial, perms):
tempperms |= perm
return tempperms
+
def normUid(entry):
"""
This takes a user name or uid and
@@ -58,6 +59,7 @@ def normUid(entry):
log.error('UID normalization failed for %s' % (entry.get('name')))
return False
+
def normGid(entry):
"""
This takes a group name or gid and
@@ -75,6 +77,7 @@ def normGid(entry):
text_chars = "".join([chr(y) for y in range(32, 127)] + list("\n\r\t\b"))
notrans = string.maketrans("", "")
+
def isString(strng):
"""Returns true if a string contains no binary chars."""
if "\0" in strng:
@@ -85,6 +88,7 @@ def isString(strng):
return len(strng.translate(notrans, text_chars)) == 0
+
class POSIX(Bcfg2.Client.Tools.Tool):
"""POSIX File support code."""
name = 'POSIX'
@@ -161,7 +165,8 @@ class POSIX(Bcfg2.Client.Tools.Tool):
else:
os.unlink(entry.get('name'))
except OSError:
- self.logger.info("Symlink %s cleanup failed" % (entry.get('name')))
+ self.logger.info("Symlink %s cleanup failed" %\
+ (entry.get('name')))
try:
os.symlink(entry.get('to'), entry.get('name'))
return True
@@ -205,7 +210,8 @@ class POSIX(Bcfg2.Client.Tools.Tool):
pruneTrue = True
ex_ents = []
if entry.get('prune', 'false') == 'true' \
- and (entry.tag == 'Directory' or entry.get('type') == 'directory'):
+ and (entry.tag == 'Directory' or
+ entry.get('type') == 'directory'):
# FIXME: need to verify both old and new POSIX types
try:
entries = ['/'.join([entry.get('name'), ent]) \
@@ -217,7 +223,8 @@ class POSIX(Bcfg2.Client.Tools.Tool):
entry.get('name'))
self.logger.debug(ex_ents)
nqtext = entry.get('qtext', '') + '\n'
- nqtext += "Directory %s contains extra entries:" % entry.get('name')
+ nqtext += "Directory %s contains extra entries:" % \
+ entry.get('name')
nqtext += ":".join(ex_ents)
entry.set('qtest', nqtext)
[entry.append(XML.Element('Prune', path=x)) for x in ex_ents]
diff --git a/src/lib/Client/Tools/Portage.py b/src/lib/Client/Tools/Portage.py
index 765e981fe..58d2aad29 100644
--- a/src/lib/Client/Tools/Portage.py
+++ b/src/lib/Client/Tools/Portage.py
@@ -4,9 +4,10 @@ __revision__ = '$Revision$'
import re
import Bcfg2.Client.Tools
+
class Portage(Bcfg2.Client.Tools.PkgTool):
- """The Gentoo toolset implements package and service operations and inherits
- the rest from Toolset.Toolset."""
+ """The Gentoo toolset implements package and service operations and
+ inherits the rest from Toolset.Toolset."""
name = 'Portage'
__execs__ = ['/usr/bin/emerge', '/usr/bin/equery']
__handles__ = [('Package', 'ebuild')]
@@ -47,8 +48,7 @@ class Portage(Bcfg2.Client.Tools.PkgTool):
if self.installed[entry.attrib['name']] == entry.attrib['version']:
if not self.setup['quick'] and \
entry.get('verify', 'true') == 'true':
- output = self.cmd.run \
- ("/usr/bin/equery check '=%s-%s' 2>&1 |grep '!!!' | awk '{print $2}'" \
+ output = self.cmd.run("/usr/bin/equery check '=%s-%s' 2>&1 |grep '!!!' | awk '{print $2}'" \
% (entry.get('name'), entry.get('version')))[1]
if [filename for filename in output \
if filename not in modlist]:
diff --git a/src/lib/Client/Tools/RcUpdate.py b/src/lib/Client/Tools/RcUpdate.py
index a91562c30..159172b78 100644
--- a/src/lib/Client/Tools/RcUpdate.py
+++ b/src/lib/Client/Tools/RcUpdate.py
@@ -87,5 +87,7 @@ class RcUpdate(Bcfg2.Client.Tools.SvcTool):
self.logger.debug('Found active services:')
self.logger.debug(allsrv)
specified = [srv.get('name') for srv in self.getSupportedEntries()]
- return [Bcfg2.Client.XML.Element('Service', type='rc-update', name=name) \
+ return [Bcfg2.Client.XML.Element('Service',
+ type='rc-update',
+ name=name) \
for name in allsrv if name not in specified]
diff --git a/src/lib/Client/Tools/SMF.py b/src/lib/Client/Tools/SMF.py
index 733228d18..f0bc6bd05 100644
--- a/src/lib/Client/Tools/SMF.py
+++ b/src/lib/Client/Tools/SMF.py
@@ -1,15 +1,18 @@
"""SMF support for Bcfg2"""
__revision__ = '$Revision$'
-import glob, os
+import glob
+import os
+
import Bcfg2.Client.Tools
+
class SMF(Bcfg2.Client.Tools.SvcTool):
"""Support for Solaris SMF Services."""
__handles__ = [('Service', 'smf')]
__execs__ = ['/usr/sbin/svcadm', '/usr/bin/svcs']
name = 'SMF'
- __req__ = {'Service':['name', 'status']}
+ __req__ = {'Service': ['name', 'status']}
__ireq__ = {'Service': ['name', 'status', 'FMRI']}
def get_svc_command(self, service, action):
@@ -53,7 +56,8 @@ class SMF(Bcfg2.Client.Tools.SvcTool):
(entry.get("FMRI"), ":".join(files)))
return entry.get('status') == 'on'
else:
- self.logger.debug("No service matching %s" % (entry.get("FMRI")))
+ self.logger.debug("No service matching %s" % \
+ (entry.get("FMRI")))
return entry.get('status') == 'off'
try:
srvdata = self.cmd.run("/usr/bin/svcs -H -o STA %s" % \
@@ -79,7 +83,8 @@ class SMF(Bcfg2.Client.Tools.SvcTool):
os.rename(loc, loc.replace('/S', '/DISABLED.S'))
return True
except OSError:
- self.logger.error("Failed to rename init script %s" % (loc))
+ self.logger.error("Failed to rename init script %s" % \
+ (loc))
return False
else:
cmdrc = self.cmd.run("/usr/sbin/svcadm disable %s" % \
@@ -94,8 +99,8 @@ class SMF(Bcfg2.Client.Tools.SvcTool):
os.rename(loc.replace('/S', '/DISABLED.S'), loc)
cmdrc = 0
except OSError:
- self.logger.debug("Failed to rename %s to %s" \
- % (loc.replace('/S', '/DISABLED.S'), loc))
+ self.logger.debug("Failed to rename %s to %s" % \
+ (loc.replace('/S', '/DISABLED.S'), loc))
cmdrc = 1
else:
srvdata = self.cmd.run("/usr/bin/svcs -H -o STA %s" %
diff --git a/src/lib/Client/Tools/SYSV.py b/src/lib/Client/Tools/SYSV.py
index c2b0eb2cc..b5e1f1c59 100644
--- a/src/lib/Client/Tools/SYSV.py
+++ b/src/lib/Client/Tools/SYSV.py
@@ -2,7 +2,10 @@
"""This provides bcfg2 support for Solaris SYSV packages."""
__revision__ = '$Revision$'
-import tempfile, Bcfg2.Client.Tools, Bcfg2.Client.XML
+import tempfile
+
+import Bcfg2.Client.Tools
+import Bcfg2.Client.XML
noask = '''
@@ -19,6 +22,7 @@ action=nocheck
basedir=default
'''
+
class SYSV(Bcfg2.Client.Tools.PkgTool):
"""Solaris SYSV package support."""
__execs__ = ["/usr/sbin/pkgadd", "/usr/bin/pkginfo"]
diff --git a/src/lib/Client/Tools/YUMng.py b/src/lib/Client/Tools/YUMng.py
index 077d71508..9fc776471 100644
--- a/src/lib/Client/Tools/YUMng.py
+++ b/src/lib/Client/Tools/YUMng.py
@@ -4,7 +4,6 @@ __revision__ = '$Revision$'
import ConfigParser
import copy
import os.path
-import sys
import yum
import yum.packages
import yum.rpmtrans
@@ -21,6 +20,7 @@ try:
except NameError:
from sets import Set as set
+
def build_yname(pkgname, inst):
"""Build yum appropriate package name."""
d = {}
@@ -39,6 +39,7 @@ def build_yname(pkgname, inst):
d['arch'] = inst.get('arch')
return d
+
def short_yname(nevra):
d = nevra.copy()
if 'version' in d:
@@ -49,17 +50,19 @@ def short_yname(nevra):
del d['release']
return d
+
def nevraString(p):
if isinstance(p, yum.packages.PackageObject):
return str(p)
else:
ret = ""
- for i, j in [('epoch','%s:'), ('name','%s'), ('version','-%s'),
- ('release','-%s'), ('arch','.%s')]:
+ for i, j in [('epoch', '%s:'), ('name', '%s'), ('version', '-%s'),
+ ('release', '-%s'), ('arch', '.%s')]:
if i in p:
ret = "%s%s" % (ret, j % p[i])
return ret
+
class Parser(ConfigParser.ConfigParser):
def get(self, section, option, default):
@@ -73,6 +76,7 @@ class Parser(ConfigParser.ConfigParser):
except (ConfigParser.NoOptionError, ConfigParser.NoSectionError):
return default
+
class RPMDisplay(yum.rpmtrans.RPMBaseCallback):
"""We subclass the default RPM transaction callback so that we
can control Yum's verbosity and pipe it through the right logger."""
@@ -83,11 +87,11 @@ class RPMDisplay(yum.rpmtrans.RPMBaseCallback):
self.state = None
self.package = None
- def event(self, package, action, te_current, te_total,
+ def event(self, package, action, te_current, te_total,
ts_current, ts_total):
- """
+ """
@param package: A yum package object or simple string of a package name
- @param action: A yum.constant transaction set state or in the obscure
+ @param action: A yum.constant transaction set state or in the obscure
rpm repackage case it could be the string 'repackaging'
@param te_current: Current number of bytes processed in the transaction
element being processed
@@ -114,6 +118,7 @@ class RPMDisplay(yum.rpmtrans.RPMBaseCallback):
"""Deal with error reporting."""
self.logger.error(msg)
+
class YumDisplay(yum.callbacks.ProcessTransBaseCallback):
"""Class to handle display of what step we are in the Yum transaction
such as downloading packages, etc."""
@@ -141,10 +146,10 @@ class YUMng(Bcfg2.Client.Tools.PkgTool):
def __init__(self, logger, setup, config):
self.yb = yum.YumBase()
Bcfg2.Client.Tools.PkgTool.__init__(self, logger, setup, config)
- self.ignores = [ entry.get('name') for struct in config \
- for entry in struct \
- if entry.tag == 'Path' and \
- entry.get('type') == 'ignore' ]
+ self.ignores = [entry.get('name') for struct in config \
+ for entry in struct \
+ if entry.tag == 'Path' and \
+ entry.get('type') == 'ignore']
self.instance_status = {}
self.extra_instances = []
self.modlists = {}
@@ -168,7 +173,7 @@ class YUMng(Bcfg2.Client.Tools.PkgTool):
except yum.Errors.YumBaseError, e:
self.logger.error("YUMng error: %s" % e)
raise Bcfg2.Client.Tools.toolInstantiationError
-
+
yup = self.yb.doPackageLists(pkgnarrow='updates')
if hasattr(self.yb.rpmdb, 'pkglist'):
yinst = self.yb.rpmdb.pkglist
@@ -201,7 +206,7 @@ class YUMng(Bcfg2.Client.Tools.PkgTool):
in truth
self.doInstall = CP.get(self.name, "installed_action",
"install").lower() == "install"
- self.doUpgrade = CP.get(self.name,
+ self.doUpgrade = CP.get(self.name,
"version_fail_action", "upgrade").lower() == "upgrade"
self.doReinst = CP.get(self.name, "verify_fail_action",
"reinstall").lower() == "reinstall"
@@ -254,7 +259,7 @@ class YUMng(Bcfg2.Client.Tools.PkgTool):
instance = Bcfg2.Client.XML.SubElement(entry, 'Package')
for attrib in list(entry.attrib.keys()):
instance.attrib[attrib] = entry.attrib[attrib]
- instances = [ instance ]
+ instances = [instance]
return instances
@@ -287,18 +292,20 @@ class YUMng(Bcfg2.Client.Tools.PkgTool):
else:
results = verify(po)
self.verifyCache[key] = results
- if not rpmUtils.arch.isMultiLibArch(): return results
+ if not rpmUtils.arch.isMultiLibArch():
+ return results
# Okay deal with a buggy yum multilib and verify
packages = self.yb.rpmdb.searchNevra(name=po.name, epoch=po.epoch,
ver=po.version, rel=po.release) # find all arches of pkg
- if len(packages) == 1:
+ if len(packages) == 1:
return results # No mathcing multilib packages
files = set(po.returnFileEntries()) # Will be the list of common fns
common = {}
for p in packages:
- if p != po: files = files & set(p.returnFileEntries())
+ if p != po:
+ files = files & set(p.returnFileEntries())
for p in packages:
k = (p.name, p.epoch, p.version, p.release, p.arch)
self.logger.debug("Multilib Verify: comparing %s to %s" \
@@ -320,10 +327,11 @@ class YUMng(Bcfg2.Client.Tools.PkgTool):
# this fn had verify problems in all but one of the multilib
# packages. That means its correct in the package that's
# "on top." Therefore, this is a fake verify problem.
- if fn in results: del results[fn]
+ if fn in results:
+ del results[fn]
return results
-
+
def RefreshPackages(self):
"""
Creates self.installed{} which is a dict of installed packages.
@@ -407,12 +415,13 @@ class YUMng(Bcfg2.Client.Tools.PkgTool):
virtPkg = True
self.logger.info("%s appears to be provided by:" \
% entry.get('name'))
- for p in POs: self.logger.info(" %s" % p)
+ for p in POs:
+ self.logger.info(" %s" % p)
for inst in instances:
nevra = build_yname(entry.get('name'), inst)
snevra = short_yname(nevra)
- if nevra in packageCache:
+ if nevra in packageCache:
continue # Ignore duplicate instances
else:
packageCache.append(nevra)
@@ -436,15 +445,16 @@ class YUMng(Bcfg2.Client.Tools.PkgTool):
qtext_versions.append("I(%s)" % nevra)
continue
- if not pkg_checks: continue
+ if not pkg_checks:
+ continue
# Check EVR
if virtPkg:
self.logger.debug(" Not checking version for virtual package")
- _POs = [ po for po in POs ] # Make a copy
+ _POs = [po for po in POs] # Make a copy
elif entry.get('name') == 'gpg-pubkey':
- _POs = [ p for p in POs if p.version == nevra['version'] \
- and p.release == nevra['release'] ]
+ _POs = [p for p in POs if p.version == nevra['version'] \
+ and p.release == nevra['release']]
else:
_POs = self.yb.rpmdb.searchNevra(**snevra)
if len(_POs) == 0:
@@ -452,7 +462,7 @@ class YUMng(Bcfg2.Client.Tools.PkgTool):
stat['version_fail'] = True
# Just chose the first pkg for the error message
self.logger.info(" Wrong version installed. "\
- "Want %s, but have %s" % (nevraString(nevra),
+ "Want %s, but have %s" % (nevraString(nevra),
nevraString(POs[0])))
qtext_versions.append("U(%s)" % str(POs[0]))
continue
@@ -485,7 +495,7 @@ class YUMng(Bcfg2.Client.Tools.PkgTool):
[ig.get('name') for ig in inst.findall('Ignore')] + \
self.ignores
for fn, probs in vResult.items():
- if fn in modlist:
+ if fn in modlist:
self.logger.debug(" %s in modlist, skipping" % fn)
continue
if fn in ignores:
@@ -499,18 +509,19 @@ class YUMng(Bcfg2.Client.Tools.PkgTool):
tmp.append((p.type, p.message))
if tmp != []:
stat['verify'][fn] = tmp
-
+
if stat['verify'] != {}:
stat['verify_fail'] = True
package_fail = True
self.logger.debug(" Verify Problems:")
for fn, probs in stat['verify'].items():
self.logger.debug(" %s" % fn)
- for p in probs: self.logger.debug(" %s: %s" % p)
+ for p in probs:
+ self.logger.debug(" %s: %s" % p)
if len(POs) > 0:
# Is this an install only package? We just look at the first one
- provides = set([ p[0] for p in POs[0].provides ] + [ POs[0].name ])
+ provides = set([p[0] for p in POs[0].provides] + [POs[0].name])
install_only = len(set(self.installOnlyPkgs) & provides) > 0
else:
install_only = False
@@ -530,7 +541,6 @@ class YUMng(Bcfg2.Client.Tools.PkgTool):
return not package_fail
-
def FindExtraInstances(self, entry, POs):
"""
Check for installed instances that are not in the config.
@@ -538,12 +548,13 @@ class YUMng(Bcfg2.Client.Tools.PkgTool):
are no Instances to remove.
"""
- if len(POs) == 0: return None
+ if len(POs) == 0:
+ return None
name = entry.get('name')
- extra_entry = Bcfg2.Client.XML.Element('Package', name=name,
+ extra_entry = Bcfg2.Client.XML.Element('Package', name=name,
type=self.pkgtype)
instances = self._buildInstances(entry)
- _POs = [ p for p in POs ] # Shallow copy
+ _POs = [p for p in POs] # Shallow copy
# Algorythm is sensitive to duplicates, check for them
checked = []
@@ -565,19 +576,19 @@ class YUMng(Bcfg2.Client.Tools.PkgTool):
epoch=p.epoch, name=p.name, version=p.version,
release=p.release, arch=p.arch)
- if _POs == []:
+ if _POs == []:
return None
else:
return extra_entry
def FindExtraPackages(self):
"""Find extra packages."""
- packages = [ e.get('name') for e in self.getSupportedEntries() ]
+ packages = [e.get('name') for e in self.getSupportedEntries()]
extras = []
for p in self.installed.keys():
if p not in packages:
- entry = Bcfg2.Client.XML.Element('Package', name=p,
+ entry = Bcfg2.Client.XML.Element('Package', name=p,
type=self.pkgtype)
for i in self.installed[p]:
inst = Bcfg2.Client.XML.SubElement(entry, 'Instance', \
@@ -608,16 +619,16 @@ class YUMng(Bcfg2.Client.Tools.PkgTool):
rel = yum.misc.keyIdToRPMVer(gpg['timestamp'])
if not (ver == inst.get('version') and rel == inst.get('release')):
self.logger.info("GPG key file %s does not match gpg-pubkey-%s-%s"\
- % (key_file, inst.get('version'),
+ % (key_file, inst.get('version'),
inst.get('release')))
return False
- if not yum.misc.keyInstalled(ts, gpg['keyid'],
+ if not yum.misc.keyInstalled(ts, gpg['keyid'],
gpg['timestamp']) == 0:
result = ts.pgpImportPubkey(yum.misc.procgpgkey(rawkey))
else:
self.logger.debug("gpg-pubkey-%s-%s already installed"\
- % (inst.get('version'),
+ % (inst.get('version'),
inst.get('release')))
return True
diff --git a/src/lib/Client/Tools/launchd.py b/src/lib/Client/Tools/launchd.py
index a8b785016..db6d94c1b 100644
--- a/src/lib/Client/Tools/launchd.py
+++ b/src/lib/Client/Tools/launchd.py
@@ -2,20 +2,23 @@
__revision__ = '$Revision$'
import os
-import Bcfg2.Client.Tools
import popen2
+import Bcfg2.Client.Tools
+
+
class launchd(Bcfg2.Client.Tools.Tool):
"""Support for Mac OS X launchd services."""
__handles__ = [('Service', 'launchd')]
__execs__ = ['/bin/launchctl', '/usr/bin/defaults']
name = 'launchd'
- __req__ = {'Service':['name', 'status']}
+ __req__ = {'Service': ['name', 'status']}
'''
Currently requires the path to the plist to load/unload,
and Name is acually a reverse-fqdn (or the label).
'''
+
def __init__(self, logger, setup, config):
Bcfg2.Client.Tools.Tool.__init__(self, logger, setup, config)
@@ -77,7 +80,6 @@ class launchd(Bcfg2.Client.Tools.Tool):
return 'on'
return False
-
def InstallService(self, entry):
"""Enable or disable launchd item."""
name = entry.get('name')
@@ -95,18 +97,19 @@ class launchd(Bcfg2.Client.Tools.Tool):
"""Remove Extra launchd entries."""
pass
-
-
def FindExtra(self):
"""Find Extra launchd services."""
try:
- allsrv = self.cmd.run("/bin/launchctl list")[1]
+ allsrv = self.cmd.run("/bin/launchctl list")[1]
except IndexError:
allsrv = []
[allsrv.remove(svc) for svc in [entry.get("name") for entry
in self.getSupportedEntries()] if svc in allsrv]
- return [Bcfg2.Client.XML.Element("Service", type='launchd', name=name, status='on') for name in allsrv]
+ return [Bcfg2.Client.XML.Element("Service",
+ type='launchd',
+ name=name,
+ status='on') for name in allsrv]
def BundleUpdated(self, bundle, states):
"""Reload launchd plist."""
@@ -126,4 +129,3 @@ class launchd(Bcfg2.Client.Tools.Tool):
#only if necessary....
self.cmd.run("/bin/launchctl stop %s" % name)
self.cmd.run("/bin/launchctl unload -w %s" % (self.FindPlist(entry)))
-