summaryrefslogtreecommitdiffstats
path: root/src/lib/Bcfg2/Server
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/Bcfg2/Server')
-rw-r--r--src/lib/Bcfg2/Server/Admin/Init.py4
-rw-r--r--src/lib/Bcfg2/Server/Admin/Minestruct.py2
-rw-r--r--src/lib/Bcfg2/Server/Admin/Perf.py11
-rw-r--r--src/lib/Bcfg2/Server/Admin/Pull.py2
-rw-r--r--src/lib/Bcfg2/Server/Admin/Xcmd.py5
-rw-r--r--src/lib/Bcfg2/Server/Admin/__init__.py42
-rw-r--r--src/lib/Bcfg2/Server/Core.py4
-rw-r--r--src/lib/Bcfg2/Server/FileMonitor/Fam.py2
-rw-r--r--src/lib/Bcfg2/Server/FileMonitor/Pseudo.py2
-rw-r--r--src/lib/Bcfg2/Server/Lint/RequiredAttrs.py13
-rw-r--r--src/lib/Bcfg2/Server/Plugin/helpers.py26
-rw-r--r--src/lib/Bcfg2/Server/Plugin/interfaces.py15
-rw-r--r--src/lib/Bcfg2/Server/Plugins/Bundler.py14
-rw-r--r--src/lib/Bcfg2/Server/Plugins/Cfg/CfgPrivateKeyCreator.py5
-rw-r--r--src/lib/Bcfg2/Server/Plugins/Cfg/__init__.py6
-rw-r--r--src/lib/Bcfg2/Server/Plugins/Cvs.py6
-rw-r--r--src/lib/Bcfg2/Server/Plugins/Darcs.py6
-rw-r--r--src/lib/Bcfg2/Server/Plugins/FileProbes.py7
-rw-r--r--src/lib/Bcfg2/Server/Plugins/Fossil.py6
-rw-r--r--src/lib/Bcfg2/Server/Plugins/GroupPatterns.py4
-rw-r--r--src/lib/Bcfg2/Server/Plugins/Metadata.py12
-rw-r--r--src/lib/Bcfg2/Server/Plugins/Ohai.py2
-rw-r--r--src/lib/Bcfg2/Server/Plugins/Packages/Apt.py4
-rw-r--r--src/lib/Bcfg2/Server/Plugins/Packages/Source.py4
-rw-r--r--src/lib/Bcfg2/Server/Plugins/Packages/Yum.py12
-rw-r--r--src/lib/Bcfg2/Server/Plugins/Packages/__init__.py16
-rw-r--r--src/lib/Bcfg2/Server/Plugins/Probes.py11
-rw-r--r--src/lib/Bcfg2/Server/Plugins/Reporting.py5
-rw-r--r--src/lib/Bcfg2/Server/Plugins/SSHbase.py5
-rw-r--r--src/lib/Bcfg2/Server/Plugins/__init__.py6
30 files changed, 123 insertions, 136 deletions
diff --git a/src/lib/Bcfg2/Server/Admin/Init.py b/src/lib/Bcfg2/Server/Admin/Init.py
index 4b8d65597..6175d8ed0 100644
--- a/src/lib/Bcfg2/Server/Admin/Init.py
+++ b/src/lib/Bcfg2/Server/Admin/Init.py
@@ -227,8 +227,8 @@ class Init(Bcfg2.Server.Admin.Mode):
def _prompt_password(self):
"""Ask for a password or generate one if none is provided."""
newpassword = getpass.getpass(
- "Input password used for communication verification "
- "(without echoing; leave blank for a random): ").strip()
+ "Input password used for communication verification "
+ "(without echoing; leave blank for a random): ").strip()
if len(newpassword) != 0:
self.data['password'] = newpassword
diff --git a/src/lib/Bcfg2/Server/Admin/Minestruct.py b/src/lib/Bcfg2/Server/Admin/Minestruct.py
index 6d0dab106..13c0563ec 100644
--- a/src/lib/Bcfg2/Server/Admin/Minestruct.py
+++ b/src/lib/Bcfg2/Server/Admin/Minestruct.py
@@ -44,7 +44,7 @@ class Minestruct(Bcfg2.Server.Admin.StructureMode):
extra.add(item)
except:
self.log.error("Failed to find extra entry info for client %s" %
- client)
+ client)
raise SystemExit(1)
root = lxml.etree.Element("Base")
self.log.info("Found %d extra entries" % (len(extra)))
diff --git a/src/lib/Bcfg2/Server/Admin/Perf.py b/src/lib/Bcfg2/Server/Admin/Perf.py
index 86eb6810d..f6bc22959 100644
--- a/src/lib/Bcfg2/Server/Admin/Perf.py
+++ b/src/lib/Bcfg2/Server/Admin/Perf.py
@@ -18,8 +18,7 @@ class Perf(Bcfg2.Server.Admin.Mode):
'password': Bcfg2.Options.SERVER_PASSWORD,
'server': Bcfg2.Options.SERVER_LOCATION,
'user': Bcfg2.Options.CLIENT_USER,
- 'timeout': Bcfg2.Options.CLIENT_TIMEOUT,
- }
+ 'timeout': Bcfg2.Options.CLIENT_TIMEOUT}
setup = Bcfg2.Options.OptionParser(optinfo)
setup.parse(sys.argv[1:])
proxy = Bcfg2.Proxy.ComponentProxy(setup['server'],
@@ -31,8 +30,8 @@ class Perf(Bcfg2.Server.Admin.Mode):
timeout=setup['timeout'])
data = proxy.get_statistics()
for key in sorted(data.keys()):
- output.append((key, ) +
- tuple(["%.06f" % item
- for item in data[key][:-1]] + \
- [data[key][-1]]))
+ output.append(
+ (key, ) +
+ tuple(["%.06f" % item
+ for item in data[key][:-1]] + [data[key][-1]]))
self.print_table(output)
diff --git a/src/lib/Bcfg2/Server/Admin/Pull.py b/src/lib/Bcfg2/Server/Admin/Pull.py
index 130e85b67..9f1b3d138 100644
--- a/src/lib/Bcfg2/Server/Admin/Pull.py
+++ b/src/lib/Bcfg2/Server/Admin/Pull.py
@@ -65,7 +65,7 @@ class Pull(Bcfg2.Server.Admin.MetadataCore):
for plugin in self.bcore.pull_sources:
try:
(owner, group, mode, contents) = \
- plugin.GetCurrentEntry(client, etype, ename)
+ plugin.GetCurrentEntry(client, etype, ename)
break
except Bcfg2.Server.Plugin.PluginExecutionError:
if plugin == self.bcore.pull_sources[-1]:
diff --git a/src/lib/Bcfg2/Server/Admin/Xcmd.py b/src/lib/Bcfg2/Server/Admin/Xcmd.py
index 79eeebc7c..be556bed4 100644
--- a/src/lib/Bcfg2/Server/Admin/Xcmd.py
+++ b/src/lib/Bcfg2/Server/Admin/Xcmd.py
@@ -19,8 +19,7 @@ class Xcmd(Bcfg2.Server.Admin.Mode):
'key': Bcfg2.Options.SERVER_KEY,
'certificate': Bcfg2.Options.CLIENT_CERT,
'ca': Bcfg2.Options.CLIENT_CA,
- 'timeout': Bcfg2.Options.CLIENT_TIMEOUT,
- }
+ 'timeout': Bcfg2.Options.CLIENT_TIMEOUT}
setup = Bcfg2.Options.OptionParser(optinfo)
setup.parse(args)
Bcfg2.Proxy.RetryMethod.max_retries = 1
@@ -54,5 +53,5 @@ class Xcmd(Bcfg2.Server.Admin.Mode):
print("Proxy Error: %s" % err)
return
- if data != None:
+ if data is not None:
print(data)
diff --git a/src/lib/Bcfg2/Server/Admin/__init__.py b/src/lib/Bcfg2/Server/Admin/__init__.py
index 19175533f..a3c45b8c3 100644
--- a/src/lib/Bcfg2/Server/Admin/__init__.py
+++ b/src/lib/Bcfg2/Server/Admin/__init__.py
@@ -1,23 +1,21 @@
""" Base classes for admin modes """
-__all__ = [
- 'Backup',
- 'Bundle',
- 'Client',
- 'Compare',
- 'Group',
- 'Init',
- 'Minestruct',
- 'Perf',
- 'Pull',
- 'Query',
- 'Reports',
- 'Snapshots',
- 'Syncdb',
- 'Tidy',
- 'Viz',
- 'Xcmd'
- ]
+__all__ = ['Backup',
+ 'Bundle',
+ 'Client',
+ 'Compare',
+ 'Group',
+ 'Init',
+ 'Minestruct',
+ 'Perf',
+ 'Pull',
+ 'Query',
+ 'Reports',
+ 'Snapshots',
+ 'Syncdb',
+ 'Tidy',
+ 'Viz',
+ 'Xcmd']
import re
import sys
@@ -105,15 +103,15 @@ class Mode(object):
# Calculate column widths (longest item in each column
# plus padding on both sides)
cols = list(zip(*rows))
- col_widths = [max([len(str(item)) + 2 * padding for \
- item in col]) for col in cols]
+ col_widths = [max([len(str(item)) + 2 * padding
+ for item in col]) for col in cols]
borderline = vdelim.join([w * hdelim for w in col_widths])
# Print out the table
print(borderline)
for row in rows:
- print(vdelim.join([justify(str(item), width) for \
- (item, width) in zip(row, col_widths)]))
+ print(vdelim.join([justify(str(item), width)
+ for (item, width) in zip(row, col_widths)]))
if hdr:
print(borderline)
hdr = False
diff --git a/src/lib/Bcfg2/Server/Core.py b/src/lib/Bcfg2/Server/Core.py
index 8ceb8cfc1..deb9065a5 100644
--- a/src/lib/Bcfg2/Server/Core.py
+++ b/src/lib/Bcfg2/Server/Core.py
@@ -397,7 +397,7 @@ class BaseCore(object):
self.logger.debug("Loading plugin %s" % plugin)
try:
mod = getattr(__import__("Bcfg2.Server.Plugins.%s" %
- (plugin)).Server.Plugins, plugin)
+ (plugin)).Server.Plugins, plugin)
except ImportError:
try:
mod = __import__(plugin, globals(), locals(),
@@ -1084,7 +1084,7 @@ class BaseCore(object):
Bcfg2.Server.Plugin.MetadataRuntimeError):
err = sys.exc_info()[1]
self.critical_error("Unable to assert profile for %s: %s" %
- (client, err))
+ (client, err))
return True
@exposed
diff --git a/src/lib/Bcfg2/Server/FileMonitor/Fam.py b/src/lib/Bcfg2/Server/FileMonitor/Fam.py
index 253bb2801..09d41038e 100644
--- a/src/lib/Bcfg2/Server/FileMonitor/Fam.py
+++ b/src/lib/Bcfg2/Server/FileMonitor/Fam.py
@@ -51,7 +51,7 @@ class Fam(FileMonitor):
else:
handle = self.filemonitor.monitorFile(path, None)
self.handles[handle.requestID()] = handle
- if obj != None:
+ if obj is not None:
self.users[handle.requestID()] = obj
return handle.requestID()
AddMonitor.__doc__ = FileMonitor.AddMonitor.__doc__
diff --git a/src/lib/Bcfg2/Server/FileMonitor/Pseudo.py b/src/lib/Bcfg2/Server/FileMonitor/Pseudo.py
index 24cd099d0..b1e1adab7 100644
--- a/src/lib/Bcfg2/Server/FileMonitor/Pseudo.py
+++ b/src/lib/Bcfg2/Server/FileMonitor/Pseudo.py
@@ -24,6 +24,6 @@ class Pseudo(FileMonitor):
self.events.append(Event(handleID, fname, 'exists'))
self.events.append(Event(handleID, path, 'endExist'))
- if obj != None:
+ if obj is not None:
self.handles[handleID] = obj
return handleID
diff --git a/src/lib/Bcfg2/Server/Lint/RequiredAttrs.py b/src/lib/Bcfg2/Server/Lint/RequiredAttrs.py
index 2a10da417..be4264b07 100644
--- a/src/lib/Bcfg2/Server/Lint/RequiredAttrs.py
+++ b/src/lib/Bcfg2/Server/Lint/RequiredAttrs.py
@@ -61,7 +61,7 @@ class RequiredAttrs(Bcfg2.Server.Lint.ServerPlugin):
Path=dict(
device=dict(name=is_filename, owner=is_username,
group=is_username,
- dev_type=lambda v: \
+ dev_type=lambda v:
v in Bcfg2.Client.Tools.POSIX.base.device_map),
directory=dict(name=is_filename, owner=is_username,
group=is_username, mode=is_octal_mode),
@@ -98,10 +98,10 @@ class RequiredAttrs(Bcfg2.Server.Lint.ServerPlugin):
SEBoolean={None: dict(name=None,
value=lambda v: v in ['on', 'off'])},
SEModule={None: dict(name=None, __text__=None)},
- SEPort={None:
- dict(name=lambda v: re.match(r'^\d+(-\d+)?/(tcp|udp)',
- v),
- selinuxtype=is_selinux_type)},
+ SEPort={
+ None: dict(name=lambda v: re.match(r'^\d+(-\d+)?/(tcp|udp)',
+ v),
+ selinuxtype=is_selinux_type)},
SEFcontext={None: dict(name=None, selinuxtype=is_selinux_type)},
SENode={None: dict(name=lambda v: "/" in v,
selinuxtype=is_selinux_type,
@@ -116,8 +116,7 @@ class RequiredAttrs(Bcfg2.Server.Lint.ServerPlugin):
SEPermissive={None: dict(name=is_selinux_type)},
POSIXGroup={None: dict(name=is_username)},
POSIXUser={None: dict(name=is_username)},
- MemberOf={None: dict(__text__=is_username)},
- )
+ MemberOf={None: dict(__text__=is_username)})
def Run(self):
self.check_packages()
diff --git a/src/lib/Bcfg2/Server/Plugin/helpers.py b/src/lib/Bcfg2/Server/Plugin/helpers.py
index 448d8b3b6..bddd0ba20 100644
--- a/src/lib/Bcfg2/Server/Plugin/helpers.py
+++ b/src/lib/Bcfg2/Server/Plugin/helpers.py
@@ -25,15 +25,15 @@ except ImportError:
HAS_DJANGO = False
#: A dict containing default metadata for Path entries from bcfg2.conf
-DEFAULT_FILE_METADATA = Bcfg2.Options.OptionParser(dict(
- configfile=Bcfg2.Options.CFILE,
- owner=Bcfg2.Options.MDATA_OWNER,
- group=Bcfg2.Options.MDATA_GROUP,
- mode=Bcfg2.Options.MDATA_MODE,
- secontext=Bcfg2.Options.MDATA_SECONTEXT,
- important=Bcfg2.Options.MDATA_IMPORTANT,
- paranoid=Bcfg2.Options.MDATA_PARANOID,
- sensitive=Bcfg2.Options.MDATA_SENSITIVE))
+DEFAULT_FILE_METADATA = Bcfg2.Options.OptionParser(
+ dict(configfile=Bcfg2.Options.CFILE,
+ owner=Bcfg2.Options.MDATA_OWNER,
+ group=Bcfg2.Options.MDATA_GROUP,
+ mode=Bcfg2.Options.MDATA_MODE,
+ secontext=Bcfg2.Options.MDATA_SECONTEXT,
+ important=Bcfg2.Options.MDATA_IMPORTANT,
+ paranoid=Bcfg2.Options.MDATA_PARANOID,
+ sensitive=Bcfg2.Options.MDATA_SENSITIVE))
DEFAULT_FILE_METADATA.parse([Bcfg2.Options.CFILE.cmd, Bcfg2.Options.CFILE])
del DEFAULT_FILE_METADATA['args']
del DEFAULT_FILE_METADATA['configfile']
@@ -786,14 +786,14 @@ class InfoNode (INode):
Client="lambda m, e: '%(name)s' == m.hostname and predicate(m, e)",
Group="lambda m, e: '%(name)s' in m.groups and predicate(m, e)",
Path="lambda m, e: ('%(name)s' == e.get('name') or " +
- "'%(name)s' == e.get('realname')) and " +
- "predicate(m, e)")
+ "'%(name)s' == e.get('realname')) and " +
+ "predicate(m, e)")
nraw = dict(
Client="lambda m, e: '%(name)s' != m.hostname and predicate(m, e)",
Group="lambda m, e: '%(name)s' not in m.groups and predicate(m, e)",
Path="lambda m, e: '%(name)s' != e.get('name') and " +
- "'%(name)s' != e.get('realname') and " +
- "predicate(m, e)")
+ "'%(name)s' != e.get('realname') and " +
+ "predicate(m, e)")
containers = ['Group', 'Client', 'Path']
diff --git a/src/lib/Bcfg2/Server/Plugin/interfaces.py b/src/lib/Bcfg2/Server/Plugin/interfaces.py
index cb996b1ca..0fd711be9 100644
--- a/src/lib/Bcfg2/Server/Plugin/interfaces.py
+++ b/src/lib/Bcfg2/Server/Plugin/interfaces.py
@@ -337,12 +337,11 @@ class ThreadedStatistics(Statistics, Threaded, threading.Thread):
pending_data = []
try:
while not self.work_queue.empty():
- (metadata, data) = self.work_queue.get_nowait()
- pending_data.append(
- (metadata.hostname,
- lxml.etree.tostring(
- data,
- xml_declaration=False).decode("UTF-8")))
+ (metadata, xdata) = self.work_queue.get_nowait()
+ data = \
+ lxml.etree.tostring(xdata,
+ xml_declaration=False).decode("UTF-8")
+ pending_data.append((metadata.hostname, data))
except Empty:
pass
@@ -409,7 +408,7 @@ class ThreadedStatistics(Statistics, Threaded, threading.Thread):
def run(self):
if not self._load():
return
- while not self.terminate.isSet() and self.work_queue != None:
+ while not self.terminate.isSet() and self.work_queue is not None:
try:
(client, xdata) = self.work_queue.get(block=True, timeout=2)
except Empty:
@@ -419,7 +418,7 @@ class ThreadedStatistics(Statistics, Threaded, threading.Thread):
self.logger.error("ThreadedStatistics: %s" % err)
continue
self.handle_statistic(client, xdata)
- if self.work_queue != None and not self.work_queue.empty():
+ if self.work_queue is not None and not self.work_queue.empty():
self._save()
def process_statistics(self, metadata, data):
diff --git a/src/lib/Bcfg2/Server/Plugins/Bundler.py b/src/lib/Bcfg2/Server/Plugins/Bundler.py
index 24301155d..a9b9bf8c1 100644
--- a/src/lib/Bcfg2/Server/Plugins/Bundler.py
+++ b/src/lib/Bcfg2/Server/Plugins/Bundler.py
@@ -13,7 +13,7 @@ import Bcfg2.Server.Lint
try:
import genshi.template.base
- import Bcfg2.Server.Plugins.TGenshi
+ from Bcfg2.Server.Plugins.TGenshi import removecomment, TemplateFile
HAS_GENSHI = True
except ImportError:
HAS_GENSHI = False
@@ -34,14 +34,12 @@ class BundleFile(Bcfg2.Server.Plugin.StructFile):
if HAS_GENSHI:
- class BundleTemplateFile(Bcfg2.Server.Plugins.TGenshi.TemplateFile,
+ class BundleTemplateFile(TemplateFile,
Bcfg2.Server.Plugin.StructFile):
""" Representation of a Genshi-templated bundle XML file """
def __init__(self, name, specific, encoding):
- Bcfg2.Server.Plugins.TGenshi.TemplateFile.__init__(self, name,
- specific,
- encoding)
+ TemplateFile.__init__(self, name, specific, encoding)
Bcfg2.Server.Plugin.StructFile.__init__(self, name)
self.logger = logging.getLogger(name)
@@ -52,9 +50,9 @@ if HAS_GENSHI:
msg = "No parsed template information for %s" % self.name
self.logger.error(msg)
raise Bcfg2.Server.Plugin.PluginExecutionError(msg)
- stream = self.template.generate(metadata=metadata,
- repo=SETUP['repo']).filter(
- Bcfg2.Server.Plugins.TGenshi.removecomment)
+ stream = self.template.generate(
+ metadata=metadata,
+ repo=SETUP['repo']).filter(removecomment)
data = lxml.etree.XML(stream.render('xml',
strip_whitespace=False),
parser=Bcfg2.Server.XMLParser)
diff --git a/src/lib/Bcfg2/Server/Plugins/Cfg/CfgPrivateKeyCreator.py b/src/lib/Bcfg2/Server/Plugins/Cfg/CfgPrivateKeyCreator.py
index aaeb65cd6..581a997d8 100644
--- a/src/lib/Bcfg2/Server/Plugins/Cfg/CfgPrivateKeyCreator.py
+++ b/src/lib/Bcfg2/Server/Plugins/Cfg/CfgPrivateKeyCreator.py
@@ -48,9 +48,8 @@ class CfgPrivateKeyCreator(CfgCreator, StructFile):
if (HAS_CRYPTO and
SETUP.cfp.has_section("sshkeys") and
SETUP.cfp.has_option("sshkeys", "passphrase")):
- return Bcfg2.Encryption.get_passphrases(SETUP)[SETUP.cfp.get(
- "sshkeys",
- "passphrase")]
+ return Bcfg2.Encryption.get_passphrases(SETUP)[
+ SETUP.cfp.get("sshkeys", "passphrase")]
return None
def handle_event(self, event):
diff --git a/src/lib/Bcfg2/Server/Plugins/Cfg/__init__.py b/src/lib/Bcfg2/Server/Plugins/Cfg/__init__.py
index ec3ba222c..f347b898c 100644
--- a/src/lib/Bcfg2/Server/Plugins/Cfg/__init__.py
+++ b/src/lib/Bcfg2/Server/Plugins/Cfg/__init__.py
@@ -87,7 +87,7 @@ class CfgBaseFileMatcher(Bcfg2.Server.Plugin.SpecificData,
Bcfg2.Server.Plugin.Debuggable.__init__(self)
self.encoding = encoding
__init__.__doc__ = Bcfg2.Server.Plugin.SpecificData.__init__.__doc__ + \
-"""
+ """
.. -----
.. autoattribute:: CfgBaseFileMatcher.__basenames__
.. autoattribute:: CfgBaseFileMatcher.__extensions__
@@ -758,8 +758,8 @@ class CfgEntrySet(Bcfg2.Server.Plugin.EntrySet,
pass
if not rv or not rv[0].hostname:
- rv.append(Bcfg2.Server.Plugin.Specificity(
- hostname=metadata.hostname))
+ rv.append(
+ Bcfg2.Server.Plugin.Specificity(hostname=metadata.hostname))
return rv
def build_filename(self, specific):
diff --git a/src/lib/Bcfg2/Server/Plugins/Cvs.py b/src/lib/Bcfg2/Server/Plugins/Cvs.py
index ba1559a1a..22cacaa76 100644
--- a/src/lib/Bcfg2/Server/Plugins/Cvs.py
+++ b/src/lib/Bcfg2/Server/Plugins/Cvs.py
@@ -20,9 +20,9 @@ class Cvs(Bcfg2.Server.Plugin.Version):
"""Read cvs revision information for the Bcfg2 repository."""
try:
data = Popen("env LC_ALL=C cvs log",
- shell=True,
- cwd=self.vcs_root,
- stdout=PIPE).stdout.readlines()
+ shell=True,
+ cwd=self.vcs_root,
+ stdout=PIPE).stdout.readlines()
return data[3].strip('\n')
except IndexError:
msg = "Failed to read CVS log"
diff --git a/src/lib/Bcfg2/Server/Plugins/Darcs.py b/src/lib/Bcfg2/Server/Plugins/Darcs.py
index 0033e00f3..b4abafb0e 100644
--- a/src/lib/Bcfg2/Server/Plugins/Darcs.py
+++ b/src/lib/Bcfg2/Server/Plugins/Darcs.py
@@ -20,9 +20,9 @@ class Darcs(Bcfg2.Server.Plugin.Version):
"""Read Darcs changeset information for the Bcfg2 repository."""
try:
data = Popen("env LC_ALL=C darcs changes",
- shell=True,
- cwd=self.vcs_root,
- stdout=PIPE).stdout.readlines()
+ shell=True,
+ cwd=self.vcs_root,
+ stdout=PIPE).stdout.readlines()
revision = data[0].strip('\n')
except:
msg = "Failed to read darcs repository"
diff --git a/src/lib/Bcfg2/Server/Plugins/FileProbes.py b/src/lib/Bcfg2/Server/Plugins/FileProbes.py
index 882c22c49..d816192aa 100644
--- a/src/lib/Bcfg2/Server/Plugins/FileProbes.py
+++ b/src/lib/Bcfg2/Server/Plugins/FileProbes.py
@@ -226,11 +226,8 @@ class FileProbes(Bcfg2.Server.Plugin.Plugin,
root = lxml.etree.Element("FileInfo")
root.append(info)
try:
- open(infoxml,
- "w").write(
- lxml.etree.tostring(root,
- xml_declaration=False,
- pretty_print=True).decode('UTF-8'))
+ root.getroottree().write(infoxml, xml_declaration=False,
+ pretty_print=True)
except IOError:
err = sys.exc_info()[1]
self.logger.error("Could not write %s: %s" % (infoxml, err))
diff --git a/src/lib/Bcfg2/Server/Plugins/Fossil.py b/src/lib/Bcfg2/Server/Plugins/Fossil.py
index f6735df12..d0c328b36 100644
--- a/src/lib/Bcfg2/Server/Plugins/Fossil.py
+++ b/src/lib/Bcfg2/Server/Plugins/Fossil.py
@@ -20,9 +20,9 @@ class Fossil(Bcfg2.Server.Plugin.Version):
"""Read fossil revision information for the Bcfg2 repository."""
try:
data = Popen("env LC_ALL=C fossil info",
- shell=True,
- cwd=self.vcs_root,
- stdout=PIPE).stdout.readlines()
+ shell=True,
+ cwd=self.vcs_root,
+ stdout=PIPE).stdout.readlines()
revline = [line.split(': ')[1].strip() for line in data if \
line.split(': ')[0].strip() == 'checkout'][-1]
return revline.split(' ')[0]
diff --git a/src/lib/Bcfg2/Server/Plugins/GroupPatterns.py b/src/lib/Bcfg2/Server/Plugins/GroupPatterns.py
index 8ce3fcd3a..fcfae2088 100644
--- a/src/lib/Bcfg2/Server/Plugins/GroupPatterns.py
+++ b/src/lib/Bcfg2/Server/Plugins/GroupPatterns.py
@@ -15,10 +15,10 @@ class PatternMap(object):
self.pattern = pattern
self.rangestr = rangestr
self.groups = groups
- if pattern != None:
+ if pattern is not None:
self.re = re.compile(pattern)
self.process = self.process_re
- elif rangestr != None:
+ elif rangestr is not None:
if '\\' in rangestr:
raise Exception("Backslashes are not allowed in NameRanges")
range_finder = r'\[\[[\d\-,]+\]\]'
diff --git a/src/lib/Bcfg2/Server/Plugins/Metadata.py b/src/lib/Bcfg2/Server/Plugins/Metadata.py
index 4af4df666..10b09842a 100644
--- a/src/lib/Bcfg2/Server/Plugins/Metadata.py
+++ b/src/lib/Bcfg2/Server/Plugins/Metadata.py
@@ -602,7 +602,7 @@ class Metadata(Bcfg2.Server.Plugin.Metadata,
def _add_xdata(self, config, tag, name, attribs=None, alias=False):
""" Generic method to add XML data (group, client, etc.) """
node = self._search_xdata(tag, name, config.xdata, alias=alias)
- if node != None:
+ if node is not None:
raise Bcfg2.Server.Plugin.MetadataConsistencyError("%s \"%s\" "
"already exists"
% (tag, name))
@@ -662,7 +662,7 @@ class Metadata(Bcfg2.Server.Plugin.Metadata,
def _update_xdata(self, config, tag, name, attribs, alias=False):
""" Generic method to modify XML data (group, client, etc.) """
node = self._search_xdata(tag, name, config.xdata, alias=alias)
- if node == None:
+ if node is None:
self.logger.error("%s \"%s\" does not exist" % (tag, name))
raise Bcfg2.Server.Plugin.MetadataConsistencyError
xdict = config.find_xml_for_xpath('.//%s[@name="%s"]' %
@@ -679,7 +679,7 @@ class Metadata(Bcfg2.Server.Plugin.Metadata,
"""Update a groups attributes."""
if self._use_db:
msg = "Metadata does not support updating groups with " + \
- "use_database enabled"
+ "use_database enabled"
self.logger.error(msg)
raise Bcfg2.Server.Plugin.PluginExecutionError(msg)
else:
@@ -707,7 +707,7 @@ class Metadata(Bcfg2.Server.Plugin.Metadata,
def _remove_xdata(self, config, tag, name):
""" Generic method to remove XML data (group, client, etc.) """
node = self._search_xdata(tag, name, config.xdata)
- if node == None:
+ if node is None:
self.logger.error("%s \"%s\" does not exist" % (tag, name))
raise Bcfg2.Server.Plugin.MetadataConsistencyError
xdict = config.find_xml_for_xpath('.//%s[@name="%s"]' %
@@ -1557,8 +1557,8 @@ class MetadataLint(Bcfg2.Server.Lint.ServerPlugin):
tag as a definition if it a) has profile or public set; or b)
has any children. """
self.duplicate_entries(
- self.metadata.groups_xml.xdata.xpath("//Groups/Group") + \
- self.metadata.groups_xml.xdata.xpath("//Groups/Group//Group"),
+ self.metadata.groups_xml.xdata.xpath("//Groups/Group") +
+ self.metadata.groups_xml.xdata.xpath("//Groups/Group//Group"),
"group",
include=lambda g: (g.get("profile") or
g.get("public") or
diff --git a/src/lib/Bcfg2/Server/Plugins/Ohai.py b/src/lib/Bcfg2/Server/Plugins/Ohai.py
index 07b04f3f0..a88c245bd 100644
--- a/src/lib/Bcfg2/Server/Plugins/Ohai.py
+++ b/src/lib/Bcfg2/Server/Plugins/Ohai.py
@@ -32,7 +32,7 @@ class OhaiCache(object):
self.cache = dict()
def __setitem__(self, item, value):
- if value == None:
+ if value is None:
# simply return if the client returned nothing
return
self.cache[item] = json.loads(value)
diff --git a/src/lib/Bcfg2/Server/Plugins/Packages/Apt.py b/src/lib/Bcfg2/Server/Plugins/Packages/Apt.py
index 27f493677..5ae160994 100644
--- a/src/lib/Bcfg2/Server/Plugins/Packages/Apt.py
+++ b/src/lib/Bcfg2/Server/Plugins/Packages/Apt.py
@@ -30,8 +30,8 @@ class AptCollection(Collection):
""" Get an APT configuration file (i.e., ``sources.list``).
:returns: string """
- lines = ["# This config was generated automatically by the Bcfg2 " \
- "Packages plugin", '']
+ lines = ["# This config was generated automatically by the Bcfg2 "
+ "Packages plugin", '']
for source in self:
if source.rawurl:
diff --git a/src/lib/Bcfg2/Server/Plugins/Packages/Source.py b/src/lib/Bcfg2/Server/Plugins/Packages/Source.py
index 985405e65..0c6ee0759 100644
--- a/src/lib/Bcfg2/Server/Plugins/Packages/Source.py
+++ b/src/lib/Bcfg2/Server/Plugins/Packages/Source.py
@@ -52,8 +52,8 @@ import re
import sys
import Bcfg2.Server.Plugin
from Bcfg2.Compat import HTTPError, HTTPBasicAuthHandler, \
- HTTPPasswordMgrWithDefaultRealm, install_opener, build_opener, \
- urlopen, cPickle, md5
+ HTTPPasswordMgrWithDefaultRealm, install_opener, build_opener, urlopen, \
+ cPickle, md5
def fetch_url(url):
diff --git a/src/lib/Bcfg2/Server/Plugins/Packages/Yum.py b/src/lib/Bcfg2/Server/Plugins/Packages/Yum.py
index 6b8ed1f7d..77186d2cb 100644
--- a/src/lib/Bcfg2/Server/Plugins/Packages/Yum.py
+++ b/src/lib/Bcfg2/Server/Plugins/Packages/Yum.py
@@ -66,7 +66,7 @@ from Bcfg2.Compat import StringIO, cPickle, HTTPError, URLError, \
# pylint: enable=W0622
from Bcfg2.Server.Plugins.Packages.Collection import Collection
from Bcfg2.Server.Plugins.Packages.Source import SourceInitError, Source, \
- fetch_url
+ fetch_url
LOGGER = logging.getLogger(__name__)
@@ -281,7 +281,7 @@ class YumCollection(Collection):
#: Define a unique cache file for this collection to use
#: for cached yum metadata
self.cachefile = os.path.join(self.cachepath,
- "cache-%s" % self.cachekey)
+ "cache-%s" % self.cachekey)
if not os.path.exists(self.cachefile):
os.mkdir(self.cachefile)
@@ -1169,7 +1169,7 @@ class YumSource(Source):
if entry.get('name').startswith('/'):
self.needed_paths.add(entry.get('name'))
pro = pdata.find(RP + 'provides')
- if pro != None:
+ if pro is not None:
for entry in pro.getchildren():
prov = entry.get('name')
if prov not in self.provides[arch]:
@@ -1185,9 +1185,9 @@ class YumSource(Source):
try:
groupid = group.xpath('id')[0].text
self.yumgroups[groupid] = {'mandatory': list(),
- 'default': list(),
- 'optional': list(),
- 'conditional': list()}
+ 'default': list(),
+ 'optional': list(),
+ 'conditional': list()}
except IndexError:
continue
try:
diff --git a/src/lib/Bcfg2/Server/Plugins/Packages/__init__.py b/src/lib/Bcfg2/Server/Plugins/Packages/__init__.py
index 0b6889b09..4f163a1ab 100644
--- a/src/lib/Bcfg2/Server/Plugins/Packages/__init__.py
+++ b/src/lib/Bcfg2/Server/Plugins/Packages/__init__.py
@@ -247,14 +247,14 @@ class Packages(Bcfg2.Server.Plugin.Plugin,
return True
elif entry.tag == 'Path':
# managed entries for yum/apt configs
- if (entry.get("name") == \
- self.core.setup.cfp.get("packages",
- "yum_config",
- default=YUM_CONFIG_DEFAULT) or
- entry.get("name") == \
- self.core.setup.cfp.get("packages",
- "apt_config",
- default=APT_CONFIG_DEFAULT)):
+ if (entry.get("name") ==
+ self.core.setup.cfp.get("packages",
+ "yum_config",
+ default=YUM_CONFIG_DEFAULT) or
+ entry.get("name") ==
+ self.core.setup.cfp.get("packages",
+ "apt_config",
+ default=APT_CONFIG_DEFAULT)):
return True
return False
diff --git a/src/lib/Bcfg2/Server/Plugins/Probes.py b/src/lib/Bcfg2/Server/Plugins/Probes.py
index f106b75a4..634826f4b 100644
--- a/src/lib/Bcfg2/Server/Plugins/Probes.py
+++ b/src/lib/Bcfg2/Server/Plugins/Probes.py
@@ -214,10 +214,9 @@ class Probes(Bcfg2.Server.Plugin.Probing,
for group in sorted(self.cgroups[client]):
lxml.etree.SubElement(ctag, "Group", name=group)
try:
- datafile = open(os.path.join(self.data, 'probed.xml'), 'w')
- datafile.write(lxml.etree.tostring(
- top, xml_declaration=False,
- pretty_print='true').decode('UTF-8'))
+ top.getroottree().write(os.path.join(self.data, 'probed.xml'),
+ xml_declaration=False,
+ pretty_print='true')
except IOError:
err = sys.exc_info()[1]
self.logger.error("Failed to write probed.xml: %s" % err)
@@ -246,7 +245,7 @@ class Probes(Bcfg2.Server.Plugin.Probing,
grp.save()
ProbesGroupsModel.objects.filter(
hostname=client.hostname).exclude(
- group__in=self.cgroups[client.hostname]).delete()
+ group__in=self.cgroups[client.hostname]).delete()
def load_data(self):
""" Load probe data from the appropriate backend (probed.xml
@@ -320,7 +319,7 @@ class Probes(Bcfg2.Server.Plugin.Probing,
def ReceiveDataItem(self, client, data, cgroups, cprobedata):
"""Receive probe results pertaining to client."""
- if data.text == None:
+ if data.text is None:
self.logger.info("Got null response to probe %s from %s" %
(data.get('name'), client.hostname))
cprobedata[data.get('name')] = ProbeData('')
diff --git a/src/lib/Bcfg2/Server/Plugins/Reporting.py b/src/lib/Bcfg2/Server/Plugins/Reporting.py
index a6dc2c1ef..3bd6fd14f 100644
--- a/src/lib/Bcfg2/Server/Plugins/Reporting.py
+++ b/src/lib/Bcfg2/Server/Plugins/Reporting.py
@@ -92,8 +92,9 @@ class Reporting(Statistics, Threaded, PullSource, Debuggable):
# try 3 times to store the data
for i in [1, 2, 3]:
try:
- self.transport.store(client.hostname, cdata,
- lxml.etree.tostring(
+ self.transport.store(
+ client.hostname, cdata,
+ lxml.etree.tostring(
stats,
xml_declaration=False).decode('UTF-8'))
self.debug_log("%s: Queued statistics data for %s" %
diff --git a/src/lib/Bcfg2/Server/Plugins/SSHbase.py b/src/lib/Bcfg2/Server/Plugins/SSHbase.py
index c7db67301..0c5644395 100644
--- a/src/lib/Bcfg2/Server/Plugins/SSHbase.py
+++ b/src/lib/Bcfg2/Server/Plugins/SSHbase.py
@@ -201,9 +201,10 @@ class SSHbase(Bcfg2.Server.Plugin.Plugin,
if specific.hostname and specific.hostname in names:
hostnames = names[specific.hostname]
elif specific.group:
- hostnames = list(chain(
+ hostnames = list(
+ chain(
*[names[cmeta.hostname]
- for cmeta in \
+ for cmeta in
mquery.by_groups([specific.group])]))
elif specific.all:
# a generic key for all hosts? really?
diff --git a/src/lib/Bcfg2/Server/Plugins/__init__.py b/src/lib/Bcfg2/Server/Plugins/__init__.py
index b33eeba28..063e14315 100644
--- a/src/lib/Bcfg2/Server/Plugins/__init__.py
+++ b/src/lib/Bcfg2/Server/Plugins/__init__.py
@@ -1,7 +1,6 @@
"""Imports for Bcfg2.Server.Plugins."""
-__all__ = [
- 'Account',
+__all__ = ['Account',
'Base',
'Bundler',
'Bzr',
@@ -28,5 +27,4 @@ __all__ = [
'Svn',
'TCheetah',
'Trigger',
- 'TGenshi',
- ]
+ 'TGenshi']