diff --git a/.gitignore b/.gitignore index 2042986..1e8f01f 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1 @@ -SOURCES/python-linux-procfs-0.4.9.tar.bz2 +SOURCES/python-linux-procfs-0.4.11.tar.bz2 diff --git a/.python-linux-procfs.metadata b/.python-linux-procfs.metadata index 3a0a4f3..63f6293 100644 --- a/.python-linux-procfs.metadata +++ b/.python-linux-procfs.metadata @@ -1 +1 @@ -84be95847bb357649692fab06668c78263b83c31 SOURCES/python-linux-procfs-0.4.9.tar.bz2 +7672a83d64b9ed78dcd3558cfc3a61eee4d340ca SOURCES/python-linux-procfs-0.4.11.tar.bz2 diff --git a/SOURCES/fix-parse_affinity-for-CPU-numbers-greater-than-31.patch b/SOURCES/fix-parse_affinity-for-CPU-numbers-greater-than-31.patch deleted file mode 100644 index 3599083..0000000 --- a/SOURCES/fix-parse_affinity-for-CPU-numbers-greater-than-31.patch +++ /dev/null @@ -1,50 +0,0 @@ -From 56cec3cf78392f2464f28129b1de70c53616de26 Mon Sep 17 00:00:00 2001 -From: Jozef Bacik -Date: Wed, 24 Aug 2016 11:05:05 +0100 -Subject: [PATCH] fix parse_affinity for CPU numbers greater than 31 - -The function parse_affinity reports wrong results for CPU numbers -greater than 31. - -The problem is caused by the function bitmastlist which parse_affinity -calls. The fix treats the inpput line as a long hexbitmask instead of an -array in order to produce correct results - -Signed-off-by: Jozef Bacik -Signed-off-by: John Kacur ---- - procfs/utilist.py | 16 ++++++---------- - 1 file changed, 6 insertions(+), 10 deletions(-) - -diff --git a/procfs/utilist.py b/procfs/utilist.py -index 18645c0ba45e..0e7c24f45cda 100755 ---- a/procfs/utilist.py -+++ b/procfs/utilist.py -@@ -37,18 +37,14 @@ def hexbitmask(l, nr_entries): - return hexbitmask - - def bitmasklist(line, nr_entries): -- fields = line.strip().split(",") -+ hexmask = line.strip().replace(",", "") - bitmasklist = [] - entry = 0 -- for i in range(len(fields) - 1, -1, -1): -- mask = int(fields[i], 16) -- while mask != 0: -- if mask & 1: -- bitmasklist.append(entry) -- mask >>= 1 -- entry += 1 -- if entry == nr_entries: -- break -+ bitmask = bin(int(hexmask, 16))[2::] -+ for i in reversed(bitmask): -+ if int(i) & 1: -+ bitmasklist.append(entry) -+ entry +=1 - if entry == nr_entries: - break - return bitmasklist --- -2.4.11 - diff --git a/SOURCES/pflags_Use_argparse_to_create_help_option.patch b/SOURCES/pflags_Use_argparse_to_create_help_option.patch new file mode 100644 index 0000000..688d239 --- /dev/null +++ b/SOURCES/pflags_Use_argparse_to_create_help_option.patch @@ -0,0 +1,59 @@ +From 1694ab2ab3628cead18ba7aa59e134e80675c601 Mon Sep 17 00:00:00 2001 +From: John Kacur +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 +--- + 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 + diff --git a/SOURCES/pflags_ignore_non-existent_pids.patch b/SOURCES/pflags_ignore_non-existent_pids.patch new file mode 100644 index 0000000..90c1b07 --- /dev/null +++ b/SOURCES/pflags_ignore_non-existent_pids.patch @@ -0,0 +1,40 @@ +From e153f5177e1ae4b7859454a2d3011d6f55710600 Mon Sep 17 00:00:00 2001 +From: John Kacur +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 +--- + 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 + diff --git a/SOURCES/pidstats-fix-documentation-indentation.patch b/SOURCES/pidstats-fix-documentation-indentation.patch deleted file mode 100644 index 0d5ba0a..0000000 --- a/SOURCES/pidstats-fix-documentation-indentation.patch +++ /dev/null @@ -1,50 +0,0 @@ -From f1c8bf461da1344ae48f456a129502f276f5fc14 Mon Sep 17 00:00:00 2001 -From: Jiri Kastner -Date: Fri, 9 Oct 2015 13:50:09 +0200 -Subject: [PATCH] pidstats: fix documentation indentation - -Signed-off-by: Jiri Kastner -Signed-off-by: John Kacur ---- - procfs/procfs.py | 22 +++++++++++----------- - 1 file changed, 11 insertions(+), 11 deletions(-) - -diff --git a/procfs/procfs.py b/procfs/procfs.py -index 3d683c1ec5c6..0706fbc3debd 100755 ---- a/procfs/procfs.py -+++ b/procfs/procfs.py -@@ -412,20 +412,20 @@ class pidstats: - return key in self.processes - - def reload(self): -- """ -- This operation will trow away the current dictionary contents, if any, and -- read all the pid files from /proc/, instantiating a 'process' instance for -- each of them. -+ """ -+ This operation will throw away the current dictionary contents, if any, and -+ read all the pid files from /proc/, instantiating a 'process' instance for -+ each of them. - -- This is a high overhead operation, and should be avoided if the perf python -- binding can be used to detect when new threads appear and existing ones -- terminate. -+ This is a high overhead operation, and should be avoided if the perf python -+ binding can be used to detect when new threads appear and existing ones -+ terminate. - -- In RHEL it is found in the python-perf rpm package. -+ In RHEL it is found in the python-perf rpm package. - -- More information about the perf facilities can be found in the 'perf_event_open' -- man page. -- """ -+ More information about the perf facilities can be found in the 'perf_event_open' -+ man page. -+ """ - del self.processes - self.processes = {} - pids = os.listdir(self.basedir) --- -2.4.3 - diff --git a/SPECS/python-linux-procfs.spec b/SPECS/python-linux-procfs.spec index cc81341..c82c0d5 100644 --- a/SPECS/python-linux-procfs.spec +++ b/SPECS/python-linux-procfs.spec @@ -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 # 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} %doc COPYING %changelog +* Tue Dec 04 2018 John Kacur - 0.4.11-4 +- Need to apply the patch in prep +Resolves: rhbz#1654311 + +* Mon Dec 03 2018 John Kacur - 0.4.11-3 +- Ignore non-existent pids +Resolves: rhbz#1654311 + +* Mon Dec 03 2018 John Kacur - 0.4.11-2 +- Use argparse to create a help option +Resolves: rhbz#1654700 + +* Fri Nov 30 2018 John Kacur - 0.4.11-1 +- Upgrade to upstream v0.4-11 +Resolves: rhbz#1654726 + * Thu May 31 2018 John Kacur - 0.4.9-4 - Fix upstream URL reference and source Resolves: rhbz#1583961