summaryrefslogtreecommitdiffstats
path: root/src/lib
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib')
-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
3 files changed, 23 insertions, 19 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',