From 52b0407b5313fd4892d75f7026f3c49fc7d7fbe4 Mon Sep 17 00:00:00 2001 From: ocket8888 Date: Mon, 23 Jul 2018 11:14:33 -0600 Subject: [PATCH] fixed some references to old global config values --- connvitals/__init__.py | 26 +++++++++----------------- connvitals/config.py | 2 +- 2 files changed, 10 insertions(+), 18 deletions(-) diff --git a/connvitals/__init__.py b/connvitals/__init__.py index a3da80c..04a2450 100644 --- a/connvitals/__init__.py +++ b/connvitals/__init__.py @@ -39,17 +39,18 @@ def main() -> int: prematurely with a fatal error. """ - from . import utils from . import config - from . import collector config.init() # No hosts could be parsed - if not config.HOSTS: + if not config.CONFIG or not config.CONFIG.HOSTS: + from . import utils utils.error("No hosts could be parsed! Exiting...", True) - collectors = [collector.Collector(host,i+1) for i,host in enumerate(config.HOSTS)] + from . import collector + + collectors = [collector.Collector(host,i+1) for i,host in enumerate(config.CONFIG.HOSTS)] # Start all the collectors for collect in collectors: @@ -57,19 +58,10 @@ def main() -> int: # Wait for every collector to finish # Print JSON if requested - if config.JSON: - for collect in collectors: - _ = collect.join() - collect.result = collect.recv() - print(repr(collect)) - - # ... else print plaintext - else: - for collect in collectors: - _ = collect.join() - collect.result = collect.recv() - print(collect) - + for collect in collectors: + _ = collect.join() + collect.result = collect.recv() + print(repr(collect) if collect.conf.JSON else collect) # Errors will be indicated on stdout; because we query multiple hosts, as # long as the main routine doesn't crash, we have exited successfully. diff --git a/connvitals/config.py b/connvitals/config.py index 16be2d6..ac7f410 100644 --- a/connvitals/config.py +++ b/connvitals/config.py @@ -134,7 +134,7 @@ def init(): # Parse the list of hosts and try to find valid addresses for each CONFIG.HOSTS = {} - for host in hosts: + for host in args.hosts: info = utils.getaddr(host) if not info: utils.error("Unable to resolve host ( %s )" % host)