def __init__(self, path=None): if path is None: path = os.environ.get(Warp17Env.INI_FILE_ENV) if path is None: raise Warp17Exception('Missing ' + Warp17Env.INI_FILE_ENV + ' ' + \ 'environment variable!') self._config = ConfigParser() if not os.path.exists(path): raise Warp17Exception('Missing ' + path + ' config file!') self._config.read_file(open(path)) self._uniq_stamp = os.environ.get(Warp17Env.UNIQ_STAMP, get_uniq_stamp()) self._bin_name = os.environ.get(Warp17Env.BIN, '../build/warp17') self._host_name = os.environ.get(Warp17Env.HOST, 'localhost') self._rpc_port = os.environ.get(Warp17Env.RPC_PORT, '42424') self._init_retry = os.environ.get(Warp17Env.INIT_RETRY, '30')
def get_value(self, name, section=DEFAULTSECT, mandatory=False, cast=None): val = self._config[section].get(name) if mandatory and val is None: raise Warp17Exception('Missing mandatory ' + name + ' variable ' + \ 'in section ' + section + '!') if not val is None and not cast is None: return cast(val) return val