summaryrefslogtreecommitdiffstats
path: root/src/lib/Bcfg2/Client/__init__.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/Bcfg2/Client/__init__.py')
-rw-r--r--src/lib/Bcfg2/Client/__init__.py34
1 files changed, 21 insertions, 13 deletions
diff --git a/src/lib/Bcfg2/Client/__init__.py b/src/lib/Bcfg2/Client/__init__.py
index dd32fc45c..2761fcddb 100644
--- a/src/lib/Bcfg2/Client/__init__.py
+++ b/src/lib/Bcfg2/Client/__init__.py
@@ -12,9 +12,9 @@ import argparse
import tempfile
import Bcfg2.Logger
import Bcfg2.Options
-import XML
-import Proxy
-import Tools
+import XML # pylint: disable=W0403
+import Proxy # pylint: disable=W0403
+import Tools # pylint: disable=W0403
from Bcfg2.Utils import locked, Executor, safe_input
from Bcfg2.version import __version__
# pylint: disable=W0622
@@ -66,6 +66,9 @@ def prompt(msg):
try:
ans = safe_input(msg)
return ans in ['y', 'Y']
+ except UnicodeEncodeError:
+ ans = input(msg.encode('utf-8'))
+ return ans in ['y', 'Y']
except EOFError:
# handle ^C on rhel-based platforms
raise SystemExit(1)
@@ -75,6 +78,7 @@ def prompt(msg):
class ClientDriverAction(Bcfg2.Options.ComponentAction):
+ """ Action to load client drivers """
bases = ['Bcfg2.Client.Tools']
fail_silently = True
@@ -129,8 +133,8 @@ class Client(object):
Bcfg2.Options.BooleanOption(
"-O", "--no-lock", help='Omit lock check'),
Bcfg2.Options.PathOption(
- cf=('components', 'lockfile'), default='/var/lock/bcfg2.run',
- help='Client lock file'),
+ cf=('components', 'lockfile'), default='/var/lock/bcfg2.run',
+ help='Client lock file'),
Bcfg2.Options.BooleanOption(
"-n", "--dry-run", help='Do not actually change the system'),
Bcfg2.Options.Option(
@@ -171,6 +175,7 @@ class Client(object):
self.whitelist = []
self.blacklist = []
self.removal = []
+ self.unhandled = []
self.logger = logging.getLogger(__name__)
def _probe_failure(self, probename, msg):
@@ -342,6 +347,7 @@ class Client(object):
return rawconfig
def parse_config(self, rawconfig):
+ """ Parse the XML configuration received from the Bcfg2 server """
try:
self.config = XML.XML(rawconfig)
except XML.ParseError:
@@ -448,6 +454,7 @@ class Client(object):
self.logger.info("Finished Bcfg2 client run at %s" % time.time())
def load_tools(self):
+ """ Load all applicable client tools """
for tool in Bcfg2.Options.setup.drivers:
try:
self.tools.append(tool(self.config))
@@ -546,7 +553,8 @@ class Client(object):
elif Bcfg2.Options.setup.decision == 'blacklist':
b_to_rem = \
[e for e in self.whitelist
- if not passes_black_list(e, Bcfg2.Options.setup.decision_list)]
+ if not
+ passes_black_list(e, Bcfg2.Options.setup.decision_list)]
if b_to_rem:
self.logger.info("In blacklist mode: "
"suppressing installation of:")
@@ -579,7 +587,7 @@ class Client(object):
self.states[cfile] = tools[0].InstallPath(cfile)
if self.states[cfile]:
tools[0].modified.append(cfile)
- except:
+ except: # pylint: disable=W0702
self.logger.error("Unexpected tool failure",
exc_info=1)
cfile.set('qtext', '')
@@ -600,7 +608,7 @@ class Client(object):
for tool in self.tools:
try:
self.states.update(tool.Inventory())
- except:
+ except: # pylint: disable=W0702
self.logger.error("%s.Inventory() call failed:" % tool.name,
exc_info=1)
@@ -715,7 +723,7 @@ class Client(object):
continue
try:
self.states.update(tool.Install(handled))
- except:
+ except: # pylint: disable=W0702
self.logger.error("%s.Install() call failed:" % tool.name,
exc_info=1)
@@ -735,7 +743,7 @@ class Client(object):
for tool, bundle in tbm:
try:
self.states.update(tool.Inventory(structures=[bundle]))
- except:
+ except: # pylint: disable=W0702
self.logger.error("%s.Inventory() call failed:" %
tool.name,
exc_info=1)
@@ -765,7 +773,7 @@ class Client(object):
for tool in self.tools:
try:
self.states.update(getattr(tool, func)(bundle))
- except:
+ except: # pylint: disable=W0702
self.logger.error("%s.%s(%s:%s) call failed:" %
(tool.name, func, bundle.tag,
bundle.get("name")), exc_info=1)
@@ -774,7 +782,7 @@ class Client(object):
for tool in self.tools:
try:
self.states.update(tool.BundleNotUpdated(indep))
- except:
+ except: # pylint: disable=W0702
self.logger.error("%s.BundleNotUpdated(%s:%s) call failed:"
% (tool.name, indep.tag,
indep.get("name")), exc_info=1)
@@ -787,7 +795,7 @@ class Client(object):
if extras:
try:
tool.Remove(extras)
- except:
+ except: # pylint: disable=W0702
self.logger.error("%s.Remove() failed" % tool.name,
exc_info=1)