summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris St. Pierre <chris.a.st.pierre@gmail.com>2012-10-09 07:13:46 -0400
committerChris St. Pierre <chris.a.st.pierre@gmail.com>2012-10-09 07:13:46 -0400
commit7a2a69a0c5a79c88874dd3ea3c9cecfb243fad4f (patch)
treeabde34166426cc2c67eec2b7015872544c4b17cd
parenta4680a0a4ffbf7c2acf07158c1840bc849c563e7 (diff)
downloadbcfg2-7a2a69a0c5a79c88874dd3ea3c9cecfb243fad4f.tar.gz
bcfg2-7a2a69a0c5a79c88874dd3ea3c9cecfb243fad4f.tar.bz2
bcfg2-7a2a69a0c5a79c88874dd3ea3c9cecfb243fad4f.zip
fix pylint unit test errors
-rw-r--r--src/lib/Bcfg2/Options.py3
-rw-r--r--src/lib/Bcfg2/Server/Core.py11
-rw-r--r--src/lib/Bcfg2/settings.py28
-rw-r--r--testsuite/Testsrc/test_code_checks.py5
4 files changed, 26 insertions, 21 deletions
diff --git a/src/lib/Bcfg2/Options.py b/src/lib/Bcfg2/Options.py
index 0b4b1b047..467d9d6d7 100644
--- a/src/lib/Bcfg2/Options.py
+++ b/src/lib/Bcfg2/Options.py
@@ -333,7 +333,10 @@ def get_bool(val):
else:
raise ValueError
+
def get_size(value):
+ """ Given a number of bytes in a human-readable format (e.g.,
+ '512m', '2g'), get the absolute number of bytes as an integer """
if value == -1:
return value
mat = re.match("(\d+)([KkMmGg])?", value)
diff --git a/src/lib/Bcfg2/Server/Core.py b/src/lib/Bcfg2/Server/Core.py
index ae1c578fa..144d226fe 100644
--- a/src/lib/Bcfg2/Server/Core.py
+++ b/src/lib/Bcfg2/Server/Core.py
@@ -152,14 +152,15 @@ class BaseCore(object):
from django.core.exceptions import ImproperlyConfigured
from django.core import management
try:
- management.call_command("syncdb", interactive=False, verbosity=0)
+ management.call_command("syncdb", interactive=False,
+ verbosity=0)
self._database_available = True
except ImproperlyConfigured:
- self.logger.error("Django configuration problem: %s" %
- format_exc().splitlines()[-1])
+ self.logger.error("Django configuration problem: %s" %
+ format_exc().splitlines()[-1])
except:
- self.logger.error("Database update failed: %s" %
- format_exc().splitlines()[-1])
+ self.logger.error("Database update failed: %s" %
+ format_exc().splitlines()[-1])
if '' in setup['plugins']:
setup['plugins'].remove('')
diff --git a/src/lib/Bcfg2/settings.py b/src/lib/Bcfg2/settings.py
index dcd6e4889..190bdff58 100644
--- a/src/lib/Bcfg2/settings.py
+++ b/src/lib/Bcfg2/settings.py
@@ -12,10 +12,10 @@ except ImportError:
# required for reporting
try:
- import south
- has_south = True
-except:
- has_south = False
+ import south # pylint: disable=W0611
+ HAS_SOUTH = True
+except ImportError:
+ HAS_SOUTH = False
DATABASES = dict()
@@ -108,15 +108,6 @@ def read_config(cfile=DEFAULT_CONFIG, repo=None, quiet=False):
else:
MEDIA_URL = '/site_media'
- if HAS_DJANGO and django.VERSION[0] == 1 and django.VERSION[1] < 3:
- CACHE_BACKEND = 'locmem:///'
- else:
- CACHES = {
- 'default': {
- 'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
- }
- }
-
# initialize settings from /etc/bcfg2-web.conf or /etc/bcfg2.conf, or
# set up basic defaults. this lets manage.py work in all cases
read_config(quiet=True)
@@ -140,7 +131,7 @@ INSTALLED_APPS = (
'django.contrib.admin',
'Bcfg2.Server',
)
-if has_south:
+if HAS_SOUTH:
INSTALLED_APPS = INSTALLED_APPS + (
'south',
'Bcfg2.Reporting',
@@ -157,6 +148,15 @@ ADMIN_MEDIA_PREFIX = '/media/'
# Make this unique, and don't share it with anybody.
SECRET_KEY = 'eb5+y%oy-qx*2+62vv=gtnnxg1yig_odu0se5$h0hh#pc*lmo7'
+if HAS_DJANGO and django.VERSION[0] == 1 and django.VERSION[1] < 3:
+ CACHE_BACKEND = 'locmem:///'
+else:
+ CACHES = {
+ 'default': {
+ 'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
+ }
+ }
+
if HAS_DJANGO and django.VERSION[0] == 1 and django.VERSION[1] < 2:
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.load_template_source',
diff --git a/testsuite/Testsrc/test_code_checks.py b/testsuite/Testsrc/test_code_checks.py
index 481dd7fa3..1d1d271d6 100644
--- a/testsuite/Testsrc/test_code_checks.py
+++ b/testsuite/Testsrc/test_code_checks.py
@@ -34,7 +34,8 @@ except OSError:
# perform checks on the listed files only if the module listed in the
# keys can be imported
contingent_checks = {
- ("django",): {"lib/Bcfg2/Server": ["Reports",
+ ("django",): {"lib/Bcfg2": ["Reporting"],
+ "lib/Bcfg2/Server": ["Reports",
"SchemaUpdater",
"models.py"],
"lib/Bcfg2/Server/Admin": ["Reports.py", "Syncdb.py"],
@@ -55,7 +56,7 @@ contingent_checks = {
# perform only error checking on the listed files
error_checks = {
"sbin": ["bcfg2-build-reports", "bcfg2-admin", "bcfg2-reports"],
- "lib/Bcfg2": ["Proxy.py", "SSLServer.py"],
+ "lib/Bcfg2": ["Proxy.py", "SSLServer.py", "Reporting"],
"lib/Bcfg2/Server": ["Reports", "SchemaUpdater"],
"lib/Bcfg2/Server/Admin": ["Backup.py",
"Bundle.py",