Browse Source

BF: delay check for the existence of config directory until read()

pull/163/head
Yaroslav Halchenko 12 years ago
parent
commit
ab044b75ea
  1. 6
      client/configreader.py
  2. 3
      testcases/clientreadertestcase.py

6
client/configreader.py

@ -46,15 +46,15 @@ class ConfigReader(SafeConfigParserWithIncludes):
def setBaseDir(self, basedir):
if basedir is None:
basedir = ConfigReader.DEFAULT_BASEDIR # stock system location
if not (os.path.exists(basedir) and os.access(basedir, os.R_OK | os.X_OK)):
raise ValueError("Base configuration directory %s either does not exist "
"or is not accessible" % basedir)
self._basedir = basedir.rstrip('/')
def getBaseDir(self):
return self._basedir
def read(self, filename):
if not (os.path.exists(self._basedir) and os.access(self._basedir, os.R_OK | os.X_OK)):
raise ValueError("Base configuration directory %s either does not exist "
"or is not accessible" % self._basedir)
basename = os.path.join(self._basedir, filename)
logSys.debug("Reading configs for %s under %s " % (basename, self._basedir))
config_files = [ basename + ".conf",

3
testcases/clientreadertestcase.py

@ -114,7 +114,8 @@ class JailsReaderTest(unittest.TestCase):
def testProvidingBadBasedir(self):
if not os.path.exists('/XXX'):
self.assertRaises(ValueError, JailsReader, basedir='/XXX')
reader = JailsReader(basedir='/XXX')
self.assertRaises(ValueError, reader.read)
def testReadStockJailConf(self):
jails = JailsReader(basedir='config') # we are running tests from root project dir atm

Loading…
Cancel
Save