tuned-adm: Fix a traceback when run without action specified

This commit is contained in:
Ondřej Lysoněk 2018-07-10 15:02:28 +02:00
parent 37a962cee5
commit bb8072409d
2 changed files with 47 additions and 1 deletions

View File

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

View File

@ -32,7 +32,7 @@
Summary: A dynamic adaptive system tuning daemon
Name: tuned
Version: 2.10.0
Release: 1%{?prerel1}%{?dist}
Release: 2%{?prerel1}%{?dist}
License: GPLv2+
Source0: https://github.com/redhat-performance/%{name}/archive/v%{version}%{?prerel2}.tar.gz#/%{name}-%{version}%{?prerel1}.tar.gz
URL: http://www.tuned-project.org/
@ -55,7 +55,10 @@ Requires: util-linux, dbus, polkit
%if 0%{?fedora} > 22 || 0%{?rhel} > 7
Recommends: kernel-tools
%endif
# Upstream patch:
Patch0: tuned-2.10.0-python-3.7-fix.patch
# Upstream patch:
Patch1: 0001-tuned-adm-Fix-a-traceback-when-run-without-action-sp.patch
%description
The tuned package contains a daemon that tunes system settings dynamically.
@ -201,6 +204,7 @@ It can be also used to fine tune your system for specific scenarios.
%prep
%setup -q -n %{name}-%{version}%{?prerel2}
%patch0 -p1
%patch1 -p1
%build
@ -433,6 +437,10 @@ fi
%{_mandir}/man7/tuned-profiles-compat.7*
%changelog
* Tue Jul 10 2018 Ondřej Lysoněk <olysonek@redhat.com> - 2.10.0-2
- tuned-adm: Fix a traceback when run without action specified
- Fixed compatibility with python-3.7
* Wed Jul 4 2018 Jaroslav Škarvada <jskarvad@redhat.com> - 2.10.0-1
- new release
- rebased tuned to latest upstream