1 # config.py - configuration settings and global variables for Arvados clients
3 # Arvados configuration settings are taken from $HOME/.config/arvados.
4 # Environment variables override settings in the config file.
10 if os.environ.get('HOME') is not None:
11 default_config_file = os.environ['HOME'] + '/.config/arvados/settings.conf'
13 default_config_file = ''
15 KEEP_BLOCK_SIZE = 2**26
16 EMPTY_BLOCK_LOCATOR = 'd41d8cd98f00b204e9800998ecf8427e+0'
18 def initialize(config_file=default_config_file):
22 # load the specified config file if available
24 _settings = load(config_file)
28 # override any settings with environment vars
29 for var in os.environ:
30 if var.startswith('ARVADOS_'):
31 _settings[var] = os.environ[var]
33 def load(config_file):
35 with open(config_file, "r") as f:
37 if re.match('^\s*$', config_line):
39 if re.match('^\s*#', config_line):
41 var, val = config_line.rstrip().split('=', 2)
45 def flag_is_true(key):
46 return get(key, '').lower() in set(['1', 't', 'true', 'y', 'yes'])
48 def get(key, default_val=None):
49 return settings().get(key, default_val)