def reload_config(): """ convenience function to read in new config. Not sure if it is kosher.. So if in doubt, restart pyfusion. Fails to forget lines that were commented out maybe need also config = PyfusionConfigParser() and return it but this is worse - commented out. """ #config = PyfusionConfigParser() read_config([DEFAULT_CONFIG_FILE, USER_CONFIG_FILE, USER_ENV_CONFIG_FILE])
def reload_config(): """ convenience function to read in new config. Not sure if it is kosher.. So if in doubt, restart pyfusion. Fails to forget lines that were commented out maybe need also config = PyfusionConfigParser() and return it but this is worse - commented out. """ #config = PyfusionConfigParser() # can't import from this level? py3? to do with whether this is used as a module #from conf.utils import clear_config # clear it to try to remove old defs #clear_config() read_config([DEFAULT_CONFIG_FILE, USER_CONFIG_FILE, USER_ENV_CONFIG_FILE])
# Now we actually load the configuration files. Settings in # DEFAULT_CONFIG_FILE will be superseded by those in USER_CONFIG_FILE, # and USER_ENV_CONFIG_FILE will supersede both. As well as storing the # settings, read_config() will set up the ORM backend if required. # Note that the $HOME/.pyfusion file overrides the $PYFUSION_ROOT_DIR file. DEBUG = os.getenv('PYFUSION_DEBUG', '0') # probably better as an env var try: # if it looks like an int, make it one. DEBUG = int(DEBUG) except: pass # VERBOSE is likely to be used as an env var for debugging and as a config # var, depending on taste. VERBOSE = int(os.getenv('PYFUSION_VERBOSE', '0')) # allows config info to be debugged read_config([DEFAULT_CONFIG_FILE, USER_CONFIG_FILE, USER_ENV_CONFIG_FILE]) # verbosity level from environment has priority, otherwise use config, which # defaults to 0. Note that we looked at the env var previously to allow debug of config VERBOSE = int( os.getenv('PYFUSION_VERBOSE', config.get('global', 'VERBOSE', vars={'VERBOSE': '0'}))) ## Variable precision - allows data sets to be much bigger - up to 4x bdb Dec-2012 root_dir = os.path.split(os.path.abspath(__file__))[0] try: from numpy import dtype as npdtype # Beware! vars takes precedence over others! prec_med = npdtype(config.get( 'global', 'precision_medium')) #,vars={'precision_medium':'float32'}))
return(DEBUG) else: return(0) # VERBOSE is likely to be used as an env var for debugging and as a config # var, depending on taste. VERBOSE = int(os.getenv('PYFUSION_VERBOSE','0')) # allows config info to be debugged #read_config([DEFAULT_CONFIG_FILE, USER_CONFIG_FILE, USER_ENV_CONFIG_FILE]) """ Common stuff in DEFAULT_CONFIG_FILE, including my_tmp Computer specific personalisation in USER_CONFIG_FILE e.g. my_tmp = /tmp/blackwell Conputer independent personalisation in USER_ENV_CONFIG_FILE the USER_CONFIG file (.pyfusion) must be after DEFAULT_CONFIG to override defaults """ read_config([DEFAULT_CONFIG_FILE, USER_CONFIG_FILE, USER_ENV_CONFIG_FILE]) def reload_config(): """ convenience function to read in new config. Not sure if it is kosher.. So if in doubt, restart pyfusion. Fails to forget lines that were commented out maybe need also config = PyfusionConfigParser() and return it but this is worse - commented out. """ #config = PyfusionConfigParser() read_config([DEFAULT_CONFIG_FILE, USER_CONFIG_FILE, USER_ENV_CONFIG_FILE]) #return(config) # verbosity level from environment has priority, otherwise use config, which # defaults to 0. Note that we looked at the env var previously to allow debug of config VERBOSE = int(os.getenv('PYFUSION_VERBOSE',