summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/lib/Bcfg2/Client/Tools/IPS.py2
-rw-r--r--src/lib/Bcfg2/Client/Tools/VCS.py2
-rw-r--r--src/lib/Bcfg2/Client/XML.py2
-rw-r--r--src/lib/Bcfg2/Compat.py2
-rw-r--r--src/lib/Bcfg2/Proxy.py1
-rw-r--r--src/lib/Bcfg2/Server/Admin/Snapshots.py2
-rw-r--r--src/lib/Bcfg2/Server/CherryPyCore.py2
-rw-r--r--src/lib/Bcfg2/Server/Core.py2
-rw-r--r--src/lib/Bcfg2/Server/FileMonitor/Fam.py2
-rw-r--r--src/lib/Bcfg2/Server/FileMonitor/Gamin.py2
-rw-r--r--src/lib/Bcfg2/Server/FileMonitor/Inotify.py2
-rw-r--r--src/lib/Bcfg2/Server/Plugins/Bzr.py2
-rw-r--r--src/lib/Bcfg2/Server/Plugins/DBStats.py5
-rw-r--r--src/lib/Bcfg2/Server/Plugins/Git.py2
-rw-r--r--src/lib/Bcfg2/Server/Plugins/Guppy.py3
-rw-r--r--src/lib/Bcfg2/Server/Plugins/Ldap.py11
-rw-r--r--src/lib/Bcfg2/Server/Plugins/NagiosGen.py100
-rw-r--r--src/lib/Bcfg2/Server/Plugins/Ohai.py2
-rw-r--r--src/lib/Bcfg2/Server/Plugins/Packages/Yum.py4
-rw-r--r--src/lib/Bcfg2/Server/Plugins/Probes.py2
-rw-r--r--src/lib/Bcfg2/Server/Plugins/PuppetENC.py2
-rw-r--r--src/lib/Bcfg2/Server/Plugins/Svn2.py2
-rw-r--r--src/lib/Bcfg2/Server/Reports/reports/templatetags/syntax_coloring.py5
-rw-r--r--testsuite/Testsrc/test_code_checks.py25
-rw-r--r--testsuite/pylintrc.conf4
-rw-r--r--testsuite/requirements.txt1
26 files changed, 67 insertions, 124 deletions
diff --git a/src/lib/Bcfg2/Client/Tools/IPS.py b/src/lib/Bcfg2/Client/Tools/IPS.py
index 730f4c2d9..e30bbd2a4 100644
--- a/src/lib/Bcfg2/Client/Tools/IPS.py
+++ b/src/lib/Bcfg2/Client/Tools/IPS.py
@@ -1,9 +1,7 @@
"""This is the Bcfg2 support for OpenSolaris packages."""
-# pylint: disable=F0401
import pkg.client.image as image
import pkg.client.progress as progress
-# pylint: enable=F0401
import Bcfg2.Client.Tools
diff --git a/src/lib/Bcfg2/Client/Tools/VCS.py b/src/lib/Bcfg2/Client/Tools/VCS.py
index 790ac787a..6c4c77426 100644
--- a/src/lib/Bcfg2/Client/Tools/VCS.py
+++ b/src/lib/Bcfg2/Client/Tools/VCS.py
@@ -10,7 +10,6 @@ import os
import shutil
import sys
-# pylint: disable=F0401
# python-dulwich git imports
try:
import dulwich
@@ -23,7 +22,6 @@ try:
import pysvn
except ImportError:
missing.append('svn')
-# pylint: enable=F0401
import Bcfg2.Client.Tools
diff --git a/src/lib/Bcfg2/Client/XML.py b/src/lib/Bcfg2/Client/XML.py
index 720416724..91d4ac5c6 100644
--- a/src/lib/Bcfg2/Client/XML.py
+++ b/src/lib/Bcfg2/Client/XML.py
@@ -2,7 +2,7 @@
# library will use lxml, then builtin xml.etree, then ElementTree
-# pylint: disable=F0401,E0611,W0611,W0613,C0103
+# pylint: disable=E0611,W0611,W0613,C0103
try:
from lxml.etree import Element, SubElement, XML, tostring
diff --git a/src/lib/Bcfg2/Compat.py b/src/lib/Bcfg2/Compat.py
index f466b8e03..635c49a49 100644
--- a/src/lib/Bcfg2/Compat.py
+++ b/src/lib/Bcfg2/Compat.py
@@ -3,7 +3,7 @@ Python 2.4 and such-like """
import sys
-# pylint: disable=F0401,E0611,W0611,W0622,C0103
+# pylint: disable=E0611,W0611,W0622,C0103
try:
from email.Utils import formatdate
diff --git a/src/lib/Bcfg2/Proxy.py b/src/lib/Bcfg2/Proxy.py
index f3a19c3b3..72953ef3e 100644
--- a/src/lib/Bcfg2/Proxy.py
+++ b/src/lib/Bcfg2/Proxy.py
@@ -16,7 +16,6 @@ except ImportError:
SSL_LIB = 'm2crypto'
SSL_ERROR = SSL.SSLError
-
import sys
import time
diff --git a/src/lib/Bcfg2/Server/Admin/Snapshots.py b/src/lib/Bcfg2/Server/Admin/Snapshots.py
index c3f3268d0..36e3dfe02 100644
--- a/src/lib/Bcfg2/Server/Admin/Snapshots.py
+++ b/src/lib/Bcfg2/Server/Admin/Snapshots.py
@@ -2,7 +2,7 @@ from datetime import date
import sys
# Prereq issues can be signaled with ImportError, so no try needed
-import sqlalchemy, sqlalchemy.orm # pylint: disable=F0401
+import sqlalchemy, sqlalchemy.orm
import Bcfg2.Server.Admin
import Bcfg2.Server.Snapshots
import Bcfg2.Server.Snapshots.model
diff --git a/src/lib/Bcfg2/Server/CherryPyCore.py b/src/lib/Bcfg2/Server/CherryPyCore.py
index 684ea4556..6b438b71c 100644
--- a/src/lib/Bcfg2/Server/CherryPyCore.py
+++ b/src/lib/Bcfg2/Server/CherryPyCore.py
@@ -2,9 +2,9 @@
import sys
import time
-import cherrypy
from Bcfg2.Compat import urlparse, xmlrpclib, b64decode
from Bcfg2.Server.Core import BaseCore
+import cherrypy
from cherrypy.lib import xmlrpcutil
from cherrypy._cptools import ErrorTool
from cherrypy.process.plugins import Daemonizer
diff --git a/src/lib/Bcfg2/Server/Core.py b/src/lib/Bcfg2/Server/Core.py
index 0e5a88f79..81b020a13 100644
--- a/src/lib/Bcfg2/Server/Core.py
+++ b/src/lib/Bcfg2/Server/Core.py
@@ -20,7 +20,7 @@ from Bcfg2.Compat import xmlrpclib, reduce, wraps # pylint: disable=W0622
from Bcfg2.Server.Plugin import PluginInitError, PluginExecutionError
try:
- import psyco # pylint: disable=F0401
+ import psyco
psyco.full()
except ImportError:
pass
diff --git a/src/lib/Bcfg2/Server/FileMonitor/Fam.py b/src/lib/Bcfg2/Server/FileMonitor/Fam.py
index 9c6031be9..d1420c105 100644
--- a/src/lib/Bcfg2/Server/FileMonitor/Fam.py
+++ b/src/lib/Bcfg2/Server/FileMonitor/Fam.py
@@ -1,7 +1,7 @@
""" Fam provides FAM support for file alteration events """
import os
-import _fam # pylint: disable=F0401
+import _fam
import stat
import logging
from time import time
diff --git a/src/lib/Bcfg2/Server/FileMonitor/Gamin.py b/src/lib/Bcfg2/Server/FileMonitor/Gamin.py
index d0ba59cd8..12965c040 100644
--- a/src/lib/Bcfg2/Server/FileMonitor/Gamin.py
+++ b/src/lib/Bcfg2/Server/FileMonitor/Gamin.py
@@ -2,10 +2,8 @@
import os
import stat
-# pylint: disable=F0401
from gamin import WatchMonitor, GAMCreated, GAMExists, GAMEndExist, \
GAMChanged, GAMDeleted
-# pylint: enable=F0401
from Bcfg2.Server.FileMonitor import Event, FileMonitor
diff --git a/src/lib/Bcfg2/Server/FileMonitor/Inotify.py b/src/lib/Bcfg2/Server/FileMonitor/Inotify.py
index 5a8a1e1c6..175df65c8 100644
--- a/src/lib/Bcfg2/Server/FileMonitor/Inotify.py
+++ b/src/lib/Bcfg2/Server/FileMonitor/Inotify.py
@@ -2,7 +2,7 @@
import os
import logging
-import pyinotify # pylint: disable=F0401
+import pyinotify
from Bcfg2.Compat import reduce # pylint: disable=W0622
from Bcfg2.Server.FileMonitor import Event
from Bcfg2.Server.FileMonitor.Pseudo import Pseudo
diff --git a/src/lib/Bcfg2/Server/Plugins/Bzr.py b/src/lib/Bcfg2/Server/Plugins/Bzr.py
index 4de204468..a8b4113ff 100644
--- a/src/lib/Bcfg2/Server/Plugins/Bzr.py
+++ b/src/lib/Bcfg2/Server/Plugins/Bzr.py
@@ -2,10 +2,8 @@
bazaar. """
import Bcfg2.Server.Plugin
-# pylint: disable=F0401
from bzrlib.workingtree import WorkingTree
from bzrlib import errors
-# pylint: enable=F0401
class Bzr(Bcfg2.Server.Plugin.Plugin,
diff --git a/src/lib/Bcfg2/Server/Plugins/DBStats.py b/src/lib/Bcfg2/Server/Plugins/DBStats.py
index 16e9e4a8a..b796b3431 100644
--- a/src/lib/Bcfg2/Server/Plugins/DBStats.py
+++ b/src/lib/Bcfg2/Server/Plugins/DBStats.py
@@ -5,10 +5,7 @@ import platform
import sys
import time
-try:
- from django.core.exceptions import MultipleObjectsReturned
-except ImportError:
- pass
+from django.core.exceptions import MultipleObjectsReturned
import Bcfg2.Server.Plugin
from Bcfg2.Server.Reports.importscript import load_stat
diff --git a/src/lib/Bcfg2/Server/Plugins/Git.py b/src/lib/Bcfg2/Server/Plugins/Git.py
index 30416a147..56f05e4f6 100644
--- a/src/lib/Bcfg2/Server/Plugins/Git.py
+++ b/src/lib/Bcfg2/Server/Plugins/Git.py
@@ -1,7 +1,7 @@
""" The Git plugin provides a revision interface for Bcfg2 repos using
git. """
-from dulwich.repo import Repo # pylint: disable=F0401
+from dulwich.repo import Repo
import Bcfg2.Server.Plugin
diff --git a/src/lib/Bcfg2/Server/Plugins/Guppy.py b/src/lib/Bcfg2/Server/Plugins/Guppy.py
index d13e3f061..4f2601f15 100644
--- a/src/lib/Bcfg2/Server/Plugins/Guppy.py
+++ b/src/lib/Bcfg2/Server/Plugins/Guppy.py
@@ -27,6 +27,7 @@ Remote interactive console. To return to Annex, type '-'.
"""
import Bcfg2.Server.Plugin
+from guppy.heapy import Remote
class Guppy(Bcfg2.Server.Plugin.Plugin):
@@ -45,7 +46,6 @@ class Guppy(Bcfg2.Server.Plugin.Plugin):
def Enable(self):
"""Enable remote debugging"""
try:
- from guppy.heapy import Remote
Remote.on()
except:
self.logger.error("Failed to create Heapy context")
@@ -54,7 +54,6 @@ class Guppy(Bcfg2.Server.Plugin.Plugin):
def Disable(self):
"""Disable remote debugging"""
try:
- from guppy.heapy import Remote
Remote.off()
except:
self.logger.error("Failed to disable Heapy")
diff --git a/src/lib/Bcfg2/Server/Plugins/Ldap.py b/src/lib/Bcfg2/Server/Plugins/Ldap.py
index 8e5ce2624..f724402d0 100644
--- a/src/lib/Bcfg2/Server/Plugins/Ldap.py
+++ b/src/lib/Bcfg2/Server/Plugins/Ldap.py
@@ -10,7 +10,7 @@ logger = logging.getLogger('Bcfg2.Plugins.Ldap')
try:
import ldap
-except:
+except ImportError:
logger.error("Unable to load ldap module. Is python-ldap installed?")
raise ImportError
@@ -21,16 +21,18 @@ RETRY_DELAY = 5
RETRY_COUNT = 3
SCOPE_MAP = {
- "base" : ldap.SCOPE_BASE,
- "one" : ldap.SCOPE_ONELEVEL,
- "sub" : ldap.SCOPE_SUBTREE,
+ "base": ldap.SCOPE_BASE,
+ "one": ldap.SCOPE_ONELEVEL,
+ "sub": ldap.SCOPE_SUBTREE,
}
LDAP_QUERIES = []
+
def register_query(query):
LDAP_QUERIES.append(query)
+
class ConfigFile(Bcfg2.Server.Plugin.FileBacked):
"""
Config file for the Ldap plugin
@@ -58,6 +60,7 @@ class ConfigFile(Bcfg2.Server.Plugin.FileBacked):
LDAP_QUERIES = []
imp.load_source("ldap_cfg", self.filename)
+
class Ldap(Bcfg2.Server.Plugin.Plugin, Bcfg2.Server.Plugin.Connector):
"""
The Ldap plugin allows adding data from an LDAP server to your metadata.
diff --git a/src/lib/Bcfg2/Server/Plugins/NagiosGen.py b/src/lib/Bcfg2/Server/Plugins/NagiosGen.py
index f2b8336e0..d815999f0 100644
--- a/src/lib/Bcfg2/Server/Plugins/NagiosGen.py
+++ b/src/lib/Bcfg2/Server/Plugins/NagiosGen.py
@@ -6,15 +6,15 @@ import sys
import glob
import socket
import logging
-import lxml.etree
import Bcfg2.Server
import Bcfg2.Server.Plugin
-LOGGER = logging.getLogger('Bcfg2.Plugins.NagiosGen')
+LOGGER = logging.getLogger(__name__)
-line_fmt = '\t%-32s %s'
class NagiosGenConfig(Bcfg2.Server.Plugin.StructFile):
+ """ NagiosGen config file handler """
+
def __init__(self, filename, fam):
# create config.xml if missing
if not os.path.exists(filename):
@@ -28,11 +28,10 @@ class NagiosGenConfig(Bcfg2.Server.Plugin.StructFile):
class NagiosGen(Bcfg2.Server.Plugin.Plugin,
Bcfg2.Server.Plugin.Generator):
- """NagiosGen is a Bcfg2 plugin that dynamically generates
- Nagios configuration file based on Bcfg2 data.
- """
- name = 'NagiosGen'
+ """ NagiosGen is a Bcfg2 plugin that dynamically generates Nagios
+ configuration file based on Bcfg2 data. """
__author__ = 'bcfg-dev@mcs.anl.gov'
+ line_fmt = '\t%-32s %s'
def __init__(self, core, datastore):
Bcfg2.Server.Plugin.Plugin.__init__(self, core, datastore)
@@ -59,84 +58,47 @@ class NagiosGen(Bcfg2.Server.Plugin.Plugin,
try:
host_address = socket.gethostbyname(metadata.hostname)
except socket.gaierror:
- LOGGER.error("Failed to find IP address for %s" %
- metadata.hostname)
+ self.logger.error("Failed to find IP address for %s" %
+ metadata.hostname)
raise Bcfg2.Server.Plugin.PluginExecutionError
host_groups = [grp for grp in metadata.groups
if os.path.isfile('%s/%s-group.cfg' % (self.data, grp))]
host_config = ['define host {',
- line_fmt % ('host_name', metadata.hostname),
- line_fmt % ('alias', metadata.hostname),
- line_fmt % ('address', host_address)]
+ self.line_fmt % ('host_name', metadata.hostname),
+ self.line_fmt % ('alias', metadata.hostname),
+ self.line_fmt % ('address', host_address)]
if host_groups:
- host_config.append(line_fmt % ("hostgroups",
- ",".join(host_groups)))
+ host_config.append(self.line_fmt % ("hostgroups",
+ ",".join(host_groups)))
- # read the old-style Properties config, but emit a warning.
+ # read the config
xtra = dict()
- props = None
- if (hasattr(metadata, 'Properties') and
- 'NagiosGen.xml' in metadata.Properties):
- props = metadata.Properties['NagiosGen.xml'].data
- if props is not None:
- LOGGER.warn("Parsing deprecated Properties/NagiosGen.xml. "
- "Update to the new-style config with "
- "nagiosgen-convert.py.")
- xtra = dict((el.tag, el.text)
- for el in props.find(metadata.hostname))
- # hold off on parsing the defaults until we've checked for
- # a new-style config
-
- # read the old-style parents.xml, but emit a warning
- pfile = os.path.join(self.data, "parents.xml")
- if os.path.exists(pfile):
- LOGGER.warn("Parsing deprecated NagiosGen/parents.xml. "
- "Update to the new-style config with "
- "nagiosgen-convert.py.")
- parents = lxml.etree.parse(pfile,
- parser=Bcfg2.Server.XMLParser)
- for el in parents.xpath("//Depend[@name='%s']" % metadata.hostname):
- if 'parent' in xtra:
- xtra['parent'] += "," + el.get("on")
- else:
- xtra['parent'] = el.get("on")
-
- # read the new-style config and overwrite the old-style config
for el in self.config.Match(metadata):
if el.tag == 'Option':
xtra[el.get("name")] = el.text
- # if we haven't found anything in the new- or old-style
- # configs, finally read defaults from old-style config
- if not xtra and props is not None:
- xtra = dict((el.tag, el.text) for el in props.find('default'))
-
if xtra:
- host_config.extend([line_fmt % (opt, val)
+ host_config.extend([self.line_fmt % (opt, val)
for opt, val in list(xtra.items())])
else:
- host_config.append(line_fmt % ('use', 'default'))
+ host_config.append(self.line_fmt % ('use', 'default'))
host_config.append('}')
entry.text = "%s\n" % "\n".join(host_config)
- [entry.attrib.__setitem__(key, value)
- for (key, value) in list(self.client_attrib.items())]
+ for (key, value) in list(self.client_attrib.items()):
+ entry.attrib.__setitem__(key, value)
+ fname = os.path.join(self.data, metadata.hostname + "-host.cfg")
try:
- fileh = open("%s/%s-host.cfg" %
- (self.data, metadata.hostname), 'w')
- fileh.write(entry.text)
- fileh.close()
+ open(fname, 'w').write(entry.text)
except OSError:
- ioerr = sys.exc_info()[1]
- LOGGER.error("Failed to write %s/%s-host.cfg" %
- (self.data, metadata.hostname))
- LOGGER.error(ioerr)
+ err = sys.exc_info()[1]
+ self.logger.error("Failed to write %s: %s" % (fname, err))
def createserverconfig(self, entry, _):
"""Build monolithic server configuration file."""
- host_configs = glob.glob('%s/*-host.cfg' % self.data)
- group_configs = glob.glob('%s/*-group.cfg' % self.data)
+ host_configs = glob.glob(os.path.join(self.data, '*-host.cfg'))
+ group_configs = glob.glob(os.path.join(self.data, '*-group.cfg'))
host_data = []
group_data = []
for host in host_configs:
@@ -150,13 +112,11 @@ class NagiosGen(Bcfg2.Server.Plugin.Plugin,
groupfile.close()
entry.text = "%s\n\n%s" % ("\n".join(group_data), "\n".join(host_data))
- [entry.attrib.__setitem__(key, value)
- for (key, value) in list(self.server_attrib.items())]
+ for (key, value) in list(self.server_attrib.items()):
+ entry.attrib.__setitem__(key, value)
+ fname = os.path.join(self.data, "nagiosgen.cfg")
try:
- fileh = open("%s/nagiosgen.cfg" % self.data, 'w')
- fileh.write(entry.text)
- fileh.close()
+ open(fname, 'w').write(entry.text)
except OSError:
- ioerr = sys.exc_info()[1]
- LOGGER.error("Failed to write %s/nagiosgen.cfg" % self.data)
- LOGGER.error(ioerr)
+ err = sys.exc_info()[1]
+ self.logger.error("Failed to write %s: %s" % (fname, err))
diff --git a/src/lib/Bcfg2/Server/Plugins/Ohai.py b/src/lib/Bcfg2/Server/Plugins/Ohai.py
index fbb46f004..ebc03197e 100644
--- a/src/lib/Bcfg2/Server/Plugins/Ohai.py
+++ b/src/lib/Bcfg2/Server/Plugins/Ohai.py
@@ -6,12 +6,10 @@ import lxml.etree
import os
import Bcfg2.Server.Plugin
-# pylint: disable=F0401
try:
import json
except ImportError:
import simplejson as json
-# pylint: enable=F0401
PROBECODE = """#!/bin/sh
diff --git a/src/lib/Bcfg2/Server/Plugins/Packages/Yum.py b/src/lib/Bcfg2/Server/Plugins/Packages/Yum.py
index 592369029..420c65844 100644
--- a/src/lib/Bcfg2/Server/Plugins/Packages/Yum.py
+++ b/src/lib/Bcfg2/Server/Plugins/Packages/Yum.py
@@ -69,7 +69,7 @@ from Bcfg2.Server.Plugins.Packages.Source import SourceInitError, Source, \
LOGGER = logging.getLogger(__name__)
-# pylint: disable=E0611,F0401
+# pylint: disable=E0611
try:
from pulp.client.consumer.config import ConsumerConfig
from pulp.client.api.repository import RepositoryAPI
@@ -78,6 +78,7 @@ try:
HAS_PULP = True
except ImportError:
HAS_PULP = False
+# pylint: enable=E0611
try:
import yum
@@ -91,7 +92,6 @@ except ImportError:
LOGGER.info("Packages: No yum libraries found; forcing use of internal "
"dependency resolver")
-# pylint: enable=E0611,F0401
XP = '{http://linux.duke.edu/metadata/common}'
RP = '{http://linux.duke.edu/metadata/rpm}'
diff --git a/src/lib/Bcfg2/Server/Plugins/Probes.py b/src/lib/Bcfg2/Server/Plugins/Probes.py
index e0f527f2c..872cbb34e 100644
--- a/src/lib/Bcfg2/Server/Plugins/Probes.py
+++ b/src/lib/Bcfg2/Server/Plugins/Probes.py
@@ -10,7 +10,6 @@ import lxml.etree
import Bcfg2.Server
import Bcfg2.Server.Plugin
-# pylint: disable=F0401
try:
from django.db import models
HAS_DJANGO = True
@@ -52,7 +51,6 @@ except ImportError:
HAS_YAML = True
except ImportError:
HAS_YAML = False
-# pylint: enable=F0401
class ClientProbeDataSet(dict):
diff --git a/src/lib/Bcfg2/Server/Plugins/PuppetENC.py b/src/lib/Bcfg2/Server/Plugins/PuppetENC.py
index ebcbf3bcc..801e7006d 100644
--- a/src/lib/Bcfg2/Server/Plugins/PuppetENC.py
+++ b/src/lib/Bcfg2/Server/Plugins/PuppetENC.py
@@ -6,7 +6,6 @@ import Bcfg2.Server
import Bcfg2.Server.Plugin
from subprocess import Popen, PIPE
-# pylint: disable=F0401
try:
from syck import load as yaml_load, error as yaml_error
except ImportError:
@@ -14,7 +13,6 @@ except ImportError:
from yaml import load as yaml_load, YAMLError as yaml_error
except ImportError:
raise ImportError("No yaml library could be found")
-# pylint: enable=F0401
class PuppetENCFile(Bcfg2.Server.Plugin.FileBacked):
diff --git a/src/lib/Bcfg2/Server/Plugins/Svn2.py b/src/lib/Bcfg2/Server/Plugins/Svn2.py
index 110f2c2eb..19093eb6a 100644
--- a/src/lib/Bcfg2/Server/Plugins/Svn2.py
+++ b/src/lib/Bcfg2/Server/Plugins/Svn2.py
@@ -4,13 +4,11 @@ XML-RPC methods. """
import sys
import Bcfg2.Server.Plugin
-# pylint: disable=F0401
try:
import pysvn
HAS_SVN = False
except ImportError:
HAS_SVN = True
-# pylint: enable=F0401
class Svn2(Bcfg2.Server.Plugin.Plugin,
diff --git a/src/lib/Bcfg2/Server/Reports/reports/templatetags/syntax_coloring.py b/src/lib/Bcfg2/Server/Reports/reports/templatetags/syntax_coloring.py
index 70ef49bc1..bd379b98d 100644
--- a/src/lib/Bcfg2/Server/Reports/reports/templatetags/syntax_coloring.py
+++ b/src/lib/Bcfg2/Server/Reports/reports/templatetags/syntax_coloring.py
@@ -8,16 +8,15 @@ from Bcfg2.Compat import u_str
register = template.Library()
-# pylint: disable=E0611,F0401
+# pylint: disable=E0611
try:
from pygments import highlight
from pygments.lexers import get_lexer_by_name
from pygments.formatters import HtmlFormatter
colorize = True
-
except:
colorize = False
-# pylint: enable=E0611,F0401
+# pylint: enable=E0611
@register.filter
diff --git a/testsuite/Testsrc/test_code_checks.py b/testsuite/Testsrc/test_code_checks.py
index d4a82eab4..fbca427f7 100644
--- a/testsuite/Testsrc/test_code_checks.py
+++ b/testsuite/Testsrc/test_code_checks.py
@@ -24,14 +24,6 @@ except ImportError:
# path to Bcfg2 src directory
srcpath = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..",
"src"))
-# we set this in the environment rather than with sys.path because we
-# call pylint, an external command, later, and it needs the modified
-# environment
-if 'PYTHONPATH' in os.environ:
- os.environ['PYTHONPATH'] = os.environ['PYTHONPATH'] + ":" + \
- os.path.join(srcpath, "lib")
-else:
- os.environ['PYTHONPATH'] = os.path.join(srcpath, "lib")
# path to pylint rc file
rcfile = os.path.abspath(os.path.join(os.path.dirname(__file__), "..",
@@ -74,7 +66,6 @@ error_checks = {
"lib/Bcfg2/Server/Plugins": ["Decisions.py",
"Deps.py",
"Ldap.py",
- "NagiosGen.py",
"Pkgmgr.py",
"SSHbase.py",
"SSLCA.py"]
@@ -122,10 +113,21 @@ class TestPylint(Bcfg2TestCase):
@skipIf(not os.path.exists(rcfile), "%s does not exist" % rcfile)
@skipUnless(HAS_PYLINT, "pylint not found, skipping")
def test_lib_full(self):
- full_list = list(set(self._get_paths(full_checks)) -
- set(expand_path_dict(error_checks)))
+ full_list = list((set(self._get_paths(full_checks)) -
+ set(expand_path_dict(error_checks))) -
+ set(expand_path_dict(django_checks)))
self._pylint_full(full_list)
+ @skipUnless(HAS_DJANGO, "Django not found, skipping")
+ @skipIf(not os.path.exists(srcpath), "%s does not exist" % srcpath)
+ @skipIf(not os.path.exists(rcfile), "%s does not exist" % rcfile)
+ @skipUnless(HAS_PYLINT, "pylint not found, skipping")
+ def test_django_full(self):
+ test_list = list(set(self._get_paths(full_checks)) &
+ set(expand_path_dict(django_checks)))
+ return self._pylint_errors(test_list,
+ extra_args=["-d", "E1101"])
+
@skipIf(not os.path.exists(srcpath), "%s does not exist" % srcpath)
@skipIf(not os.path.exists(rcfile), "%s does not exist" % rcfile)
@skipUnless(HAS_PYLINT, "pylint not found, skipping")
@@ -182,7 +184,6 @@ class TestPylint(Bcfg2TestCase):
rv = pylint.wait()
for line in output.splitlines():
- #print line
if self.error_re.search(line):
print(line)
# pylint returns a bitmask, where 1 means fatal errors
diff --git a/testsuite/pylintrc.conf b/testsuite/pylintrc.conf
index 2e4279e75..250929163 100644
--- a/testsuite/pylintrc.conf
+++ b/testsuite/pylintrc.conf
@@ -33,7 +33,7 @@ load-plugins=
# can either give multiple identifier separated by comma (,) or put this option
# multiple time (only on the command line, not in the configuration file where
# it should appear only once).
-disable=W0142,W0511,W0603,W1201,R0201,R0901,R0902,R0903,R0904,R0921,R0922,C0302,I0011
+disable=F0401,W0142,W0511,W0603,W1201,R0201,R0901,R0902,R0903,R0904,R0921,R0922,C0302,I0011
[REPORTS]
@@ -121,7 +121,7 @@ zope=no
# List of members which are set dynamically and missed by pylint inference
# system, and so shouldn't trigger E0201 when accessed. Python regular
# expressions are accepted.
-generated-members=objects,DoesNotExist,isoformat
+generated-members=objects,DoesNotExist,isoformat,filter,save,count,get,add,id
[MISCELLANEOUS]
diff --git a/testsuite/requirements.txt b/testsuite/requirements.txt
index 39418e98b..8529b247f 100644
--- a/testsuite/requirements.txt
+++ b/testsuite/requirements.txt
@@ -2,3 +2,4 @@ lxml
nose
mock
sphinx
+daemon