From f911ad025a2ea0b69783cc1c4937687e0644f977 Mon Sep 17 00:00:00 2001 From: RODRIGO MONTENEGRO <62527805+rmontenegroo@users.noreply.github.com> Date: Mon, 20 Apr 2020 04:07:36 -0300 Subject: [PATCH] feat(deprecate_yamlconfig): Deprecate yamlconfig (#192) * Fix to issue #179: removing yamlconfig, and using PyYAML itself instead --- requirements-tests.txt | 8 ++++---- requirements.txt | 2 +- vmware_exporter/vmware_exporter.py | 6 ++++-- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/requirements-tests.txt b/requirements-tests.txt index 7b75bfc..d455f3d 100644 --- a/requirements-tests.txt +++ b/requirements-tests.txt @@ -1,6 +1,6 @@ pytest_docker_tools==0.2.0 -pytest==3.3 -pytest-cov==2.6.0 -pytest-twisted==1.8 -codecov==2.0.15 +pytest==5.4.1 +pytest-cov==2.8.1 +pytest-twisted==1.12 +codecov==2.0.17 flake8==3.6.0 diff --git a/requirements.txt b/requirements.txt index a5b7bd8..1632de7 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,5 +2,5 @@ prometheus-client==0.0.19 pytz pyvmomi>=6.5 twisted>=14.0.2 -yamlconfig +pyyaml service-identity diff --git a/vmware_exporter/vmware_exporter.py b/vmware_exporter/vmware_exporter.py index be2bb77..cf5568b 100755 --- a/vmware_exporter/vmware_exporter.py +++ b/vmware_exporter/vmware_exporter.py @@ -17,7 +17,7 @@ import pytz import logging -from yamlconfig import YamlConfig +import yaml # Twisted from twisted.web.server import Site, NOT_DONE_YET @@ -938,7 +938,9 @@ def __init__(self, args): def configure(self, args): if args.config_file: try: - self.config = YamlConfig(args.config_file) + with open(args.config_file) as cf: + self.config = yaml.load(cf, Loader=yaml.FullLoader) + if 'default' not in self.config.keys(): logging.error("Error, you must have a default section in config file (for now)") exit(1)