Blame SOURCES/0001-tuned-adm-Fix-a-traceback-when-run-without-action-sp.patch

1bfeda
From 6678c472abbd5f645dbb99ab2946c0e35ded7499 Mon Sep 17 00:00:00 2001
1bfeda
From: =?UTF-8?q?Ond=C5=99ej=20Lyson=C4=9Bk?= <olysonek@redhat.com>
1bfeda
Date: Tue, 10 Jul 2018 00:24:00 +0200
1bfeda
Subject: [PATCH] tuned-adm: Fix a traceback when run without action specified
1bfeda
MIME-Version: 1.0
1bfeda
Content-Type: text/plain; charset=UTF-8
1bfeda
Content-Transfer-Encoding: 8bit
1bfeda
1bfeda
Running tuned-adm without an action specified using Python 3 results
1bfeda
in a traceback. This is because in this case parse_args does not
1bfeda
exit with a usage message in Python 3 and the 'action' option
1bfeda
is then undefined.
1bfeda
1bfeda
Signed-off-by: Ondřej Lysoněk <olysonek@redhat.com>
1bfeda
---
1bfeda
 tuned-adm.py | 6 +++++-
1bfeda
 1 file changed, 5 insertions(+), 1 deletion(-)
1bfeda
1bfeda
diff --git a/tuned-adm.py b/tuned-adm.py
1bfeda
index 1b9623d..1df8cc3 100755
1bfeda
--- a/tuned-adm.py
1bfeda
+++ b/tuned-adm.py
1bfeda
@@ -100,7 +100,11 @@ if __name__ == "__main__":
1bfeda
 	debug = options.pop("debug")
1bfeda
 	asynco = options.pop("async")
1bfeda
 	timeout = options.pop("timeout")
1bfeda
-	action_name = options.pop("action")
1bfeda
+	try:
1bfeda
+		action_name = options.pop("action")
1bfeda
+	except KeyError:
1bfeda
+		parser.print_usage(file = sys.stderr)
1bfeda
+		sys.exit(1)
1bfeda
 	log_level = options.pop("loglevel")
1bfeda
 	result = False
1bfeda
 
1bfeda
-- 
1bfeda
2.14.4
1bfeda