3 # load defaults from /etc/monitor.conf
11 cp = ConfigParser.ConfigParser()
13 # load defaults from global, home dir, then $PWD
14 cp.read(['/etc/monitor.conf', os.path.expanduser('~/.monitor.conf'),
15 '.monitor.conf', 'monitor.conf'])
17 self.section = "default"
18 def __getattr__(self, name):
19 if name in self.cp.sections():
23 return self.cp.get(self.section, name)
29 def updatemodule(module, cf):
30 module.__dict__.update(cf.__dict__)
32 def update_section(options, section, bool=False):
33 # Place all default commandline values at the top level of this module
34 for key in options.cp.options(section):
36 config.__dict__.update({key : options.cp.getboolean(section, key)})
38 config.__dict__.update({key : options.cp.get(section, key)})
40 def update(parseoptions):
42 # now update the top-level module with all other args passed in here.
43 for key in parseoptions.__dict__.keys():
44 config.__dict__.update({key: parseoptions.__dict__[key]})
46 if not config.imported:
49 #from config import options as config
52 update_section(options, 'commandline', True)
56 update_section(options, 'monitorconfig')
60 update_section(options, 'monitordatabase')
64 #for i in dir(config):
66 # print i, "==", config.__dict__[i]
67 #print "======================================"