adamwill / rpms / openscap

Forked from rpms/openscap 4 years ago
Clone

Blame SOURCES/openscap-1.2.9-oscap-docker-argparse.patch

765ab7
From fa334865b1eb24c6eabfe4c80a339c84ffc2d250 Mon Sep 17 00:00:00 2001
765ab7
From: Martin Preisler <mpreisle@redhat.com>
765ab7
Date: Tue, 31 May 2016 13:05:56 -0400
765ab7
Subject: [PATCH] oscap-docker fixed to be source compatible with py2 and py3
765ab7
765ab7
set_defaults is problematic on subparsers in argparse, it changed
765ab7
behavior in python2 and python3
765ab7
upstream discussion: http://bugs.python.org/issue9351#msg244786
765ab7
---
765ab7
 utils/oscap-docker.in | 5 ++++-
765ab7
 1 file changed, 4 insertions(+), 1 deletion(-)
765ab7
765ab7
diff --git a/utils/oscap-docker.in b/utils/oscap-docker.in
765ab7
index 4ed62fe..f4b0f80 100644
765ab7
--- a/utils/oscap-docker.in
765ab7
+++ b/utils/oscap-docker.in
765ab7
@@ -65,7 +65,6 @@ if __name__ == '__main__':
765ab7
     parser = argparse.ArgumentParser(description='oscap docker',
765ab7
                                      epilog='See `man oscap` to learn \
765ab7
                                      more about OSCAP-ARGUMENTS')
765ab7
-    parser.set_defaults(func=parser.print_help)
765ab7
     subparser = parser.add_subparsers(help="commands")
765ab7
 
765ab7
     # Scan CVEs in image
765ab7
@@ -98,6 +97,10 @@ if __name__ == '__main__':
765ab7
 
765ab7
     args, unknown = parser.parse_known_args()
765ab7
 
765ab7
+    if "func" not in args:
765ab7
+        parser.print_help()
765ab7
+        sys.exit(2)
765ab7
+
765ab7
     try:
765ab7
         ping_docker()
765ab7