From 7032d060202c6f16d937b8b437570ac1e0f42f33 Mon Sep 17 00:00:00 2001 From: frisco <> Date: Wed, 20 May 2009 05:05:17 +0000 Subject: [PATCH] Fixed inconsistency in logging-related code; fixed size of unit test partitions to equal 50M each --- src/cryptobox/core/blockdevice.py | 2 +- src/cryptobox/core/settings.py | 10 +++++----- src/cryptobox/tests/base.py | 1 - src/cryptobox/tests/test.cryptobox.py | 2 +- src/cryptobox/tests/tools.py | 4 ++-- 5 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/cryptobox/core/blockdevice.py b/src/cryptobox/core/blockdevice.py index 6208c77..813e926 100644 --- a/src/cryptobox/core/blockdevice.py +++ b/src/cryptobox/core/blockdevice.py @@ -41,7 +41,7 @@ OPTIONAL_PROGS = { "lvm": True } change default values from "True" to "False" to disable the respective program """ -LOGGER = logging.getLogger("CryptoBox") +LOGGER = logging.getLogger("CryptoNAS") DEFAULT_SYSBLOCK_DIR = '/sys/block' DEFAULT_DEVNODE_DIR = '/dev' diff --git a/src/cryptobox/core/settings.py b/src/cryptobox/core/settings.py index af79913..1bf1632 100644 --- a/src/cryptobox/core/settings.py +++ b/src/cryptobox/core/settings.py @@ -60,7 +60,7 @@ class CryptoBoxSettings: def __init__(self, config_file=None): self.__is_initialized = False - self.log = logging.getLogger("CryptoBox") + self.log = logging.getLogger("CryptoNAS") config_file = self.__get_config_filename(config_file) self.log.info("loading config file: %s" % config_file) self.prefs = self.__get_preferences(config_file) @@ -542,16 +542,16 @@ class CryptoBoxSettings: "invalid log details for 'syslog': only %s are allowed" % \ str(log_facil_avail)) ## retrive the log priority from the syslog module - log_handler = LocalSysLogHandler("CryptoBox", + log_handler = LocalSysLogHandler("CryptoNAS", getattr(syslog, 'LOG_%s' % log_facility)) log_handler.setFormatter( - logging.Formatter('%(asctime)s CryptoBox %(levelname)s: %(message)s')) + logging.Formatter('%(asctime)s CryptoNAS %(levelname)s: %(message)s')) else: ## this should never happen - we just have it in case someone forgets ## to update the spec, the 'log_dest_avail' or the above branches raise CBConfigInvalidValueError("Log", "Destination", log_destination, "invalid log destination: only %s are allowed" % str(log_dest_avail)) - cbox_log = logging.getLogger("CryptoBox") + cbox_log = logging.getLogger("CryptoNAS") ## remove previous handlers (from 'basicConfig') cbox_log.handlers = [] ## add new one @@ -560,7 +560,7 @@ class CryptoBoxSettings: cbox_log.propagate = False ## 'log_level' is a string -> use 'getattr' cbox_log.setLevel(getattr(logging, log_level)) - ## the logger named "CryptoBox" is configured now + ## the logger named "CryptoNAS" is configured now # We can't use real default values for the "directory_exists" tests below. diff --git a/src/cryptobox/tests/base.py b/src/cryptobox/tests/base.py index 90fd8d3..03fbbc0 100644 --- a/src/cryptobox/tests/base.py +++ b/src/cryptobox/tests/base.py @@ -76,7 +76,6 @@ class CommonTestClass(unittest.TestCase): testtools.umount("%s%d" % (self.blockdevice, num)) ## format device and partition block device if necessary testtools.prepare_partition(self.blockdevice) - self.blockdevice = testtools.find_test_device(self.DRIVE_TO_CLOBBER) self.device = self.blockdevice + "1" self.blockdevice_html = self.blockdevice.replace("/", "%2F") ## the assumption is not always valid - but usually it is ok diff --git a/src/cryptobox/tests/test.cryptobox.py b/src/cryptobox/tests/test.cryptobox.py index 07c498b..2a099c8 100755 --- a/src/cryptobox/tests/test.cryptobox.py +++ b/src/cryptobox/tests/test.cryptobox.py @@ -45,7 +45,7 @@ class CryptoBoxDeviceTests(CommonTestClass): '''is_device_allowed should accept permitted devices''' # check if one of the common devices exists and is allowed blockdevice_found = False - for dev_node in (COMMON_ALLOWED_DEVICES + [ self.blockdevice ]): + for dev_node in (COMMON_ALLOWED_DEVICES): if os.path.exists(dev_node): self.assertTrue(self.cb.is_device_allowed(dev_node)) blockdevice_found = True diff --git a/src/cryptobox/tests/tools.py b/src/cryptobox/tests/tools.py index 66c2550..4fabafd 100644 --- a/src/cryptobox/tests/tools.py +++ b/src/cryptobox/tests/tools.py @@ -94,8 +94,8 @@ def prepare_partition(blockdevice): stdout = subprocess.PIPE, stderr = subprocess.PIPE, args = [ '/sbin/sfdisk', blockdevice ]) - # create two partitions (20MB fat, 20MB ext) - proc.stdin.write(",10,0xC\n,10,L\n") + # create two partitions (50MB fat, 50MB ext) + proc.stdin.write(",50,0xC\n,50,L\n") (output, error) = proc.communicate() if proc.returncode != 0: raise Exception, "could not partition the device (%s): %s" \