arvados.config
1# Copyright (C) The Arvados Authors. All rights reserved. 2# 3# SPDX-License-Identifier: Apache-2.0 4 5# config.py - configuration settings and global variables for Arvados clients 6# 7# Arvados configuration settings are taken from $HOME/.config/arvados. 8# Environment variables override settings in the config file. 9 10import os 11import re 12 13_settings = None 14if os.environ.get('HOME') is not None: 15 default_config_file = os.environ['HOME'] + '/.config/arvados/settings.conf' 16else: 17 default_config_file = '' 18 19KEEP_BLOCK_SIZE = 2**26 20EMPTY_BLOCK_LOCATOR = 'd41d8cd98f00b204e9800998ecf8427e+0' 21 22def initialize(config_file=default_config_file): 23 global _settings 24 _settings = {} 25 26 # load the specified config file if available 27 try: 28 _settings = load(config_file) 29 except IOError: 30 pass 31 32 # override any settings with environment vars 33 for var in os.environ: 34 if var.startswith('ARVADOS_'): 35 _settings[var] = os.environ[var] 36 37def load(config_file): 38 cfg = {} 39 with open(config_file, "r") as f: 40 for config_line in f: 41 if re.match(r'^\s*(?:#|$)', config_line): 42 continue 43 var, val = config_line.rstrip().split('=', 2) 44 cfg[var] = val 45 return cfg 46 47def flag_is_true(key, d=None): 48 if d is None: 49 d = settings() 50 return d.get(key, '').lower() in set(['1', 't', 'true', 'y', 'yes']) 51 52def get(key, default_val=None): 53 return settings().get(key, default_val) 54 55def settings(): 56 if _settings is None: 57 initialize() 58 return _settings
KEEP_BLOCK_SIZE =
67108864
EMPTY_BLOCK_LOCATOR =
'd41d8cd98f00b204e9800998ecf8427e+0'
def
initialize(config_file='/var/lib/gitolite3/.config/arvados/settings.conf'):
23def initialize(config_file=default_config_file): 24 global _settings 25 _settings = {} 26 27 # load the specified config file if available 28 try: 29 _settings = load(config_file) 30 except IOError: 31 pass 32 33 # override any settings with environment vars 34 for var in os.environ: 35 if var.startswith('ARVADOS_'): 36 _settings[var] = os.environ[var]
def
load(config_file):
def
flag_is_true(key, d=None):
def
get(key, default_val=None):
def
settings():