From c4480311d74279dc735c979bbcb037a9c9e68c28 Mon Sep 17 00:00:00 2001 From: Eeshan Garg Date: Wed, 2 Aug 2017 00:58:55 -0230 Subject: [PATCH] integrations/nagios: Upgrade to argparse. --- zulip/integrations/nagios/nagios-notify-zulip | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/zulip/integrations/nagios/nagios-notify-zulip b/zulip/integrations/nagios/nagios-notify-zulip index cb5f040..aed074f 100755 --- a/zulip/integrations/nagios/nagios-notify-zulip +++ b/zulip/integrations/nagios/nagios-notify-zulip @@ -1,5 +1,5 @@ #!/usr/bin/env python -import optparse +import argparse import zulip from typing import List, Text, Dict, Any @@ -8,14 +8,14 @@ VERSION = "0.9" # Nagios passes the notification details as command line options. # In Nagios, "output" means "first line of output", and "long # output" means "other lines of output". -parser = optparse.OptionParser() # type: optparse.OptionParser -parser.add_option('--output', default='') -parser.add_option('--long-output', default='') -parser.add_option('--stream', default='nagios') -parser.add_option('--config', default='/etc/nagios3/zuliprc') +parser = zulip.add_default_arguments(argparse.ArgumentParser()) # type: argparse.ArgumentParser +parser.add_argument('--output', default='') +parser.add_argument('--long-output', default='') +parser.add_argument('--stream', default='nagios') +parser.add_argument('--config', default='/etc/nagios3/zuliprc') for opt in ('type', 'host', 'service', 'state'): - parser.add_option('--' + opt) -(opts, args) = parser.parse_args() # type: Any, List[Text] + parser.add_argument('--' + opt) +opts = parser.parse_args() client = zulip.Client(config_file=opts.config, client="ZulipNagios/" + VERSION) # type: zulip.Client