Browse Source

python-linux-procfs package update

Signed-off-by: basebuilder_pel7ppc64lebuilder0 <basebuilder@powerel.org>
master
basebuilder_pel7ppc64lebuilder0 4 years ago
parent
commit
46e4f2fb7c
  1. 59
      SOURCES/pflags_Use_argparse_to_create_help_option.patch
  2. 40
      SOURCES/pflags_ignore_non-existent_pids.patch
  3. 24
      SPECS/python-linux-procfs.spec

59
SOURCES/pflags_Use_argparse_to_create_help_option.patch

@ -0,0 +1,59 @@ @@ -0,0 +1,59 @@
From 1694ab2ab3628cead18ba7aa59e134e80675c601 Mon Sep 17 00:00:00 2001
From: John Kacur <jkacur@redhat.com>
Date: Fri, 30 Nov 2018 11:50:34 -0500
Subject: [PATCH 1/2] python-linux-procfs: pflags: Use argparse to create a
help option

The purpose of this change is to create a -h or --help option.
In addition the handling of pids or process names is improved. Instead of a
command separated list (without spaces), the more standard unix way of
space separated command line arguments are used.

This is explained in the help.

./pflags -h
usage: pflags [-h] [pid [pid ...]]

Print process flags

positional arguments:
pid a list of pids or names

optional arguments:
-h, --help show this help message and exit

Signed-off-by: John Kacur <jkacur@redhat.com>
---
pflags-cmd.py | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/pflags-cmd.py b/pflags-cmd.py
index 9228c688e7a2..f180ed505977 100755
--- a/pflags-cmd.py
+++ b/pflags-cmd.py
@@ -15,6 +15,7 @@
# General Public License for more details.
import procfs, re, fnmatch, sys
+import argparse
ps = None
@@ -35,8 +36,13 @@ def main(argv):
global ps
ps = procfs.pidstats()
+ parser = argparse.ArgumentParser(description='Print process flags')
+ parser.add_argument('pid', nargs='*', help='a list of pids or names')
+ args = parser.parse_args()
+
if (len(argv) > 1):
- pids = reduce(lambda i, j: i + j, map(thread_mapper, argv[1].split(",")))
+ pids = args.pid
+ pids = reduce(lambda i, j: i + j, list(map(thread_mapper, pids)))
else:
pids = ps.processes.keys()
--
2.19.2

40
SOURCES/pflags_ignore_non-existent_pids.patch

@ -0,0 +1,40 @@ @@ -0,0 +1,40 @@
From e153f5177e1ae4b7859454a2d3011d6f55710600 Mon Sep 17 00:00:00 2001
From: John Kacur <jkacur@redhat.com>
Date: Mon, 3 Dec 2018 09:02:34 -0500
Subject: [PATCH 2/2] python-linux-procfs: pflags: Ignore non-existent pids or
process names

If the user enters a non-existent pid or process name, skip over it.

Also, if the user enters nothing but a non-existent pid, then don't
calculte max_comm_len since you can't take the max of an empty list.

Signed-off-by: John Kacur <jkacur@redhat.com>
---
pflags-cmd.py | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/pflags-cmd.py b/pflags-cmd.py
index f180ed505977..c2627dcec14e 100755
--- a/pflags-cmd.py
+++ b/pflags-cmd.py
@@ -47,11 +47,14 @@ def main(argv):
pids = ps.processes.keys()
pids.sort()
- len_comms = map(lambda pid: len(ps[pid]["stat"]["comm"]), pids)
- max_comm_len = max(len_comms)
+ len_comms = [len(ps[pid]["stat"]["comm"]) for pid in pids if pid in ps]
+ if len_comms:
+ max_comm_len = max(len_comms)
del(len_comms)
for pid in pids:
+ if pid not in ps:
+ continue
flags = ps[pid].stat.process_flags()
# Remove flags that were superseeded
if "PF_THREAD_BOUND" in flags and "PF_NO_SETAFFINITY" in flags:
--
2.19.2

24
SPECS/python-linux-procfs.spec

@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
%{!?python_ver: %define python_ver %(%{__python} -c "import sys ; print sys.version[:3]")}

Name: python-linux-procfs
Version: 0.4.9
Version: 0.4.11
Release: 4%{?dist}
License: GPLv2
Summary: Linux /proc abstraction classes
@ -14,8 +14,10 @@ URL: https://git.kernel.org/pub/scm/libs/python/python-linux-procfs/python-linux @@ -14,8 +14,10 @@ URL: https://git.kernel.org/pub/scm/libs/python/python-linux-procfs/python-linux
# cd python-linux-procfs
# git archive --format=tar --prefix=python-linux-procfs-%%{version}/ v%%{version} | bzip2 -c > python-linux-procfs-%%{version}.tar.bz2
Source: https://git.kernel.org/pub/scm/libs/python/python-linux-procfs/python-linux-procfs.git/snapshot/%{name}-%{version}.tar.bz2
Patch1: pidstats-fix-documentation-indentation.patch
Patch2: fix-parse_affinity-for-CPU-numbers-greater-than-31.patch

# PATCHES
Patch1: pflags_Use_argparse_to_create_help_option.patch
Patch2: pflags_ignore_non-existent_pids.patch

BuildArch: noarch
BuildRequires: python-devel
@ -52,6 +54,22 @@ rm -rf %{buildroot} @@ -52,6 +54,22 @@ rm -rf %{buildroot}
%doc COPYING

%changelog
* Tue Dec 04 2018 John Kacur <jkacur@redhat.com> - 0.4.11-4
- Need to apply the patch in prep
Resolves: rhbz#1654311

* Mon Dec 03 2018 John Kacur <jkacur@redhat.com> - 0.4.11-3
- Ignore non-existent pids
Resolves: rhbz#1654311

* Mon Dec 03 2018 John Kacur <jkacur@redhat.com> - 0.4.11-2
- Use argparse to create a help option
Resolves: rhbz#1654700

* Fri Nov 30 2018 John Kacur <jkacur@redhat.com> - 0.4.11-1
- Upgrade to upstream v0.4-11
Resolves: rhbz#1654726

* Thu May 31 2018 John Kacur <jkacur@redhat.com> - 0.4.9-4
- Fix upstream URL reference and source
Resolves: rhbz#1583961

Loading…
Cancel
Save