@ -52,9 +52,9 @@ class ConfigReader(SafeConfigParserWithIncludes):
return self . _basedir
return self . _basedir
def read ( self , filename ) :
def read ( self , filename ) :
if not ( os . path . exists ( self . _basedir ) and os . access ( self . _basedir , os . R_OK | os . X_OK ) ) :
if not os . path . exists ( self . _basedir ) :
raise ValueError ( " Base configuration directory %s either does not exist "
raise ValueError ( " Base configuration directory %s does not exist "
" or is not accessible " % self . _basedir )
% self . _basedir )
basename = os . path . join ( self . _basedir , filename )
basename = os . path . join ( self . _basedir , filename )
logSys . debug ( " Reading configs for %s under %s " % ( basename , self . _basedir ) )
logSys . debug ( " Reading configs for %s under %s " % ( basename , self . _basedir ) )
config_files = [ basename + " .conf " ,
config_files = [ basename + " .conf " ,
@ -65,27 +65,20 @@ class ConfigReader(SafeConfigParserWithIncludes):
# possible further customizations under a .conf.d directory
# possible further customizations under a .conf.d directory
config_dir = basename + ' .d '
config_dir = basename + ' .d '
if os . path . exists ( config_dir ) :
if os . path . isdir ( config_dir ) and os . access ( config_dir , os . X_OK | os . R_OK ) :
# files must carry .conf suffix as well
config_files + = sorted ( glob . glob ( ' %s /*.conf ' % config_dir ) )
config_files + = sorted ( glob . glob ( ' %s /*.conf ' % config_dir ) )
else :
logSys . warn ( " %s exists but not a directory or not accessible "
% config_dir )
# check if files are accessible, warn if any is not accessible
# and remove it from the list
config_files_accessible = [ ]
for f in config_files :
if os . access ( f , os . R_OK ) :
config_files_accessible . append ( f )
else :
logSys . warn ( " %s exists but not accessible - skipping " % f )
if len ( config_files _accessible ) :
if len ( config_files ) :
# at least one config exists and accessible
# at least one config exists and accessible
SafeConfigParserWithIncludes . read ( self , config_files_accessible )
logSys . debug ( " Reading config files: " + ' , ' . join ( config_files ) )
config_files_read = SafeConfigParserWithIncludes . read ( self , config_files )
missed = [ cf for cf in config_files if cf not in config_files_read ]
if missed :
logSys . error ( " Could not read config files: " + ' , ' . join ( missed ) )
if config_files_read :
return True
return True
logSys . error ( " Found no accessible config files for %r under %s " %
( filename , self . getBaseDir ( ) ) )
return False
else :
else :
logSys . error ( " Found no accessible config files for %r " % filename
logSys . error ( " Found no accessible config files for %r " % filename
+ ( [ " under %s " % self . getBaseDir ( ) ,
+ ( [ " under %s " % self . getBaseDir ( ) ,