1 """@package CrombieTools.CommonTools.FileConfigReader 2 Holds centralized SetupConfigFromEnv functions. 3 @author Daniel Abercrombie <dabercro@mit.edu> 8 from ..
import LoadConfig
11 """Calls functions using environment variables 13 @param targets is a list of tuples, each containing a function and 14 the environment variable to use as an argument 16 for func, envname
in targets:
17 if os.environ.get(envname) ==
None:
18 print 'Cannot find ' + envname +
' in config' 21 func(os.environ[envname])
24 func(float(os.environ[envname]))
26 func(int(os.environ[envname]))
30 """Sets up FileConfigReaders to read the config file automatically. 31 It uses the environment variable $DEBUG to set the verbosity level of a class. 32 The default is 1, with a maximum of 3 for real debugging output. 34 @param obj is the python object that inherits from FileConfigReader. 37 level = int(os.environ.get(
'DEBUG', 1))
38 if os.environ.get(
'DEBUG'):
39 print 'Setting debug level to %i' % level
41 obj.SetDebugLevel(level)
44 obj.ReadMCConfig(config, obj.kBackground)
45 def readSignal(config):
46 obj.ReadMCConfig(config, obj.kSignal)
49 (obj.SetInDirectory,
'CrombieInFilesDir'),
50 (obj.SetLuminosity,
'CrombieLuminosity'),
51 (readMC,
'CrombieMCConfig'),
52 (readSignal,
'CrombieSignalConfig')
55 obj.SetFileType(obj.kBackground)