use defaults for SFA_CONFIG_DIR and SFA_DATA_DIR if not found in config file
authorTony Mack <tmack@cs.princeton.edu>
Wed, 11 Nov 2009 18:12:00 +0000 (18:12 +0000)
committerTony Mack <tmack@cs.princeton.edu>
Wed, 11 Nov 2009 18:12:00 +0000 (18:12 +0000)
sfa/util/config.py

index b6c62c0..37f3038 100644 (file)
@@ -31,13 +31,24 @@ class Config:
     def __init__(self, config_file = "/etc/sfa/sfa_config"):
         self.config_file = None
         self.config_path = None
+        self.data_path = None
         self.load(config_file)
 
     def load(self, config_file):
         try:
             execfile(config_file, self.__dict__)
             self.config_file = config_file
+            # path to configuration data
             self.config_path = os.path.dirname(config_file)
+            # path to server data
+            if not hasattr(self, 'SFA_DATA_DIR'):
+                # default to /var/lib/sfa not specified in config
+                self.SFA_DATA_DIR="/var/lib/sfa"
+            # path to config data
+            if not hasattr(self, 'SFA_CONFIG_DIR'):
+                # default to /var/lib/sfa not specified in config
+                self.SFA_CONFIG_DIR="/etc/sfa"
+             
         except IOError, e:
             raise IOError, "Could not find the configuration file: %s" % config_file