diff options
author | Jose Lausuch <jose.lausuch@ericsson.com> | 2017-03-23 09:12:08 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@opnfv.org> | 2017-03-23 09:12:08 +0000 |
commit | 3bda241da0264a6a46cbda51f61931dd4299db20 (patch) | |
tree | 7e53d057e19608b8bec3a72b148fa4a33758dbf4 | |
parent | 2c547487a00ee7d6b0a54a00c73e848dcee12389 (diff) | |
parent | 54e89dde8714fb6080d17d1373a48e36ce60eff3 (diff) |
Merge "start TestAPI in venv with no config-file"
-rw-r--r-- | testapi/opnfv_testapi/common/config.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/testapi/opnfv_testapi/common/config.py b/testapi/opnfv_testapi/common/config.py index 105d4fa..362fca6 100644 --- a/testapi/opnfv_testapi/common/config.py +++ b/testapi/opnfv_testapi/common/config.py @@ -30,7 +30,7 @@ class APIConfig(object): """ def __init__(self): - self._default_config_location = "/etc/opnfv_testapi/config.ini" + self._set_default_config() self.mongo_url = None self.mongo_dbname = None self.api_port = None @@ -39,6 +39,11 @@ class APIConfig(object): self._parser = None self.swagger_base_url = None + def _set_default_config(self): + venv = os.getenv('VIRTUAL_ENV') + self._default_config = os.path.join('/' if not venv else venv, + 'etc/opnfv_testapi/config.ini') + def _get_parameter(self, section, param): try: return self._parser.get(section, param) @@ -66,7 +71,7 @@ class APIConfig(object): obj = APIConfig() if config_location is None: - config_location = obj._default_config_location + config_location = obj._default_config if not os.path.exists(config_location): raise ParseError("%s not found" % config_location) |