From 97063d26e56b7dccf73ec548e82ccd101d8cbd83 Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Mon, 7 Jun 2010 13:23:13 +0000 Subject: Updated files to match PEP 257 git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@5897 ce84e21b-d406-0410-9b95-82705330c041 --- src/lib/Client/Tools/APT.py | 14 ++++---- src/lib/Client/Tools/Action.py | 16 ++++----- src/lib/Client/Tools/Blast.py | 6 ++-- src/lib/Client/Tools/Chkconfig.py | 10 +++--- src/lib/Client/Tools/DebInit.py | 12 +++---- src/lib/Client/Tools/Encap.py | 10 +++--- src/lib/Client/Tools/FreeBSDInit.py | 4 +-- src/lib/Client/Tools/FreeBSDPackage.py | 6 ++-- src/lib/Client/Tools/IPS.py | 6 ++-- src/lib/Client/Tools/MacPorts.py | 11 +++--- src/lib/Client/Tools/POSIX.py | 48 +++++++++++++------------- src/lib/Client/Tools/Portage.py | 12 +++---- src/lib/Client/Tools/RPMng.py | 58 +++++++++++++++---------------- src/lib/Client/Tools/RcUpdate.py | 18 +++++----- src/lib/Client/Tools/SMF.py | 14 ++++---- src/lib/Client/Tools/SYSV.py | 10 +++--- src/lib/Client/Tools/Upstart.py | 12 +++---- src/lib/Client/Tools/YUMng.py | 15 ++++---- src/lib/Client/Tools/__init__.py | 62 +++++++++++++++++----------------- src/lib/Client/Tools/launchd.py | 18 +++++----- 20 files changed, 182 insertions(+), 180 deletions(-) (limited to 'src/lib') diff --git a/src/lib/Client/Tools/APT.py b/src/lib/Client/Tools/APT.py index 082e51ef6..3f02242ce 100644 --- a/src/lib/Client/Tools/APT.py +++ b/src/lib/Client/Tools/APT.py @@ -1,4 +1,4 @@ -'''This is the bcfg2 support for apt-get''' +"""This is the bcfg2 support for apt-get""" __revision__ = '$Revision$' # suppress apt API warnings @@ -27,8 +27,10 @@ APTGET = '%s/bin/apt-get' % install_path DPKG = '%s/bin/dpkg' % install_path class APT(Bcfg2.Client.Tools.Tool): - '''The Debian toolset implements package and service operations and inherits - the rest from Toolset.Toolset''' + """The Debian toolset implements package and service operations and inherits + the rest from Toolset.Toolset. + + """ name = 'APT' __execs__ = [DEBSUMS, APTGET, DPKG] __handles__ = [('Package', 'deb')] @@ -61,7 +63,7 @@ class APT(Bcfg2.Client.Tools.Tool): self.pkg_cache = apt.cache.Cache() def FindExtra(self): - '''Find extra packages''' + """Find extra packages.""" packages = [entry.get('name') for entry in self.getSupportedEntries()] extras = [(p.name, p.installedVersion) for p in self.pkg_cache if p.isInstalled and p.name not in packages] @@ -109,7 +111,7 @@ class APT(Bcfg2.Client.Tools.Tool): return True def VerifyPackage(self, entry, modlist, checksums=True): - '''Verify package for entry''' + """Verify package for entry.""" if not 'version' in entry.attrib: self.logger.info("Cannot verify unversioned package %s" % (entry.attrib['name'])) @@ -146,7 +148,7 @@ class APT(Bcfg2.Client.Tools.Tool): return True def Remove(self, packages): - '''Deal with extra configuration detected''' + """Deal with extra configuration detected.""" pkgnames = " ".join([pkg.get('name') for pkg in packages]) self.pkg_cache = apt.cache.Cache() if len(packages) > 0: diff --git a/src/lib/Client/Tools/Action.py b/src/lib/Client/Tools/Action.py index c196f5df4..3610d9015 100644 --- a/src/lib/Client/Tools/Action.py +++ b/src/lib/Client/Tools/Action.py @@ -1,4 +1,4 @@ -'''Action driver''' +"""Action driver""" __revision__ = '$Revision$' import Bcfg2.Client.Tools @@ -9,14 +9,14 @@ import Bcfg2.Client.Tools # => class Action(Bcfg2.Client.Tools.Tool): - '''Implement Actions''' + """Implement Actions""" name = 'Action' __handles__ = [('PostInstall', None), ('Action', None)] __req__ = {'PostInstall': ['name'], 'Action':['name', 'timing', 'when', 'command', 'status']} def RunAction(self, entry): - '''This method handles command execution and status return''' + """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')) @@ -40,15 +40,15 @@ class Action(Bcfg2.Client.Tools.Tool): return False def VerifyAction(self, dummy, _): - '''Actions always verify true''' + """Actions always verify true.""" return True def VerifyPostInstall(self, dummy, _): - '''Actions always verify true''' + """Actions always verify true.""" return True def InstallAction(self, entry): - '''Run actions as pre-checks for bundle installation''' + """Run actions as pre-checks for bundle installation.""" if entry.get('timing') != 'post': return self.RunAction(entry) return True @@ -57,7 +57,7 @@ class Action(Bcfg2.Client.Tools.Tool): return self.InstallAction(self, entry) def BundleUpdated(self, bundle, states): - '''Run postinstalls when bundles have been updated''' + """Run postinstalls when bundles have been updated.""" for postinst in bundle.findall("PostInstall"): self.cmd.run(postinst.get('name')) for action in bundle.findall("Action"): @@ -65,7 +65,7 @@ class Action(Bcfg2.Client.Tools.Tool): states[action] = self.RunAction(action) def BundleNotUpdated(self, bundle, states): - '''Run Actions when bundles have not been updated''' + """Run Actions when bundles have not been updated.""" for action in bundle.findall("Action"): if action.get('timing') in ['post', 'both'] and \ action.get('when') != 'modified': diff --git a/src/lib/Client/Tools/Blast.py b/src/lib/Client/Tools/Blast.py index acad1d961..737c6924e 100644 --- a/src/lib/Client/Tools/Blast.py +++ b/src/lib/Client/Tools/Blast.py @@ -1,11 +1,11 @@ # This is the bcfg2 support for blastwave packages (pkg-get) -'''This provides bcfg2 support for blastwave''' +"""This provides bcfg2 support for blastwave""" __revision__ = '$Revision$' import Bcfg2.Client.Tools.SYSV, tempfile class Blast(Bcfg2.Client.Tools.SYSV.SYSV): - '''Support for Blastwave packages''' + """Support for Blastwave packages""" pkgtype = 'blast' pkgtool = ("/opt/csw/bin/pkg-get install %s", ("%s", ["bname"])) name = 'Blast' @@ -29,5 +29,5 @@ class Blast(Bcfg2.Client.Tools.SYSV.SYSV): # Remove comes from Bcfg2.Client.Tools.SYSV def FindExtraPackages(self): - '''Pass through to null FindExtra call''' + """Pass through to null FindExtra call.""" return [] diff --git a/src/lib/Client/Tools/Chkconfig.py b/src/lib/Client/Tools/Chkconfig.py index c95f4c2b3..5dbb7b345 100644 --- a/src/lib/Client/Tools/Chkconfig.py +++ b/src/lib/Client/Tools/Chkconfig.py @@ -1,7 +1,7 @@ # This is the bcfg2 support for chkconfig # $Id$ -'''This is chkconfig support''' +"""This is chkconfig support.""" __revision__ = '$Revision$' import Bcfg2.Client.Tools @@ -9,7 +9,7 @@ import Bcfg2.Client.XML class Chkconfig(Bcfg2.Client.Tools.SvcTool): - '''Chkconfig support for Bcfg2''' + """Chkconfig support for Bcfg2.""" name = 'Chkconfig' __execs__ = ['/sbin/chkconfig'] __handles__ = [('Service', 'chkconfig')] @@ -19,7 +19,7 @@ class Chkconfig(Bcfg2.Client.Tools.SvcTool): return "/sbin/service %s %s" % (service.get('name'), action) def VerifyService(self, entry, _): - '''Verify Service status for entry''' + """Verify Service status for entry.""" try: cmd = "/sbin/chkconfig --list %s " % (entry.get('name')) raw = self.cmd.run(cmd)[1] @@ -75,7 +75,7 @@ class Chkconfig(Bcfg2.Client.Tools.SvcTool): return status def InstallService(self, entry): - '''Install Service entry''' + """Install Service entry.""" rcmd = "/sbin/chkconfig %s %s" self.cmd.run("/sbin/chkconfig --add %s"%(entry.attrib['name'])) self.logger.info("Installing Service %s" % (entry.get('name'))) @@ -87,7 +87,7 @@ class Chkconfig(Bcfg2.Client.Tools.SvcTool): return pass1 and rc == 0 def FindExtra(self): - '''Locate extra chkconfig Services''' + """Locate extra chkconfig Services.""" allsrv = [line.split()[0] for line in \ self.cmd.run("/sbin/chkconfig --list|grep :on")[1]] self.logger.debug('Found active services:') diff --git a/src/lib/Client/Tools/DebInit.py b/src/lib/Client/Tools/DebInit.py index 9bf8bb048..9df8bb127 100644 --- a/src/lib/Client/Tools/DebInit.py +++ b/src/lib/Client/Tools/DebInit.py @@ -1,11 +1,11 @@ -'''Debian Init Support for Bcfg2''' +"""Debian Init Support for Bcfg2""" __revision__ = '$Revision$' import glob, os, re import Bcfg2.Client.Tools class DebInit(Bcfg2.Client.Tools.SvcTool): - '''Debian Service Support for Bcfg2''' + """Debian Service Support for Bcfg2.""" name = 'DebInit' __execs__ = ['/usr/sbin/update-rc.d', '/usr/sbin/invoke-rc.d'] __handles__ = [('Service', 'deb')] @@ -14,7 +14,7 @@ class DebInit(Bcfg2.Client.Tools.SvcTool): # implement entry (Verify|Install) ops def VerifyService(self, entry, _): - '''Verify Service status for entry''' + """Verify Service status for entry.""" rawfiles = glob.glob("/etc/rc*.d/[SK]*%s" % (entry.get('name'))) files = [] if entry.get('sequence'): @@ -52,7 +52,7 @@ class DebInit(Bcfg2.Client.Tools.SvcTool): return False def InstallService(self, entry): - '''Install Service for entry''' + """Install Service for entry.""" self.logger.info("Installing Service %s" % (entry.get('name'))) try: os.stat('/etc/init.d/%s' % entry.get('name')) @@ -76,7 +76,7 @@ class DebInit(Bcfg2.Client.Tools.SvcTool): return cmdrc == 0 def FindExtra(self): - '''Find Extra Debian Service Entries''' + """Find Extra Debian Service entries.""" specified = [entry.get('name') for entry in self.getSupportedEntries()] extra = [] for name in [self.svcre.match(fname).group('name') for fname in @@ -88,7 +88,7 @@ class DebInit(Bcfg2.Client.Tools.SvcTool): in extra] def Remove(self, _): - '''Remove extra service entries''' + """Remove extra service entries.""" # Extra service removal is nonsensical # Extra services need to be reflected in the config return diff --git a/src/lib/Client/Tools/Encap.py b/src/lib/Client/Tools/Encap.py index d547dee98..92062a750 100644 --- a/src/lib/Client/Tools/Encap.py +++ b/src/lib/Client/Tools/Encap.py @@ -1,4 +1,4 @@ -'''Bcfg2 Support for Encap Packages''' +"""Bcfg2 Support for Encap Packages""" __revision__ = '$Revision$' @@ -7,7 +7,7 @@ import re import Bcfg2.Client.Tools class Encap(Bcfg2.Client.Tools.PkgTool): - '''Support for Encap packages''' + """Support for Encap packages.""" name = 'Encap' __execs__ = ['/usr/local/bin/epkg'] __handles__ = [('Package', 'encap')] @@ -20,7 +20,7 @@ class Encap(Bcfg2.Client.Tools.PkgTool): # method will do the installation stuff for you def RefreshPackages(self): - '''Try to find encap packages''' + """Try to find encap packages.""" self.installed = {} for pkg in glob.glob("/usr/local/encap/*"): match = self.splitter.match(pkg) @@ -32,7 +32,7 @@ class Encap(Bcfg2.Client.Tools.PkgTool): self.logger.debug("%s" % list(self.installed.keys())) def VerifyPackage(self, entry, _): - '''Verify Package status for entry''' + """Verify Package status for entry.""" if not entry.get('version'): self.logger.info("Insufficient information of Package %s; cannot Verify" % entry.get('name')) return False @@ -47,7 +47,7 @@ class Encap(Bcfg2.Client.Tools.PkgTool): # Can use the FindExtraPackages method from Bcfg2.Client.Tools.PkgTool def RemovePackages(self, packages): - '''Deal with extra configuration detected''' + """Deal with extra configuration detected.""" names = " ".join([pkg.get('name') for pkg in packages]) self.logger.info("Removing packages: %s" % (names)) self.cmd.run("/usr/local/bin/epkg -l -q -r %s" % (names)) diff --git a/src/lib/Client/Tools/FreeBSDInit.py b/src/lib/Client/Tools/FreeBSDInit.py index cc6a76279..e597a294b 100644 --- a/src/lib/Client/Tools/FreeBSDInit.py +++ b/src/lib/Client/Tools/FreeBSDInit.py @@ -1,4 +1,4 @@ -'''FreeBSD Init Support for Bcfg2''' +"""FreeBSD Init Support for Bcfg2.""" __revision__ = '$Rev$' # TODO @@ -9,7 +9,7 @@ import os import Bcfg2.Client.Tools class FreeBSDInit(Bcfg2.Client.Tools.SvcTool): - '''FreeBSD Service Support for Bcfg2''' + """FreeBSD service support for Bcfg2.""" name = 'FreeBSDInit' __handles__ = [('Service', 'freebsd')] __req__ = {'Service': ['name', 'status']} diff --git a/src/lib/Client/Tools/FreeBSDPackage.py b/src/lib/Client/Tools/FreeBSDPackage.py index dbd32a122..49cfa5bd2 100644 --- a/src/lib/Client/Tools/FreeBSDPackage.py +++ b/src/lib/Client/Tools/FreeBSDPackage.py @@ -1,4 +1,4 @@ -'''This is the bcfg2 tool for the FreeBSD package system.''' +"""This is the Bcfg2 tool for the FreeBSD package system.""" __revision__ = '$Rev$' # TODO @@ -9,8 +9,8 @@ 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''' + """The FreeBSD toolset implements package operations and inherits + the rest from Toolset.Toolset.""" name = 'FreeBSDPackage' __execs__ = ['/usr/sbin/pkg_add', '/usr/sbin/pkg_info'] __handles__ = [('Package', 'freebsdpkg')] diff --git a/src/lib/Client/Tools/IPS.py b/src/lib/Client/Tools/IPS.py index fa8388809..68bb1e300 100644 --- a/src/lib/Client/Tools/IPS.py +++ b/src/lib/Client/Tools/IPS.py @@ -1,4 +1,4 @@ -'''This is the bcfg2 support for OpenSolaris pkg''' +"""This is the Bcfg2 support for OpenSolaris packages.""" __revision__ = '$Revision$' import Bcfg2.Client.Tools @@ -7,7 +7,7 @@ import pkg.client.image as image import pkg.client.progress as progress class IPS(Bcfg2.Client.Tools.PkgTool): - '''The IPS driver implements OpenSolaris package operations''' + """The IPS driver implements OpenSolaris package operations.""" name = 'IPS' pkgtype = 'ips' conflicts = ['SYSV'] @@ -36,7 +36,7 @@ class IPS(Bcfg2.Client.Tools.PkgTool): self.pending_upgrades.add(pname) def VerifyPackage(self, entry, modlist): - '''Verify package for entry''' + """Verify package for entry.""" pname = entry.get('name') if not 'version' in entry.attrib: self.logger.info("Cannot verify unversioned package %s" % (pname)) diff --git a/src/lib/Client/Tools/MacPorts.py b/src/lib/Client/Tools/MacPorts.py index f398c73ed..0b486850f 100644 --- a/src/lib/Client/Tools/MacPorts.py +++ b/src/lib/Client/Tools/MacPorts.py @@ -1,11 +1,10 @@ -# This is the bcfg2 support for macports packages -'''This provides bcfg2 support for macports packages''' +"""This provides Bcfg2 support for macports packages.""" __revision__ = '$Revision$' import Bcfg2.Client.Tools class MacPorts(Bcfg2.Client.Tools.PkgTool): - '''macports package support''' + """macports package support.""" name = 'MacPorts' __execs__ = ["/opt/local/bin/port"] __handles__ = [('Package', 'macport')] @@ -19,7 +18,7 @@ class MacPorts(Bcfg2.Client.Tools.PkgTool): self.RefreshPackages() def RefreshPackages(self): - '''Refresh memory hashes of packages''' + """Refresh memory hashes of packages.""" pkgcache = self.cmd.run("/opt/local/bin/port installed")[1] self.installed = {} for pkg in pkgcache: @@ -31,7 +30,7 @@ class MacPorts(Bcfg2.Client.Tools.PkgTool): self.installed[pkgname] = version def VerifyPackage(self, entry, modlist): - '''Verify Package status for entry''' + """Verify Package status for entry.""" if not 'version' in entry.attrib: self.logger.info("Cannot verify unversioned package %s" % (entry.attrib['name'])) @@ -51,7 +50,7 @@ class MacPorts(Bcfg2.Client.Tools.PkgTool): return False def RemovePackages(self, packages): - '''Remove extra packages''' + """Remove extra packages.""" names = [pkg.get('name') for pkg in packages] self.logger.info("Removing packages: %s" % " ".join(names)) self.cmd.run("/opt/local/bin/port uninstall %s" % \ diff --git a/src/lib/Client/Tools/POSIX.py b/src/lib/Client/Tools/POSIX.py index 457ca7edd..19dd34b1a 100644 --- a/src/lib/Client/Tools/POSIX.py +++ b/src/lib/Client/Tools/POSIX.py @@ -1,4 +1,4 @@ -'''All POSIX Type client support for Bcfg2''' +"""All POSIX Type client support for Bcfg2.""" __revision__ = '$Revision$' from datetime import datetime @@ -27,7 +27,7 @@ device_map = {'block': stat.S_IFBLK, def calcPerms(initial, perms): - '''This compares ondisk permissions with specified ones''' + """This compares ondisk permissions with specified ones.""" pdisp = [{1:S_ISVTX, 2:S_ISGID, 4:S_ISUID}, {1:S_IXUSR, 2:S_IWUSR, 4:S_IRUSR}, {1:S_IXGRP, 2:S_IWGRP, 4:S_IRGRP}, @@ -43,10 +43,10 @@ def calcPerms(initial, perms): return tempperms def normUid(entry): - ''' + """ This takes a user name or uid and - returns the corresponding uid or False - ''' + returns the corresponding uid or False. + """ try: try: return int(entry.get('owner')) @@ -57,10 +57,10 @@ def normUid(entry): return False def normGid(entry): - ''' + """ This takes a group name or gid and - returns the corresponding gid or False - ''' + returns the corresponding gid or False. + """ try: try: return int(entry.get('group')) @@ -74,7 +74,7 @@ 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''' + """Returns true if a string contains no binary chars.""" if "\0" in strng: return False @@ -84,7 +84,7 @@ def isString(strng): return len(strng.translate(notrans, text_chars)) == 0 class POSIX(Bcfg2.Client.Tools.Tool): - '''POSIX File support code''' + """POSIX File support code.""" name = 'POSIX' __handles__ = [('ConfigFile', None), ('Directory', None), @@ -112,7 +112,7 @@ class POSIX(Bcfg2.Client.Tools.Tool): max_copies = setup['max_copies'] def canInstall(self, entry): - '''Check if entry is complete for installation''' + """Check if entry is complete for installation.""" if Bcfg2.Client.Tools.Tool.canInstall(self, entry): if (entry.tag, entry.text, entry.get('empty', 'false')) == \ ('ConfigFile', None, 'false'): @@ -122,7 +122,7 @@ class POSIX(Bcfg2.Client.Tools.Tool): return False def VerifySymLink(self, entry, _): - '''Verify SymLink Entry''' + """Verify SymLink Entry.""" try: sloc = os.readlink(entry.get('name')) if sloc == entry.get('to'): @@ -140,7 +140,7 @@ class POSIX(Bcfg2.Client.Tools.Tool): return False def InstallSymLink(self, entry): - '''Install SymLink Entry''' + """Install SymLink entry.""" self.logger.info("Installing Symlink %s" % (entry.get('name'))) if os.path.lexists(entry.get('name')): try: @@ -167,7 +167,7 @@ class POSIX(Bcfg2.Client.Tools.Tool): return False def VerifyDirectory(self, entry, modlist): - '''Verify Directory Entry''' + """Verify Directory entry.""" while len(entry.get('perms', '')) < 4: entry.set('perms', '0' + entry.get('perms', '')) try: @@ -258,7 +258,7 @@ class POSIX(Bcfg2.Client.Tools.Tool): return pTrue and pruneTrue def InstallDirectory(self, entry): - '''Install Directory Entry''' + """Install Directory entry.""" self.logger.info("Installing Directory %s" % (entry.get('name'))) try: fmode = os.lstat(entry.get('name')) @@ -326,7 +326,7 @@ class POSIX(Bcfg2.Client.Tools.Tool): return self.InstallPermissions(entry) def VerifyhardLink(self, entry, _): - '''Verify HardLink Entry''' + """Verify HardLink entry.""" try: if os.path.samefile(entry.get('name'), entry.get('to')): return True @@ -344,7 +344,7 @@ class POSIX(Bcfg2.Client.Tools.Tool): return False def InstallhardLink(self, entry): - '''Install HardLink Entry''' + """Install HardLink entry.""" self.logger.info("Installing Hardlink %s" % (entry.get('name'))) if os.path.lexists(entry.get('name')): try: @@ -370,11 +370,11 @@ class POSIX(Bcfg2.Client.Tools.Tool): return False def VerifyPermissions(self, entry, _): - '''Verify Permissions entry''' + """Verify Permissions entry""" return self.VerifyDirectory(entry, _) def InstallPermissions(self, entry): - '''Install POSIX Permissions''' + """Install POSIX permissions""" try: os.chown(entry.get('name'), normUid(entry), normGid(entry)) os.chmod(entry.get('name'), calcPerms(S_IFDIR, entry.get('perms'))) @@ -385,7 +385,7 @@ class POSIX(Bcfg2.Client.Tools.Tool): return False def Verifydevice(self, entry, _): - '''Verify device entry''' + """Verify device entry.""" try: # check for file existence filestat = os.stat(entry.get('name')) @@ -428,7 +428,7 @@ class POSIX(Bcfg2.Client.Tools.Tool): return False def Installdevice(self, entry): - '''Install device entries''' + """Install device entries.""" try: # check for existing paths and remove them filestat = os.lstat(entry.get('name')) @@ -461,7 +461,7 @@ class POSIX(Bcfg2.Client.Tools.Tool): return False def Verifynonexistent(self, entry, _): - '''Verify nonexistent entry''' + """Verify nonexistent entry.""" # return true if path does _not_ exist return not os.path.lexists(entry.get('name')) @@ -496,7 +496,7 @@ class POSIX(Bcfg2.Client.Tools.Tool): self.logger.error("Failed to read %s: %s" % (error.filename, error.strerror)) def VerifyConfigFile(self, entry, _): - '''Install ConfigFile Entry''' + """Install ConfigFile entry.""" # configfile verify is permissions check + content check permissionStatus = self.VerifyDirectory(entry, _) tbin = False @@ -580,7 +580,7 @@ class POSIX(Bcfg2.Client.Tools.Tool): return contentStatus and permissionStatus def InstallConfigFile(self, entry): - '''Install ConfigFile Entry''' + """Install ConfigFile entry.""" self.logger.info("Installing ConfigFile %s" % (entry.get('name'))) parent = "/".join(entry.get('name').split('/')[:-1]) diff --git a/src/lib/Client/Tools/Portage.py b/src/lib/Client/Tools/Portage.py index d87fc30d4..2b1d7c1a5 100644 --- a/src/lib/Client/Tools/Portage.py +++ b/src/lib/Client/Tools/Portage.py @@ -1,12 +1,12 @@ -'''This is the bcfg2 tool for the Gentoo Portage system.''' +"""This is the Bcfg2 tool for the Gentoo Portage system.""" __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'] __important__ = ['/etc/make.conf'] @@ -23,7 +23,7 @@ class Portage(Bcfg2.Client.Tools.PkgTool): self.RefreshPackages() def RefreshPackages(self): - '''Refresh memory hashes of packages''' + """Refresh memory hashes of packages.""" ret, cache = self.cmd.run("equery -q list") if ret == 2: cache = self.cmd.run("equery -q list '*'")[1] @@ -38,7 +38,7 @@ class Portage(Bcfg2.Client.Tools.PkgTool): self.logger.info("Failed to parse pkg name %s" % pkg) def VerifyPackage(self, entry, modlist): - '''Verify package for entry''' + """Verify package for entry.""" if not 'version' in entry.attrib: self.logger.info("Cannot verify unversioned package %s" % (entry.attrib['name'])) @@ -61,7 +61,7 @@ class Portage(Bcfg2.Client.Tools.PkgTool): return False def RemovePackages(self, packages): - '''Deal with extra configuration detected''' + """Deal with extra configuration detected.""" pkgnames = " ".join([pkg.get('name') for pkg in packages]) if len(packages) > 0: self.logger.info('Removing packages:') diff --git a/src/lib/Client/Tools/RPMng.py b/src/lib/Client/Tools/RPMng.py index 06792ef13..7caa9c2e4 100644 --- a/src/lib/Client/Tools/RPMng.py +++ b/src/lib/Client/Tools/RPMng.py @@ -1,4 +1,4 @@ -'''Bcfg2 Support for RPMS''' +"""Bcfg2 Support for RPMS""" __revision__ = '$Revision$' @@ -15,7 +15,7 @@ except NameError: from sets import Set as set class RPMng(Bcfg2.Client.Tools.PkgTool): - '''Support for RPM packages''' + """Support for RPM packages.""" name = 'RPMng' __execs__ = ['/bin/rpm', '/var/lib/rpm'] @@ -137,7 +137,7 @@ class RPMng(Bcfg2.Client.Tools.PkgTool): def RefreshPackages(self): - ''' + """ Creates self.installed{} which is a dict of installed packages. The dict items are lists of nevra dicts. This loosely matches the @@ -151,7 +151,7 @@ class RPMng(Bcfg2.Client.Tools.PkgTool): {'name':'foo', 'epoch':None, 'version':'1', 'release':2, 'arch':'x86_64'} ] - ''' + """ self.installed = {} refresh_ts = rpmtools.rpmtransactionset() # Don't bother with signature checks at this stage. The GPG keys might @@ -169,7 +169,7 @@ class RPMng(Bcfg2.Client.Tools.PkgTool): del refresh_ts def VerifyPackage(self, entry, modlist, pinned_version=None): - ''' + """ Verify Package status for entry. Performs the following: - Checks for the presence of required Package Instances. @@ -193,7 +193,7 @@ class RPMng(Bcfg2.Client.Tools.PkgTool): extra_instances = [ , ..... ] Constructs the text prompts for interactive mode. - ''' + """ instances = [inst for inst in entry if inst.tag == 'Instance' or inst.tag == 'Package'] if instances == []: # We have an old style no Instance entry. Convert it to new style. @@ -446,12 +446,13 @@ class RPMng(Bcfg2.Client.Tools.PkgTool): return True def RemovePackages(self, packages): - ''' + """ Remove specified entries. packages is a list of Package Entries with Instances generated by FindExtraPackages(). - ''' + + """ self.logger.debug('Running RPMng.RemovePackages()') pkgspec_list = [] @@ -517,12 +518,13 @@ class RPMng(Bcfg2.Client.Tools.PkgTool): self.extra = self.FindExtraPackages() def FixInstance(self, instance, inst_status): - ''' + """" Control if a reinstall of a package happens or not based on the results from RPMng.VerifyPackage(). Return True to reinstall, False to not reintstall. - ''' + + """ fix = False if inst_status.get('installed', False) == False: @@ -575,7 +577,7 @@ class RPMng(Bcfg2.Client.Tools.PkgTool): return fix def Install(self, packages, states): - ''' + """ Try and fix everything that RPMng.VerifyPackages() found wrong for each Package Entry. This can result in individual RPMs being installed (for the first time), reinstalled, deleted, downgraded @@ -591,7 +593,8 @@ class RPMng(Bcfg2.Client.Tools.PkgTool): of a package. - Each package will be added to self.modified[] if its states{} entry is set to True. - ''' + + """ self.logger.info('Runing RPMng.Install()') install_only_pkgs = [] @@ -726,9 +729,7 @@ class RPMng(Bcfg2.Client.Tools.PkgTool): self.modified.append(entry) def canInstall(self, entry): - ''' - test if entry has enough information to be installed - ''' + """Test if entry has enough information to be installed.""" if not self.handlesEntry(entry): return False @@ -800,7 +801,7 @@ class RPMng(Bcfg2.Client.Tools.PkgTool): return True def canVerify(self, entry): - ''' + """ Test if entry has enough information to be verified. Three types of entries are checked. @@ -810,7 +811,8 @@ class RPMng(Bcfg2.Client.Tools.PkgTool): Also the old style entries get modified after the first VerifyPackage() run, so there needs to be a second test. - ''' + + """ if not self.handlesEntry(entry): return False @@ -879,9 +881,7 @@ class RPMng(Bcfg2.Client.Tools.PkgTool): return True def FindExtraPackages(self): - ''' - Find extra packages - ''' + """Find extra packages.""" packages = [entry.get('name') for entry in self.getSupportedEntries()] extras = [] @@ -904,11 +904,12 @@ class RPMng(Bcfg2.Client.Tools.PkgTool): def FindExtraInstances(self, pkg_entry, installed_entry): - ''' + """ Check for installed instances that are not in the config. Return a Package Entry with Instances to remove, or None if there are no Instances to remove. - ''' + + """ name = pkg_entry.get('name') extra_entry = Bcfg2.Client.XML.Element('Package', name=name, type=self.pkgtype) instances = [inst for inst in pkg_entry if inst.tag == 'Instance' or inst.tag == 'Package'] @@ -957,9 +958,7 @@ class RPMng(Bcfg2.Client.Tools.PkgTool): return extra_entry def str_evra(self, instance): - ''' - Convert evra dict entries to a string. - ''' + """Convert evra dict entries to a string.""" if instance.get('epoch', '*') in ['*', None]: return '%s-%s.%s' % (instance.get('version', '*'), instance.get('release', '*'), @@ -983,9 +982,7 @@ class RPMng(Bcfg2.Client.Tools.PkgTool): return False def inst_evra_equal(self, config_entry, installed_entry): - ''' - Compare new style instance to installed entry. - ''' + """Compare new style instance to installed entry.""" if config_entry.get('epoch', None) != None: epoch = int(config_entry.get('epoch')) @@ -1004,12 +1001,13 @@ class RPMng(Bcfg2.Client.Tools.PkgTool): return False def getinstalledgpg(self): - ''' + """ Create a list of installed GPG key IDs. The pgp-pubkey package version is the least significant 4 bytes (big-endian) of the key ID which is good enough for our purposes. - ''' + + """ init_ts = rpmtools.rpmtransactionset() init_ts.setVSFlags(rpm._RPMVSF_NODIGESTS|rpm._RPMVSF_NOSIGNATURES) gpg_hdrs = rpmtools.getheadersbykeyword(init_ts, **{'name':'gpg-pubkey'}) diff --git a/src/lib/Client/Tools/RcUpdate.py b/src/lib/Client/Tools/RcUpdate.py index e59a4a28d..a91562c30 100644 --- a/src/lib/Client/Tools/RcUpdate.py +++ b/src/lib/Client/Tools/RcUpdate.py @@ -1,4 +1,4 @@ -'''This is rc-update support''' +"""This is rc-update support.""" __revision__ = '$Revision$' import os @@ -7,17 +7,18 @@ import Bcfg2.Client.XML class RcUpdate(Bcfg2.Client.Tools.SvcTool): - '''RcUpdate support for Bcfg2''' + """RcUpdate support for Bcfg2.""" name = 'RcUpdate' __execs__ = ['/sbin/rc-update', '/bin/rc-status'] __handles__ = [('Service', 'rc-update')] __req__ = {'Service': ['name', 'status']} def VerifyService(self, entry, _): - ''' + """ Verify Service status for entry. Assumes we run in the "default" runlevel. - ''' + + """ # check if service is enabled cmd = '/sbin/rc-update show default | grep %s' rc = self.cmd.run(cmd % entry.get('name'))[0] @@ -51,10 +52,11 @@ class RcUpdate(Bcfg2.Client.Tools.SvcTool): return True def InstallService(self, entry): - ''' + """ Install Service entry - In supervised mode we also take care it's (not) running - ''' + In supervised mode we also take care it's (not) running. + + """ self.logger.info('Installing Service %s' % entry.get('name')) if entry.get('status') == 'on': # make sure it's running if in supervised mode @@ -79,7 +81,7 @@ class RcUpdate(Bcfg2.Client.Tools.SvcTool): return False def FindExtra(self): - '''Locate extra rc-update Services''' + """Locate extra rc-update services.""" cmd = '/bin/rc-status -s | grep started' allsrv = [line.split()[0] for line in self.cmd.run(cmd)[1]] self.logger.debug('Found active services:') diff --git a/src/lib/Client/Tools/SMF.py b/src/lib/Client/Tools/SMF.py index cdf1a052b..733228d18 100644 --- a/src/lib/Client/Tools/SMF.py +++ b/src/lib/Client/Tools/SMF.py @@ -1,11 +1,11 @@ -'''SMF support for Bcfg2''' +"""SMF support for Bcfg2""" __revision__ = '$Revision$' import glob, os import Bcfg2.Client.Tools class SMF(Bcfg2.Client.Tools.SvcTool): - '''Support for Solaris SMF Services''' + """Support for Solaris SMF Services.""" __handles__ = [('Service', 'smf')] __execs__ = ['/usr/sbin/svcadm', '/usr/bin/svcs'] name = 'SMF' @@ -24,7 +24,7 @@ class SMF(Bcfg2.Client.Tools.SvcTool): return "/usr/sbin/svcadm enable %s" % (service.get('FMRI')) def GetFMRI(self, entry): - '''Perform FMRI resolution for service''' + """Perform FMRI resolution for service.""" if not 'FMRI' in entry.attrib: name = self.cmd.run("/usr/bin/svcs -H -o FMRI %s 2>/dev/null" % \ entry.get('name'))[1] @@ -38,7 +38,7 @@ class SMF(Bcfg2.Client.Tools.SvcTool): return True def VerifyService(self, entry, _): - '''Verify SMF Service Entry''' + """Verify SMF Service entry.""" if not self.GetFMRI(entry): self.logger.error("smf service %s doesn't have FMRI set" % \ entry.get('name')) @@ -68,7 +68,7 @@ class SMF(Bcfg2.Client.Tools.SvcTool): return srvdata[0] in ['OFF', 'UN', 'MNT', 'DIS', 'DGD'] def InstallService(self, entry): - '''Install SMF Service Entry''' + """Install SMF Service entry.""" self.logger.info("Installing Service %s" % (entry.get('name'))) if entry.get('status') == 'off': if entry.get("FMRI").startswith('lrc'): @@ -109,13 +109,13 @@ class SMF(Bcfg2.Client.Tools.SvcTool): return cmdrc == 0 def Remove(self, svcs): - '''Remove Extra SMF entries''' + """Remove Extra SMF entries.""" # Extra service entry removal is nonsensical # Extra service entries should be reflected in config, even if disabled pass def FindExtra(self): - '''Find Extra SMF Services''' + """Find Extra SMF Services.""" allsrv = [name for name, version in \ [srvc.split() for srvc in self.cmd.run("/usr/bin/svcs -a -H -o FMRI,STATE")[1]] diff --git a/src/lib/Client/Tools/SYSV.py b/src/lib/Client/Tools/SYSV.py index 8a9af9645..20e13c177 100644 --- a/src/lib/Client/Tools/SYSV.py +++ b/src/lib/Client/Tools/SYSV.py @@ -1,5 +1,5 @@ # This is the bcfg2 support for solaris sysv packages -'''This provides bcfg2 support for Solaris SYSV packages''' +"""This provides bcfg2 support for Solaris SYSV packages.""" __revision__ = '$Revision$' import tempfile, Bcfg2.Client.Tools, Bcfg2.Client.XML @@ -20,7 +20,7 @@ basedir=default ''' class SYSV(Bcfg2.Client.Tools.PkgTool): - '''Solaris SYSV package support''' + """Solaris SYSV package support.""" __execs__ = ["/usr/sbin/pkgadd", "/usr/bin/pkginfo"] __handles__ = [('Package', 'sysv')] __req__ = {'Package': ['name', 'version']} @@ -44,7 +44,7 @@ class SYSV(Bcfg2.Client.Tools.PkgTool): self.pkgtool = (self.pkgtool[0] % (""), self.pkgtool[1]) def RefreshPackages(self): - '''Refresh memory hashes of packages''' + """Refresh memory hashes of packages.""" self.installed = {} # Build list of packages lines = self.cmd.run("/usr/bin/pkginfo -x")[1] @@ -59,7 +59,7 @@ class SYSV(Bcfg2.Client.Tools.PkgTool): self.installed[pkg] = version def VerifyPackage(self, entry, modlist): - '''Verify Package status for entry''' + """Verify Package status for entry.""" if not entry.get('version'): self.logger.info("Insufficient information of Package %s; cannot Verify" % entry.get('name')) return False @@ -94,7 +94,7 @@ class SYSV(Bcfg2.Client.Tools.PkgTool): return False def RemovePackages(self, packages): - '''Remove specified Sysv packages''' + """Remove specified Sysv packages.""" names = [pkg.get('name') for pkg in packages] self.logger.info("Removing packages: %s" % (names)) self.cmd.run("/usr/sbin/pkgrm -a %s -n %s" % \ diff --git a/src/lib/Client/Tools/Upstart.py b/src/lib/Client/Tools/Upstart.py index b6e68d549..12d82488d 100644 --- a/src/lib/Client/Tools/Upstart.py +++ b/src/lib/Client/Tools/Upstart.py @@ -1,4 +1,4 @@ -'''Upstart support for Bcfg2''' +"""Upstart support for Bcfg2.""" __revision__ = '$Revision$' import glob @@ -9,7 +9,7 @@ import Bcfg2.Client.XML class Upstart(Bcfg2.Client.Tools.SvcTool): - '''Upstart service support for Bcfg2''' + """Upstart service support for Bcfg2.""" name = 'Upstart' __execs__ = ['/lib/init/upstart-job', '/sbin/initctl', @@ -22,13 +22,13 @@ class Upstart(Bcfg2.Client.Tools.SvcTool): return "/usr/sbin/service %s %s" % (service.get('name'), action) def VerifyService(self, entry, _): - '''Verify Service status for entry + """Verify Service status for entry Verifying whether or not the service is enabled can be done at the file level with upstart using the contents of /etc/init/servicename.conf. All we need to do is make sure the service is running when it should be. - ''' + """ try: output = self.cmd.run('/usr/sbin/service %s status' % \ entry.get('name'))[1][0] @@ -58,7 +58,7 @@ class Upstart(Bcfg2.Client.Tools.SvcTool): return status def InstallService(self, entry): - '''Install Service for entry''' + """Install Service for entry.""" if entry.get('mode', 'default') == 'supervised': pstatus, pout = self.cmd.run('/usr/sbin/service %s status' % \ entry.get('name')) @@ -67,7 +67,7 @@ class Upstart(Bcfg2.Client.Tools.SvcTool): return True def FindExtra(self): - '''Locate extra Upstart services''' + """Locate extra Upstart services.""" specified = [entry.get('name') for entry in self.getSupportedEntries()] extra = [] for name in [self.svcre.match(fname).group('name') for fname in diff --git a/src/lib/Client/Tools/YUMng.py b/src/lib/Client/Tools/YUMng.py index 9faeb3328..2078a5126 100644 --- a/src/lib/Client/Tools/YUMng.py +++ b/src/lib/Client/Tools/YUMng.py @@ -1,4 +1,4 @@ -'''This provides bcfg2 support for yum''' +"""This provides bcfg2 support for yum.""" __revision__ = '$Revision: $' import ConfigParser @@ -31,7 +31,7 @@ if not hasattr(Bcfg2.Client.Tools.RPMng, 'RPMng'): raise ImportError def build_yname(pkgname, inst): - '''build yum appropriate package name''' + """Build yum appropriate package name.""" ypname = pkgname if inst.get('version') != 'any': ypname += '-' @@ -46,7 +46,7 @@ def build_yname(pkgname, inst): return ypname class YUMng(Bcfg2.Client.Tools.RPMng.RPMng): - '''Support for Yum packages''' + """Support for Yum packages.""" pkgtype = 'yum' name = 'YUMng' @@ -148,7 +148,7 @@ class YUMng(Bcfg2.Client.Tools.RPMng.RPMng): modlist) def Install(self, packages, states): - ''' + """ Try and fix everything that RPMng.VerifyPackages() found wrong for each Package Entry. This can result in individual RPMs being installed (for the first time), deleted, downgraded @@ -167,7 +167,8 @@ class YUMng(Bcfg2.Client.Tools.RPMng.RPMng): of a package. - Each package will be added to self.modified[] if its states{} entry is set to True. - ''' + + """ self.logger.info('Running YUMng.Install()') install_pkgs = [] @@ -315,12 +316,12 @@ class YUMng(Bcfg2.Client.Tools.RPMng.RPMng): self.modified.append(entry) def RemovePackages(self, packages): - ''' + """ Remove specified entries. packages is a list of Package Entries with Instances generated by FindExtraPackages(). - ''' + """ self.logger.debug('Running YUMng.RemovePackages()') if YAD: diff --git a/src/lib/Client/Tools/__init__.py b/src/lib/Client/Tools/__init__.py index 671c5f01d..8ab815022 100644 --- a/src/lib/Client/Tools/__init__.py +++ b/src/lib/Client/Tools/__init__.py @@ -1,4 +1,4 @@ -'''This contains all Bcfg2 Tool modules''' +"""This contains all Bcfg2 Tool modules""" __revision__ = '$Revision$' __all__ = ["Action", @@ -38,11 +38,11 @@ import time import Bcfg2.Client.XML class toolInstantiationError(Exception): - '''This error is called if the toolset cannot be instantiated''' + """This error is called if the toolset cannot be instantiated.""" pass class readonlypipe(popen2.Popen4): - '''This pipe sets up stdin --> /dev/null''' + """This pipe sets up stdin --> /dev/null.""" def __init__(self, cmd, bufsize=-1): popen2._cleanup() c2pread, c2pwrite = os.pipe() @@ -60,12 +60,12 @@ class readonlypipe(popen2.Popen4): popen2._active.append(self) class executor: - '''this class runs stuff for us''' + """This class runs stuff for us""" def __init__(self, logger): self.logger = logger def run(self, command): - '''Run a command in a pipe dealing with stdout buffer overloads''' + """Run a command in a pipe dealing with stdout buffer overloads.""" self.logger.debug('> %s' % command) runpipe = readonlypipe(command, bufsize=16384) @@ -92,9 +92,9 @@ class executor: return ((cmdstat >> 8), output) class Tool: - ''' - All tools subclass this. It defines all interfaces that need to be defined - ''' + """ + All tools subclass this. It defines all interfaces that need to be defined. + """ name = 'Tool' __execs__ = [] __handles__ = [] @@ -126,15 +126,15 @@ class Tool: raise toolInstantiationError def BundleUpdated(self, _, states): - '''This callback is used when bundle updates occur''' + """This callback is used when bundle updates occur.""" return def BundleNotUpdated(self, _, states): - '''This callback is used when a bundle is not updated''' + """This callback is used when a bundle is not updated.""" return def Inventory(self, states, structures=[]): - '''Dispatch verify calls to underlying methods''' + """Dispatch verify calls to underlying methods.""" if not structures: structures = self.config.getchildren() mods = self.buildModlist() @@ -151,7 +151,7 @@ class Tool: self.extra = self.FindExtra() def Install(self, entries, states): - '''Install all entries in sublist''' + """Install all entries in sublist.""" for entry in entries: try: func = getattr(self, "Install%s" % (entry.tag)) @@ -162,18 +162,18 @@ class Tool: % (entry.tag), exc_info=1) def Remove(self, entries): - '''Remove specified extra entries''' + """Remove specified extra entries""" pass def getSupportedEntries(self): - '''return a list of supported entries''' + """Return a list of supported entries.""" return [entry for struct in \ self.config.getchildren() for entry in \ struct.getchildren() \ if self.handlesEntry(entry)] def handlesEntry(self, entry): - '''return if entry is handled by this Tool''' + """Return if entry is handled by this tool.""" return (entry.tag, entry.get('type')) in self.__handles__ def buildModlist(self): @@ -184,11 +184,11 @@ class Tool: 'Permissions', 'Ignore', 'Path']] def gatherCurrentData(self, entry): - '''Default implementation of the information gathering routines''' + """Default implementation of the information gathering routines.""" pass def canVerify(self, entry): - '''test if entry has enough information to be verified''' + """Test if entry has enough information to be verified.""" if not self.handlesEntry(entry): return False @@ -213,11 +213,11 @@ class Tool: def FindExtra(self): - '''Return a list of extra entries''' + """Return a list of extra entries.""" return [] def canInstall(self, entry): - '''test if entry has enough information to be installed''' + """Test if entry has enough information to be installed.""" if not self.handlesEntry(entry): return False @@ -237,10 +237,10 @@ class Tool: return True class PkgTool(Tool): - ''' + """ PkgTool provides a one-pass install with fallback for use with packaging systems - ''' + """ pkgtool = ('echo %s', ('%s', ['name'])) pkgtype = 'echo' name = 'PkgTool' @@ -253,14 +253,14 @@ class PkgTool(Tool): self.RefreshPackages() def VerifyPackage(self, dummy, _): - '''Dummy verification method''' + """Dummy verification method""" return False def Install(self, packages, states): - ''' + """ Run a one-pass install, followed by - single pkg installs in case of failure - ''' + single pkg installs in case of failure. + """ self.logger.info("Trying single pass package install for pkgtype %s" % \ self.pkgtype) @@ -306,15 +306,15 @@ class PkgTool(Tool): self.modified.append(entry) def RefreshPackages(self): - '''Dummy state refresh method''' + """Dummy state refresh method.""" pass def RemovePackages(self, packages): - '''Dummy implementation of package removal method''' + """Dummy implementation of package removal method.""" pass def FindExtraPackages(self): - '''Find extra packages''' + """Find extra packages.""" packages = [entry.get('name') for entry in self.getSupportedEntries()] extras = [data for data in list(self.installed.items()) \ if data[0] not in packages] @@ -323,11 +323,11 @@ class PkgTool(Tool): for (name, version) in extras] class SvcTool(Tool): - '''This class defines basic Service behavior''' + """This class defines basic Service behavior""" name = 'SvcTool' def get_svc_command(self, service, action): - '''Return the basename of the command used to start/stop services''' + """Return the basename of the command used to start/stop services.""" return '/etc/init.d/%s %s' % (service.get('name'), action) def start_service(self, service): @@ -350,7 +350,7 @@ class SvcTool(Tool): return 0 def BundleUpdated(self, bundle, states): - '''The Bundle has been updated''' + """The Bundle has been updated.""" if self.setup['servicemode'] == 'disabled': return diff --git a/src/lib/Client/Tools/launchd.py b/src/lib/Client/Tools/launchd.py index 2b035b6a8..a8b785016 100644 --- a/src/lib/Client/Tools/launchd.py +++ b/src/lib/Client/Tools/launchd.py @@ -1,4 +1,4 @@ -'''launchd support for Bcfg2''' +"""launchd support for Bcfg2.""" __revision__ = '$Revision$' import os @@ -6,15 +6,15 @@ import Bcfg2.Client.Tools import popen2 class launchd(Bcfg2.Client.Tools.Tool): - '''Support for Mac OS X Launchd Services''' + """Support for Mac OS X launchd services.""" __handles__ = [('Service', 'launchd')] __execs__ = ['/bin/launchctl', '/usr/bin/defaults'] name = 'launchd' __req__ = {'Service':['name', 'status']} ''' - currently requires the path to the plist to load/unload, - and Name is acually a reverse-fqdn (or the label) + 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) @@ -55,7 +55,7 @@ class launchd(Bcfg2.Client.Tools.Tool): return version def VerifyService(self, entry, _): - '''Verify Launchd Service Entry''' + """Verify launchd service entry.""" try: services = self.cmd.run("/bin/launchctl list")[1] except IndexError:#happens when no services are running (should be never) @@ -79,7 +79,7 @@ class launchd(Bcfg2.Client.Tools.Tool): def InstallService(self, entry): - '''Enable or Disable launchd Item''' + """Enable or disable launchd item.""" name = entry.get('name') if entry.get('status') == 'on': self.logger.error("Installing service %s" % name) @@ -92,13 +92,13 @@ class launchd(Bcfg2.Client.Tools.Tool): return cmdrc[0] == 0 def Remove(self, svcs): - '''Remove Extra launchd entries''' + """Remove Extra launchd entries.""" pass def FindExtra(self): - '''Find Extra launchd Services''' + """Find Extra launchd services.""" try: allsrv = self.cmd.run("/bin/launchctl list")[1] except IndexError: @@ -109,7 +109,7 @@ class launchd(Bcfg2.Client.Tools.Tool): return [Bcfg2.Client.XML.Element("Service", type='launchd', name=name, status='on') for name in allsrv] def BundleUpdated(self, bundle, states): - '''Reload launchd plist''' + """Reload launchd plist.""" for entry in [entry for entry in bundle if self.handlesEntry(entry)]: if not self.canInstall(entry): self.logger.error("Insufficient information to restart service %s" % (entry.get('name'))) -- cgit v1.2.3-1-g7c22