Hi, Please review this patch.
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1340718 Thanks Amol K.
>From ad4e565f54db5e38102f3cbceeb98b22090c0ef5 Mon Sep 17 00:00:00 2001 From: Amol Kahat <aka...@redhat.com> Date: Tue, 21 Jun 2016 12:47:23 +0530 Subject: [PATCH] Fixes pki-server subsystem-* --help options. Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1340718 --- base/server/python/pki/server/cli/subsystem.py | 165 +++++++++++++------------ 1 file changed, 86 insertions(+), 79 deletions(-) diff --git a/base/server/python/pki/server/cli/subsystem.py b/base/server/python/pki/server/cli/subsystem.py index c92ed16be251af87aa20ddada17da48de2ea4511..a4d91610fd2fa9f575923f3361c5a544bacb1927 100644 --- a/base/server/python/pki/server/cli/subsystem.py +++ b/base/server/python/pki/server/cli/subsystem.py @@ -90,7 +90,7 @@ class SubsystemFindCLI(pki.cli.CLI): self.set_verbose(True) elif o == '--help': - self.print_help() + self.usage() sys.exit() else: @@ -138,12 +138,6 @@ class SubsystemShowCLI(pki.cli.CLI): self.usage() sys.exit(1) - if len(args) != 1: - print('ERROR: missing subsystem ID') - self.usage() - sys.exit(1) - - subsystem_name = args[0] instance_name = 'pki-tomcat' for o, a in opts: @@ -154,7 +148,7 @@ class SubsystemShowCLI(pki.cli.CLI): self.set_verbose(True) elif o == '--help': - self.print_help() + self.usage() sys.exit() else: @@ -162,6 +156,13 @@ class SubsystemShowCLI(pki.cli.CLI): self.usage() sys.exit(1) + if len(args) != 1: + print('ERROR: missing subsystem ID') + self.usage() + sys.exit(1) + + subsystem_name = args[0] + instance = pki.server.PKIInstance(instance_name) instance.load() @@ -195,12 +196,6 @@ class SubsystemEnableCLI(pki.cli.CLI): self.usage() sys.exit(1) - if len(args) != 1: - print('ERROR: missing subsystem ID') - self.usage() - sys.exit(1) - - subsystem_name = args[0] instance_name = 'pki-tomcat' for o, a in opts: @@ -211,7 +206,7 @@ class SubsystemEnableCLI(pki.cli.CLI): self.set_verbose(True) elif o == '--help': - self.print_help() + self.usage() sys.exit() else: @@ -219,6 +214,13 @@ class SubsystemEnableCLI(pki.cli.CLI): self.usage() sys.exit(1) + if len(args) != 1: + print('ERROR: missing subsystem ID') + self.usage() + sys.exit(1) + + subsystem_name = args[0] + instance = pki.server.PKIInstance(instance_name) instance.load() @@ -257,12 +259,6 @@ class SubsystemDisableCLI(pki.cli.CLI): self.usage() sys.exit(1) - if len(args) != 1: - print('ERROR: missing subsystem ID') - self.usage() - sys.exit(1) - - subsystem_name = args[0] instance_name = 'pki-tomcat' for o, a in opts: @@ -273,7 +269,7 @@ class SubsystemDisableCLI(pki.cli.CLI): self.set_verbose(True) elif o == '--help': - self.print_help() + self.usage() sys.exit() else: @@ -281,6 +277,13 @@ class SubsystemDisableCLI(pki.cli.CLI): self.usage() sys.exit(1) + if len(args) != 1: + print('ERROR: missing subsystem ID') + self.usage() + sys.exit(1) + + subsystem_name = args[0] + instance = pki.server.PKIInstance(instance_name) instance.load() @@ -342,12 +345,6 @@ class SubsystemCertFindCLI(pki.cli.CLI): self.print_help() sys.exit(1) - if len(args) != 1: - print('ERROR: missing subsystem ID') - self.print_help() - sys.exit(1) - - subsystem_name = args[0] instance_name = 'pki-tomcat' show_all = False @@ -370,6 +367,13 @@ class SubsystemCertFindCLI(pki.cli.CLI): self.print_help() sys.exit(1) + if len(args) != 1: + print('ERROR: missing subsystem ID') + self.print_help() + sys.exit(1) + + subsystem_name = args[0] + instance = pki.server.PKIInstance(instance_name) instance.load() @@ -414,18 +418,6 @@ class SubsystemCertShowCLI(pki.cli.CLI): self.usage() sys.exit(1) - if len(args) < 1: - print('ERROR: missing subsystem ID') - self.usage() - sys.exit(1) - - if len(args) < 2: - print('ERROR: missing cert ID') - self.usage() - sys.exit(1) - - subsystem_name = args[0] - cert_id = args[1] instance_name = 'pki-tomcat' for o, a in opts: @@ -436,7 +428,7 @@ class SubsystemCertShowCLI(pki.cli.CLI): self.set_verbose(True) elif o == '--help': - self.print_help() + self.usage() sys.exit() else: @@ -444,6 +436,20 @@ class SubsystemCertShowCLI(pki.cli.CLI): self.usage() sys.exit(1) + if len(args) < 1: + print('ERROR: missing subsystem ID') + self.usage() + sys.exit(1) + + + if len(args) < 2: + print('ERROR: missing cert ID') + self.usage() + sys.exit(1) + + subsystem_name = args[0] + cert_id = args[1] + instance = pki.server.PKIInstance(instance_name) instance.load() @@ -491,13 +497,6 @@ class SubsystemCertExportCLI(pki.cli.CLI): self.print_help() sys.exit(1) - if len(args) < 1: - print('ERROR: missing subsystem ID') - self.print_help() - sys.exit(1) - - subsystem_name = args[0] - instance_name = 'pki-tomcat' cert_file = None csr_file = None @@ -556,6 +555,13 @@ class SubsystemCertExportCLI(pki.cli.CLI): self.print_help() sys.exit(1) + if len(args) < 1: + print('ERROR: missing subsystem ID') + self.print_help() + sys.exit(1) + + subsystem_name = args[0] + if not (cert_file or csr_file or pkcs12_file): print('ERROR: missing output file') self.print_help() @@ -646,18 +652,6 @@ class SubsystemCertUpdateCLI(pki.cli.CLI): self.usage() sys.exit(1) - if len(args) < 1: - print('ERROR: missing subsystem ID') - self.usage() - sys.exit(1) - - if len(args) < 2: - print('ERROR: missing cert ID') - self.usage() - sys.exit(1) - - subsystem_name = args[0] - cert_id = args[1] instance_name = 'pki-tomcat' for o, a in opts: @@ -668,7 +662,7 @@ class SubsystemCertUpdateCLI(pki.cli.CLI): self.set_verbose(True) elif o == '--help': - self.print_help() + self.usage() sys.exit() else: @@ -676,6 +670,19 @@ class SubsystemCertUpdateCLI(pki.cli.CLI): self.usage() sys.exit(1) + if len(args) < 1: + print('ERROR: missing subsystem ID') + self.usage() + sys.exit(1) + + if len(args) < 2: + print('ERROR: missing cert ID') + self.usage() + sys.exit(1) + + subsystem_name = args[0] + cert_id = args[1] + instance = pki.server.PKIInstance(instance_name) instance.load() @@ -745,6 +752,24 @@ class SubsystemCertValidateCLI(pki.cli.CLI): self.usage() sys.exit(1) + instance_name = 'pki-tomcat' + + for o, a in opts: + if o in ('-i', '--instance'): + instance_name = a + + elif o in ('-v', '--verbose'): + self.set_verbose(True) + + elif o == '--help': + self.usage() + sys.exit() + + else: + self.print_message('ERROR: unknown option ' + o) + self.usage() + sys.exit(1) + if len(args) < 1: print('ERROR: missing subsystem ID') self.usage() @@ -757,24 +782,6 @@ class SubsystemCertValidateCLI(pki.cli.CLI): else: cert_id = None - instance_name = 'pki-tomcat' - - for o, a in opts: - if o in ('-i', '--instance'): - instance_name = a - - elif o in ('-v', '--verbose'): - self.set_verbose(True) - - elif o == '--help': - self.print_help() - sys.exit() - - else: - self.print_message('ERROR: unknown option ' + o) - self.usage() - sys.exit(1) - instance = pki.server.PKIInstance(instance_name) instance.load() -- 2.5.5
_______________________________________________ Pki-devel mailing list Pki-devel@redhat.com https://www.redhat.com/mailman/listinfo/pki-devel