CryptoBoxLogger is obsolete; removed some RFCs we discussed via jabber

This commit is contained in:
age 2006-08-21 10:10:40 +00:00
parent 76ec1ee0ca
commit 04c2719c8e
3 changed files with 12 additions and 13 deletions

View file

@ -7,7 +7,6 @@ progress. So things might be confusing here. Hopefully not for long.
:) :)
''' '''
import CryptoBoxLogger
import CryptoBoxContainer import CryptoBoxContainer
import types import types
import re import re
@ -33,7 +32,6 @@ class CryptoBox:
def __initLogging(self): def __initLogging(self):
import logging 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 '''initialises the logging system
use it with: 'self.log.[debug|info|warning|error|critical](logmessage)' use it with: 'self.log.[debug|info|warning|error|critical](logmessage)'
@ -59,7 +57,6 @@ class CryptoBox:
def __initPreferences(self, config_file): def __initPreferences(self, config_file):
# RFC: this try-except should happen at the top of the script - or? [l]
try: try:
import configobj ## needed for reading and writing of the config file import configobj ## needed for reading and writing of the config file
except: except:
@ -104,6 +101,7 @@ class CryptoBox:
# RFC: what is this method useful for? # RFC: what is this method useful for?
# as it claims, just for demonstrating inheritance effects
def cbx_inheritance_test(self): def cbx_inheritance_test(self):
print "you lucky widow" print "you lucky widow"
@ -125,11 +123,6 @@ class CryptoBoxProps(CryptoBox):
#print self.cbxPrefs.items() #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 = [] self.containers = []
for device in self.__getAvailablePartitions(): for device in self.__getAvailablePartitions():
if self.isDeviceAllowed(device): if self.isDeviceAllowed(device):
@ -154,8 +147,7 @@ class CryptoBoxProps(CryptoBox):
if filterType in range(len(CryptoBoxContainer.Types)): if filterType in range(len(CryptoBoxContainer.Types)):
return [e for e in self.containers if e.getType() == filterType] return [e for e in self.containers if e.getType() == filterType]
else: else:
self.logger.debugMessage( self.log.info("invalid filterType (%d)" % filterType)
"info", "invalid filterType (%d)" % filterType)
result.clear() result.clear()
if filterName != None: if filterName != None:
result = [e for e in self.containers if e.getName() == filterName] result = [e for e in self.containers if e.getName() == filterName]
@ -223,7 +215,7 @@ class CryptoBoxProps(CryptoBox):
fpart.close() fpart.close()
return [self.__getAbsoluteDeviceName(e) for e in ret_list] return [self.__getAbsoluteDeviceName(e) for e in ret_list]
except IOError: except IOError:
self.debugMessage("Could not read /proc/partitions", "warn") self.log.warning("Could not read /proc/partitions")
return [] return []
@ -331,13 +323,15 @@ cryptsetup = /sbin/cryptsetup
def testConfigFile(self): def testConfigFile(self):
# RFC: which 'age' did a commit with a broken unittest? [l] # 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() CryptoBoxProps()
self.assertTrue(os.path.exists(self.nameDBFile)) self.assertTrue(os.path.exists(self.nameDBFile))
self.assertTrue(os.path.exists(self.logFile)) self.assertTrue(os.path.exists(self.logFile))
def testDeviceCheck(self): def testDeviceCheck(self):
# RFC: dito [l]
cb = CryptoBoxProps() cb = CryptoBoxProps()
self.assertTrue(cb.isDeviceAllowed("/dev/loop")) self.assertTrue(cb.isDeviceAllowed("/dev/loop"))
self.assertTrue(cb.isDeviceAllowed("/dev/loop1")) self.assertTrue(cb.isDeviceAllowed("/dev/loop1"))

View file

@ -1,4 +1,6 @@
''' '''
this class will not be used anymore and can be removed from svn
manages logging events of the CryptoBox manages logging events of the CryptoBox
''' '''

View file

@ -4,11 +4,14 @@ Maybe we can add some notes here to get a consistent coding experience :)
comments: comments:
- should be usable for pydoc - 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: error handling:
- unspecific error handling is evil (try: "grep -r except: .") - unspecific error handling is evil (try: "grep -r except: .")
unit testing: 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) - commits with broken unit tests are evil (options: fix or disable)
- all classes should contain exhaustive unit tests prior to the first release