summaryrefslogtreecommitdiffstats
path: root/src/sbin
diff options
context:
space:
mode:
authorChris St. Pierre <chris.a.st.pierre@gmail.com>2012-09-24 14:12:07 -0400
committerChris St. Pierre <chris.a.st.pierre@gmail.com>2012-09-25 11:58:48 -0400
commit47aebb16f15fe6f8ce29d8c6b105f10d8d64c295 (patch)
tree82b5fb2e640875a2013498b08f2cf114f3f36eb4 /src/sbin
parent3428eab79ab21d1ecee6d2f8edff083a2cccdf79 (diff)
downloadbcfg2-47aebb16f15fe6f8ce29d8c6b105f10d8d64c295.tar.gz
bcfg2-47aebb16f15fe6f8ce29d8c6b105f10d8d64c295.tar.bz2
bcfg2-47aebb16f15fe6f8ce29d8c6b105f10d8d64c295.zip
more pylint checks
Diffstat (limited to 'src/sbin')
-rwxr-xr-xsrc/sbin/bcfg2-server9
-rwxr-xr-xsrc/sbin/bcfg2-yum-helper34
2 files changed, 30 insertions, 13 deletions
diff --git a/src/sbin/bcfg2-server b/src/sbin/bcfg2-server
index fe16866cf..8322edeaa 100755
--- a/src/sbin/bcfg2-server
+++ b/src/sbin/bcfg2-server
@@ -9,9 +9,9 @@ import Bcfg2.Logger
import Bcfg2.Options
from Bcfg2.Server.Core import CoreInitError
-logger = logging.getLogger('bcfg2-server')
+LOGGER = logging.getLogger('bcfg2-server')
-if __name__ == '__main__':
+def main():
optinfo = dict()
optinfo.update(Bcfg2.Options.CLI_COMMON_OPTIONS)
optinfo.update(Bcfg2.Options.SERVER_COMMON_OPTIONS)
@@ -41,9 +41,12 @@ if __name__ == '__main__':
core.run()
except CoreInitError:
msg = sys.exc_info()[1]
- logger.error(msg)
+ LOGGER.error(msg)
sys.exit(1)
except KeyboardInterrupt:
sys.exit(1)
sys.exit(0)
+
+if __name__ == '__main__':
+ sys.exit(main())
diff --git a/src/sbin/bcfg2-yum-helper b/src/sbin/bcfg2-yum-helper
index 859ec36b6..ba6f30406 100755
--- a/src/sbin/bcfg2-yum-helper
+++ b/src/sbin/bcfg2-yum-helper
@@ -48,6 +48,8 @@ def pkg_to_tuple(package):
def pkgtup_to_string(package):
+ """ given a package tuple, return a human-readable string
+ describing the package """
if package[3] in ['auto', 'any']:
return package[0]
@@ -61,31 +63,37 @@ def pkgtup_to_string(package):
class DepSolver(object):
+ """ Yum dependency solver """
+
def __init__(self, cfgfile, verbose=1):
self.cfgfile = cfgfile
self.yumbase = yum.YumBase()
- # pylint: disable=E1121
+ # pylint: disable=E1121,W0212
try:
self.yumbase.preconf.debuglevel = verbose
self.yumbase.preconf.fn = cfgfile
self.yumbase._getConfig()
except AttributeError:
self.yumbase._getConfig(cfgfile, debuglevel=verbose)
- # pylint: enable=E1121
+ # pylint: enable=E1121,W0212
self.logger = get_logger(verbose)
+ self._groups = None
def get_groups(self):
- try:
+ """ getter for the groups property """
+ if self._groups is not None:
return self._groups
- except AttributeError:
+ else:
return ["noarch"]
def set_groups(self, groups):
+ """ setter for the groups property """
self._groups = set(groups).union(["noarch"])
groups = property(get_groups, set_groups)
def get_package_object(self, pkgtup, silent=False):
+ """ given a package tuple, get a yum package object """
try:
matches = yum.packageSack.packagesNewestByName(
self.yumbase.pkgSack.searchPkgTuple(pkgtup))
@@ -107,6 +115,7 @@ class DepSolver(object):
return None
def get_group(self, group, ptype="default"):
+ """ Resolve a package group name into a list of packages """
if group.startswith("@"):
group = group[1:]
@@ -136,6 +145,8 @@ class DepSolver(object):
return []
def _filter_arch(self, packages):
+ """ filter packages in the given list that do not have an
+ architecture in the list of groups for this client """
matching = []
for pkg in packages:
if pkg.arch in self.groups:
@@ -163,6 +174,8 @@ class DepSolver(object):
return str(package)
def complete(self, packagelist):
+ """ resolve dependencies and generate a complete package list
+ from the given list of initial packages """
packages = set()
unknown = set()
for pkg in packagelist:
@@ -170,18 +183,18 @@ class DepSolver(object):
pkgtup = pkg
else:
pkgtup = (pkg, None, None, None, None)
- po = self.get_package_object(pkgtup)
- if not po:
+ pkgobj = self.get_package_object(pkgtup)
+ if not pkgobj:
self.logger.debug("Unknown package %s" %
self.get_package_name(pkg))
unknown.add(pkg)
else:
- if self.yumbase.tsInfo.exists(pkgtup=po.pkgtup):
+ if self.yumbase.tsInfo.exists(pkgtup=pkgobj.pkgtup):
self.logger.debug("%s added to transaction multiple times"
- % po)
+ % pkgobj)
else:
- self.logger.debug("Adding %s to transaction" % po)
- self.yumbase.tsInfo.addInstall(po)
+ self.logger.debug("Adding %s to transaction" % pkgobj)
+ self.yumbase.tsInfo.addInstall(pkgobj)
self.yumbase.resolveDeps()
for txmbr in self.yumbase.tsInfo:
@@ -189,6 +202,7 @@ class DepSolver(object):
return list(packages), list(unknown)
def clean_cache(self):
+ """ clean the yum cache """
for mdtype in ["Headers", "Packages", "Sqlite", "Metadata",
"ExpireCache"]:
# for reasons that are entirely obvious, all of the yum