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()
20 self.static_path = os.path.join(
21 os.path.dirname(os.path.normpath(__file__)),
26 if not os.path.exists(self.file):
27 raise Exception("%s not found" % self.file)
29 config = ConfigParser.RawConfigParser()
30 config.read(self.file)
31 self._parse_section(config)
33 def _parse_section(self, config):
34 [self._parse_item(config, section) for section in (config.sections())]
36 def _parse_item(self, config, section):
37 [setattr(self, '{}_{}'.format(section, k), self._parse_value(v))
38 for k, v in config.items(section)]
41 def _parse_value(value):
45 if str(value).lower() == 'true':
47 elif str(value).lower() == 'false':
52 def _default_config():
53 is_venv = os.getenv('VIRTUAL_ENV')
54 return os.path.join('/' if not is_venv else is_venv,
55 'etc/opnfv_testapi/config.ini')