Skip to content

Commit

Permalink
Add CLI support for skipping or only host checking
Browse files Browse the repository at this point in the history
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 ksdme#24
  • Loading branch information
kx-chen committed Nov 5, 2018
1 parent 3bd64ba commit c4f3011
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions org_status/org_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -87,14 +89,18 @@ 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}')
Expand Down

0 comments on commit c4f3011

Please sign in to comment.