Added a user-friendly output to an import error

Reviewed-By: Martin Basti <mbasti@redhat.com>
This commit is contained in:
Oleg Fayans
2015-08-24 16:31:28 +02:00
committed by Martin Basti
parent 1255dbf2fd
commit b93137c196
+5 -1
View File
@@ -107,7 +107,11 @@ def get_global_config(env=None):
def config_from_env(env):
if 'IPATEST_YAML_CONFIG' in env:
import yaml
try:
import yaml
except ImportError as e:
raise ImportError("%s, please install PyYAML package to fix it" %
e.message)
with open(env['IPATEST_YAML_CONFIG']) as file:
confdict = yaml.safe_load(file)
return Config.from_dict(confdict)