From d2c3deeeb22420c6ee697b945ab9497300b48405 Mon Sep 17 00:00:00 2001 From: Kai Chen Date: Sun, 4 Nov 2018 16:43:35 -0800 Subject: [PATCH] Add CLI support for skipping or only host checking Add CLI options --hosts-only and --skip-host-checks which allows users to check for host statuses only or to skip host checks entirely. Closes https://github.com/ksdme/org-status/issues/24 --- org_status/org_status.py | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/org_status/org_status.py b/org_status/org_status.py index 067b371..f267ad6 100644 --- a/org_status/org_status.py +++ b/org_status/org_status.py @@ -73,6 +73,8 @@ def get_argument_parser(): parser.add_argument('--threads', type=int, default=2) parser.add_argument('--no-color', action='store_true') parser.add_argument('--verbose', '-v', action='store_true') + parser.add_argument('--hosts-only', action='store_true') + parser.add_argument('--skip-host-checks', action='store_true') return parser @@ -87,14 +89,19 @@ def main(): for Host, org in generate_fetch_jobs(args.orgs): token = None - try: - if not Host.get_host_status(): - print(styled(f'{Host.HostName} is currently down', 'red')) - continue - else: - verbose(f'{Host.HostName} is up') - except NotImplementedError: - verbose(f'{Host.HostName} does not support checking host status') + if not args.skip_host_checks: + try: + if not Host.get_host_status(): + print(styled(f'{Host.HostName} is currently down', 'red')) + continue + else: + verbose(f'{Host.HostName} is up') + except NotImplementedError: + verbose( + f'{Host.HostName} does not support checking host status') + + if args.hosts_only: + continue if (args.verbose): print(f'processing org {Host.HostName}:{org}')