aboutsummaryrefslogtreecommitdiffstats
path: root/onap-client
diff options
context:
space:
mode:
authorstark, steven <steven.stark@att.com>2020-04-24 14:41:15 -0700
committerstark, steven <steven.stark@att.com>2020-04-24 14:41:15 -0700
commit4236b7b454a201db1aab3a9dfaad1f7a08785cc0 (patch)
tree5f7c1640bd065e92e63afe9244e1f6dc7ce4a7d1 /onap-client
parentd6b3ac08745b099fbd0ea5ff9feec22a0247bf49 (diff)
[VVP] onap client fails to import if config file not set
Issue-ID: VVP-412 Signed-off-by: stark, steven <steven.stark@att.com> Change-Id: I8c810dd5268c522ea21a40704315051c5daa5292
Diffstat (limited to 'onap-client')
-rw-r--r--onap-client/onap_client/config.py18
-rw-r--r--onap-client/setup.py2
2 files changed, 11 insertions, 9 deletions
diff --git a/onap-client/onap_client/config.py b/onap-client/onap_client/config.py
index 9e6bd35..ffe493f 100644
--- a/onap-client/onap_client/config.py
+++ b/onap-client/onap_client/config.py
@@ -40,12 +40,6 @@ import logging as logger
import os
import yaml
-PATH = "{}/onap_client".format(distutils.sysconfig.PREFIX)
-PAYLOADS_DIR = "{}/payloads".format(PATH)
-APPLICATION_ID = "robot-ete"
-CONFIG_ENV = os.environ.get("OC_CONFIG")
-CONFIG_FILE = CONFIG_ENV or "/etc/onap_client/config.yaml"
-
class Config:
class ConfigClient:
@@ -69,15 +63,18 @@ class Config:
return None
def load(self, *keys):
+ config_data = {}
+
if self.config_file and self.config_file != "NONE":
try:
with open(self.config_file, "r") as f:
config_data = yaml.safe_load(f)
except FileNotFoundError:
logger.warn(
- "Config file {} not found, using default".format(self.config_file)
+ "Config file {} not found, using default.".format(self.config_file)
)
- else:
+
+ if not config_data:
with open("{}/config.example.yaml".format(PATH), "r") as f:
config_data = yaml.safe_load(f)
@@ -93,6 +90,11 @@ def load_config(config_file, *config_args):
return config
+PATH = "{}/onap_client".format(distutils.sysconfig.PREFIX)
+PAYLOADS_DIR = "{}/payloads".format(PATH)
+APPLICATION_ID = "robot-ete"
+CONFIG_ENV = os.environ.get("OC_CONFIG")
+CONFIG_FILE = CONFIG_ENV or "/etc/onap_client/config.yaml"
APP_CONFIG = load_config(CONFIG_FILE, "onap_client")
LOG = logger
log_level = getattr(LOG, APP_CONFIG.LOG_LEVEL.upper())
diff --git a/onap-client/setup.py b/onap-client/setup.py
index 228c921..292b38d 100644
--- a/onap-client/setup.py
+++ b/onap-client/setup.py
@@ -47,7 +47,7 @@ for file in os.listdir("etc/payloads"):
setuptools.setup(
name="onap-client",
- version="0.5.0",
+ version="0.5.1",
author="Steven Stark",
author_email="steven.stark@att.com",
description="Python API wrapper for ONAP applications",