nfvbenchvm: refactor wait for VPP service
[nfvbench.git] / nfvbench / config.py
index 4cc9c86..8e77127 100644 (file)
@@ -23,12 +23,12 @@ def config_load(file_name, from_cfg=None, whitelist_keys=None):
     The config file content taking precedence in case of duplicate
     """
     try:
-        with open(file_name) as fileobj:
+        with open(file_name, encoding="utf-8") as fileobj:
             cfg = AttrDict(yaml.safe_load(fileobj))
     except IOError:
         raise Exception("Configuration file at '{}' was not found. Please use correct path "
                         "and verify it is visible to container if you run nfvbench in container."
-                        .format(file_name))
+                        .format(file_name)) from IOError
 
     if from_cfg:
         if not whitelist_keys:
@@ -52,7 +52,7 @@ def config_loads(cfg_text, from_cfg=None, whitelist_keys=None):
         LOG.error("String %s is not well formatted. Please verify your yaml/json string. "
                   "If string is a file path, file was not found. Please use correct path and "
                   "verify it is visible to container if you run nfvbench in container.", cfg_text)
-        raise Exception(e)
+        raise Exception(e) from e
     if from_cfg:
         if not whitelist_keys:
             whitelist_keys = []