Changeset 184:8c6eaaf8908a for StormSiren/Config.py
- Timestamp:
- 11/28/08 15:08:22 (3 years ago)
- Branch:
- unix
- Files:
-
- 1 modified
-
StormSiren/Config.py (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
StormSiren/Config.py
r122 r184 48 48 49 49 class Config(object): 50 def __init__(self, appname, config_file = None, log_config_file = None): 51 self.log = None 50 def __init__(self, appname, config_file = None): 52 51 self.__appname = appname 53 52 self.__config_file = '' … … 55 54 self.__config_dir = self.___getConfigDir() 56 55 self.__config_file = self.__config_dir + '/' + appname + '.conf' 57 self. __log_config_file = self.__config_dir + '/' + appname + '-log.conf'56 self.log = logging.getLogger('Config') 58 57 59 if(log_config_file): 60 self.__log_config_file = log_config_file 61 62 if(os.path.exists(self.__log_config_file)): 63 logging.config.fileConfig(self.__log_config_file) 64 else: 65 print("Log configuration file [%s] not found" % self.__log_config_file) 66 print("See the example StormSiren-log.conf file in the examples directory") 67 if(not os.path.exists(self.__config_dir)): 68 os.mkdir(self.__config_dir) 69 sys.exit(1) 70 71 self.log = logging.getLogger('Config') 72 self.log.debug("Using logging configuration file %s" % self.__log_config_file) 58 self.log.setLevel(logging.INFO) 73 59 74 60 if(config_file): 75 61 self.__config_file = config_file 76 self.log.info("Override configuration file %s" % self.__config_file)77 62 78 63 if(os.path.exists(self.__config_file)): 79 64 self.log.debug("Using configuration file with %s" % self.__config_file) 80 self.__configParser.read(self.__config_file)81 self._load()82 65 else: 83 66 self.log.error("Configuration file [%s] not found" % self.__config_file) … … 121 104 def _load(self): 122 105 self.log.debug("Loading Configuration File") 106 self.__configParser.read(self.__config_file) 123 107 124 108 def __str__(self):
