1 ##############################################################################
2 # Copyright (c) 2015 Orange
3 # guyrodrigue.koffi@orange.com / koffirodrigue@gmail.com
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
8 # feng.xiaowei@zte.com.cn remove prepare_put_request 5-30-2016
9 ##############################################################################
18 self.file = self.CONFIG if self.CONFIG else self._default_config()
22 if not os.path.exists(self.file):
23 raise Exception("%s not found" % self.file)
25 config = ConfigParser.RawConfigParser()
26 config.read(self.file)
27 self._parse_section(config)
29 def _parse_section(self, config):
30 [self._parse_item(config, section) for section in (config.sections())]
32 def _parse_item(self, config, section):
33 [setattr(self, '{}_{}'.format(section, k), self._parse_value(v))
34 for k, v in config.items(section)]
37 def _parse_value(value):
41 if str(value).lower() == 'true':
43 elif str(value).lower() == 'false':
48 def _default_config():
49 is_venv = os.getenv('VIRTUAL_ENV')
50 return os.path.join('/' if not is_venv else is_venv,
51 'etc/opnfv_testapi/config.ini')