From d7ffffb20f041c982fac1b74308b6fa29f2c00db Mon Sep 17 00:00:00 2001 From: Gordon Messmer Date: Thu, 21 Apr 2016 14:07:02 -0700 Subject: Bcfg2.Options.Subcommand must not access Options.setup in __init__. --- src/lib/Bcfg2/Server/Plugins/Packages/YumHelper.py | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/lib/Bcfg2/Server/Plugins/Packages/YumHelper.py b/src/lib/Bcfg2/Server/Plugins/Packages/YumHelper.py index ddc684628..4ffd55d68 100644 --- a/src/lib/Bcfg2/Server/Plugins/Packages/YumHelper.py +++ b/src/lib/Bcfg2/Server/Plugins/Packages/YumHelper.py @@ -274,15 +274,15 @@ class HelperSubcommand(Bcfg2.Options.Subcommand): # whether or not this command accepts input on stdin accept_input = True - def __init__(self): - Bcfg2.Options.Subcommand.__init__(self) - self.verbosity = 0 + # logging level + verbosity = 0 + + def run(self, setup): if Bcfg2.Options.setup.debug: self.verbosity = 5 elif Bcfg2.Options.setup.verbose: self.verbosity = 1 - def run(self, setup): if accept_input: try: data = json.loads(sys.stdin.read()) @@ -311,10 +311,13 @@ class DepSolverSubcommand(HelperSubcommand): # pylint: disable=W0223 """ Base class for helper commands that use the depsolver (i.e., only resolve dependencies, don't modify the cache) """ - def __init__(self): - HelperSubcommand.__init__(self) + # DepSolver instance used in _run function + depsolver = None + + def run(self, setup): self.depsolver = DepSolver(Bcfg2.Options.setup.yum_config, self.verbosity) + HelperSubcommand.run(self, setup) class CacheManagerSubcommand(HelperSubcommand): # pylint: disable=W0223 @@ -323,10 +326,13 @@ class CacheManagerSubcommand(HelperSubcommand): # pylint: disable=W0223 fallback = False accept_input = False - def __init__(self): - HelperSubcommand.__init__(self) + # CacheManager instance used in _run function + cachemgr = None + + def run(self, setup): self.cachemgr = CacheManager(Bcfg2.Options.setup.yum_config, self.verbosity) + HelperSubcommand.run(self, setup) class Clean(CacheManagerSubcommand): -- cgit v1.2.3-1-g7c22