From 04c2719c8e977edda842a4179384c993f4a43e37 Mon Sep 17 00:00:00 2001 From: age Date: Mon, 21 Aug 2006 10:10:40 +0000 Subject: [PATCH] CryptoBoxLogger is obsolete; removed some RFCs we discussed via jabber --- pythonrewrite/bin2/CryptoBox.py | 18 ++++++------------ pythonrewrite/bin2/CryptoBoxLogger.py | 2 ++ pythonrewrite/bin2/coding_guidelines.txt | 5 ++++- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/pythonrewrite/bin2/CryptoBox.py b/pythonrewrite/bin2/CryptoBox.py index e7b2d4c..29bcf6d 100644 --- a/pythonrewrite/bin2/CryptoBox.py +++ b/pythonrewrite/bin2/CryptoBox.py @@ -7,7 +7,6 @@ progress. So things might be confusing here. Hopefully not for long. :) ''' -import CryptoBoxLogger import CryptoBoxContainer import types import re @@ -33,7 +32,6 @@ class CryptoBox: def __initLogging(self): import logging - # RFC: this import should be at the top of the file - or at least (for clarity) be there in a comment line [l] '''initialises the logging system use it with: 'self.log.[debug|info|warning|error|critical](logmessage)' @@ -59,7 +57,6 @@ class CryptoBox: def __initPreferences(self, config_file): - # RFC: this try-except should happen at the top of the script - or? [l] try: import configobj ## needed for reading and writing of the config file except: @@ -104,6 +101,7 @@ class CryptoBox: # RFC: what is this method useful for? + # as it claims, just for demonstrating inheritance effects def cbx_inheritance_test(self): print "you lucky widow" @@ -125,11 +123,6 @@ class CryptoBoxProps(CryptoBox): #print self.cbxPrefs.items() #### - self.debug = CryptoBoxLogger.CryptoBoxLogger( - self.cbxPrefs["Log"]["Level"], - self.cbxPrefs["Log"]["Facility"], - self.cbxPrefs["Log"]["Destination"]) - self.debugMessage = self.debug.printMessage self.containers = [] for device in self.__getAvailablePartitions(): if self.isDeviceAllowed(device): @@ -154,8 +147,7 @@ class CryptoBoxProps(CryptoBox): if filterType in range(len(CryptoBoxContainer.Types)): return [e for e in self.containers if e.getType() == filterType] else: - self.logger.debugMessage( - "info", "invalid filterType (%d)" % filterType) + self.log.info("invalid filterType (%d)" % filterType) result.clear() if filterName != None: result = [e for e in self.containers if e.getName() == filterName] @@ -223,7 +215,7 @@ class CryptoBoxProps(CryptoBox): fpart.close() return [self.__getAbsoluteDeviceName(e) for e in ret_list] except IOError: - self.debugMessage("Could not read /proc/partitions", "warn") + self.log.warning("Could not read /proc/partitions") return [] @@ -331,13 +323,15 @@ cryptsetup = /sbin/cryptsetup def testConfigFile(self): # RFC: which 'age' did a commit with a broken unittest? [l] + # the class has changed, it reads the formerly given + # configfile now out of the parent class + # unittest works for me [a] CryptoBoxProps() self.assertTrue(os.path.exists(self.nameDBFile)) self.assertTrue(os.path.exists(self.logFile)) def testDeviceCheck(self): - # RFC: dito [l] cb = CryptoBoxProps() self.assertTrue(cb.isDeviceAllowed("/dev/loop")) self.assertTrue(cb.isDeviceAllowed("/dev/loop1")) diff --git a/pythonrewrite/bin2/CryptoBoxLogger.py b/pythonrewrite/bin2/CryptoBoxLogger.py index eb7d4c2..a0c9828 100644 --- a/pythonrewrite/bin2/CryptoBoxLogger.py +++ b/pythonrewrite/bin2/CryptoBoxLogger.py @@ -1,4 +1,6 @@ ''' +this class will not be used anymore and can be removed from svn + manages logging events of the CryptoBox ''' diff --git a/pythonrewrite/bin2/coding_guidelines.txt b/pythonrewrite/bin2/coding_guidelines.txt index e5716ee..6345a0d 100644 --- a/pythonrewrite/bin2/coding_guidelines.txt +++ b/pythonrewrite/bin2/coding_guidelines.txt @@ -4,11 +4,14 @@ Maybe we can add some notes here to get a consistent coding experience :) comments: - should be usable for pydoc + - ''' or """ at the beginning of every class/method + - ## for longterm comments, that are useful for understanding + - #blabla for codelines, that are out for experimenting and might be used later again error handling: - unspecific error handling is evil (try: "grep -r except: .") unit testing: + - write a unittest and then write the relating code until the unittest stops failing :) - commits with broken unit tests are evil (options: fix or disable) - - all classes should contain exhaustive unit tests prior to the first release