diff --git a/download b/download new file mode 100644 index 0000000000000000000000000000000000000000..3db01492eecd8b4f0cd2a51bfd1535e0526bd007 --- /dev/null +++ b/download @@ -0,0 +1 @@ +598b05b4c22c13378b20c2fc45bf6576 python-linux-procfs-0.7.0.tar.xz diff --git a/pflags_Ignore_non-existent_pids.patch b/pflags_Ignore_non-existent_pids.patch deleted file mode 100644 index 8d1caa8d8390de59c8f5590962dcabad8746b048..0000000000000000000000000000000000000000 --- a/pflags_Ignore_non-existent_pids.patch +++ /dev/null @@ -1,39 +0,0 @@ -From 5b180973d90475ab32c470e568f1c786d94a9bf0 Mon Sep 17 00:00:00 2001 -From: John Kacur -Date: Thu, 29 Nov 2018 15:39:22 +0100 -Subject: [PATCH] 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 make sure -the max_comm_len defaults to 0 instead of generating an error. - -Signed-off-by: John Kacur ---- - pflags | 6 ++++-- - 1 file changed, 4 insertions(+), 2 deletions(-) - -diff --git a/pflags b/pflags -index a1667fc06131..9c45600cc1ee 100755 ---- a/pflags -+++ b/pflags -@@ -50,11 +50,13 @@ def main(argv): - pids = list(ps.processes.keys()) - - pids.sort() -- len_comms = [len(ps[pid]["stat"]["comm"]) for pid in pids] -- max_comm_len = max(len_comms) -+ len_comms = [len(ps[pid]["stat"]["comm"]) for pid in pids if pid in ps] -+ max_comm_len = max(len_comms, default=0) - 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/pflags_use_argparse_to_create_help_option.patch b/pflags_use_argparse_to_create_help_option.patch deleted file mode 100644 index 1b66c649fca38417573d87dc485640b0cd86a747..0000000000000000000000000000000000000000 --- a/pflags_use_argparse_to_create_help_option.patch +++ /dev/null @@ -1,71 +0,0 @@ -From 68e3d6e74f0941c98aaeb82b89c954c76246ba7a Mon Sep 17 00:00:00 2001 -From: John Kacur -Date: Wed, 28 Nov 2018 04:28:53 +0100 -Subject: [PATCH 2/2] python-linux-procfs: pflags: Use argparse to create a - help option - -The purpose of this change was to create a -h, or --help option. -The following changes were made. - -1. pflags is now python3 only, since it uses argparse. -2. 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 arguements 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 | 12 +++++++++--- - 1 file changed, 9 insertions(+), 3 deletions(-) - -diff --git a/pflags b/pflags -index abfcfe9e9ec1..a1667fc06131 100755 ---- a/pflags -+++ b/pflags -@@ -1,4 +1,4 @@ --#! /usr/bin/python -+#! /usr/bin/python3 - # -*- python -*- - # -*- coding: utf-8 -*- - # print process flags -@@ -14,8 +14,9 @@ - # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - # General Public License for more details. - --from __future__ import print_function -+ - import procfs, re, fnmatch, sys -+import argparse - from functools import reduce - from six.moves import map - -@@ -38,8 +39,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, list(map(thread_mapper, argv[1].split(",")))) -+ pids = args.pid -+ pids = reduce(lambda i, j: i + j, list(map(thread_mapper, pids))) - else: - pids = list(ps.processes.keys()) - --- -2.19.1 - diff --git a/procfs-Fix-removing-vanished-processes-in-pidstats.patch b/procfs-Fix-removing-vanished-processes-in-pidstats.patch deleted file mode 100644 index 436f9a1c05ebdc2fa363a18c93f4cca964025f60..0000000000000000000000000000000000000000 --- a/procfs-Fix-removing-vanished-processes-in-pidstats.patch +++ /dev/null @@ -1,72 +0,0 @@ -From cf4c740974834b7d5c9dc7b12a69c5269b0d7a2d Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Ond=C5=99ej=20Lyson=C4=9Bk?= -Date: Thu, 24 Jan 2019 21:55:16 +0100 -Subject: [PATCH] procfs: Fix removing vanished processes in - pidstats.reload_threads() -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -If a process disappears while iterating the loop in -pidstats.reload_threads(), we get a RuntimeError as shown below. This -is because we cannot remove an entry from a dictionary while iterating the -dictionary. - -Reproducer: -1. Add the following line to the beginning of pidstats.reload_threads(): -import pdb; pdb.set_trace() -2. Start some process -3. Start the python interpreter and proceed as follows: -[~/git/python-linux-procfs]$ python3 -Python 3.6.8 (default, Jan 3 2019, 16:11:14) -[GCC 8.2.1 20181215 (Red Hat 8.2.1-6)] on linux -Type "help", "copyright", "credits" or "license" for more information. ->>> import procfs ->>> ps = procfs.pidstats() ->>> ps.reload_threads() -> /home/olysonek/git/python-linux-procfs/procfs/procfs.py(462)reload_threads() --> for pid in self.processes.keys(): -(Pdb) next -> /home/olysonek/git/python-linux-procfs/procfs/procfs.py(463)reload_threads() --> try: - -At this point, terminate the process started in step 2. Return to the -python interpreter: - -(Pdb) continue -Traceback (most recent call last): - File "", line 1, in - File "/home/olysonek/git/python-linux-procfs/procfs/procfs.py", line 463, in reload_threads - try: -RuntimeError: dictionary changed size during iteration - -Signed-off-by: Ondřej Lysoněk -Signed-off-by: John Kacur ---- - procfs/procfs.py | 5 ++++- - 1 file changed, 4 insertions(+), 1 deletion(-) - -diff --git a/procfs/procfs.py b/procfs/procfs.py -index c6f65890d0e4..b0ce2514063d 100755 ---- a/procfs/procfs.py -+++ b/procfs/procfs.py -@@ -459,12 +459,15 @@ class pidstats: - self.processes[pid] = process(pid, self.basedir) - - def reload_threads(self): -+ to_remove = [] - for pid in self.processes.keys(): - try: - self.processes[pid].load_threads() - except OSError: - # process vanished, remove it -- del self.processes[pid] -+ to_remove.append(pid) -+ for pid in to_remove: -+ del self.processes[pid] - - def find_by_name(self, name): - name = name[:15] --- -2.20.1 - diff --git a/procfs-Reduce-not-in-python3-by-default.patch b/procfs-Reduce-not-in-python3-by-default.patch deleted file mode 100644 index 97f6ac9fb4b8fde10e6aab5bcb764922a68877e2..0000000000000000000000000000000000000000 --- a/procfs-Reduce-not-in-python3-by-default.patch +++ /dev/null @@ -1,27 +0,0 @@ -From 5765b274bf2929aa99185be5ce946bce94ace7a5 Mon Sep 17 00:00:00 2001 -From: John Kacur -Date: Tue, 16 Oct 2018 20:26:39 +0200 -Subject: [PATCH] procfs: Reduce not in python3 by default - -Reduce not in python3 by default, so import it from functools - -Signed-off-by: John Kacur ---- - procfs/procfs.py | 1 + - 1 file changed, 1 insertion(+) - -diff --git a/procfs/procfs.py b/procfs/procfs.py -index c70fe2ae774b..c6f65890d0e4 100755 ---- a/procfs/procfs.py -+++ b/procfs/procfs.py -@@ -21,6 +21,7 @@ - from __future__ import absolute_import - from __future__ import print_function - import os, time -+from functools import reduce - from .utilist import bitmasklist - from six.moves import range - --- -2.14.4 - diff --git a/python-linux-procfs-0.6.tar.xz b/python-linux-procfs-0.6.tar.xz deleted file mode 100644 index a162e4ff05018c02fbf58a5a7f40ca66274408a4..0000000000000000000000000000000000000000 Binary files a/python-linux-procfs-0.6.tar.xz and /dev/null differ diff --git a/python-linux-procfs.spec b/python-linux-procfs.spec index 1bd2e7c9ed740198de0df518d56c8249b0be03ef..03d25af19860c3359f790effafe0a72788612b27 100644 --- a/python-linux-procfs.spec +++ b/python-linux-procfs.spec @@ -1,30 +1,20 @@ Name: python-linux-procfs -Version: 0.6 -Release: 7%{?dist} +Version: 0.7.0 +Release: 1%{?dist} License: GPLv2 Summary: Linux /proc abstraction classes Group: System Environment/Libraries -Source: https://git.kernel.org/pub/scm/libs/python/python-linux-procfs/python-linux-procfs.git/snapshot/%{name}-%{version}.tar.xz -URL: https://git.kernel.org/pub/scm/libs/python/python-linux-procfs/python-linux-procfs.git -# If upstream does not provide tarballs, to generate -# git clone git://git.kernel.org/pub/scm/libs/python/python-linux-procfs/python-linux-procfs.git -# cd python-linux-procfs -# git archive --format=tar --prefix=python-linux-procfs-%%{version}/ v%%{version} | xz -c > python-linux-procfs-%%{version}.tar.xz +URL: https://git.kernel.org/pub/scm/libs/python/%{name}/%{name}.git +Source: https://www.kernel.org/pub/software/libs/python/%{name}/%{name}-%{version}.tar.xz BuildArch: noarch BuildRequires: python3-devel BuildRequires: python3-setuptools BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX) -Obsoletes: python-linux-procfs %global _description\ Abstractions to extract information from the Linux kernel /proc files. # PATCHES -Patch1: procfs-Reduce-not-in-python3-by-default.patch -Patch2: pflags_use_argparse_to_create_help_option.patch -Patch3: pflags_Ignore_non-existent_pids.patch -Patch4: sysctl-Fix-refreshing-cache.patch -Patch5: procfs-Fix-removing-vanished-processes-in-pidstats.patch %description %_description @@ -46,9 +36,6 @@ Requires: python3-six rm -rf %{buildroot} %py3_install -%clean -rm -rf %{buildroot} - %files -n python3-linux-procfs %defattr(0755,root,root,0755) %{_bindir}/pflags @@ -58,6 +45,39 @@ rm -rf %{buildroot} %license COPYING %changelog +* Tue Jan 11 2022 John Kacur - 0.7.0-1 +- Rebase to upstream version python-linux-procfs-0.7.0 +Resolves: rhbz#2031158 + +* Thu Dec 09 2021 John Kacur - 0.6.3-4 +- various clean-ups including using 'with' context managers in try-except +- Fix to ignore UnicodeDecodeError when it occurs +Resolves: rhbz#2016204 + +* Tue Nov 23 2021 John Kacur - 0.6.3-3 +- Propagate error to user if pid completed +- Handle pid completed in pflags +Resolves: rhbz#1820709 + +* Fri Nov 19 2021 John Kacur - 0.6.3-2 +- Fix traceback with non-utf8 chars +Resolves: rhbz#2016204 + +* Tue Jan 12 2021 John Kacur - 0.6.3-1 +- Rebase to latest upstream +- Correct URL and Source +- Simplify specfile +Resolves: rhbz#1890557 + +* Wed Jun 24 2020 John Kacur - 0.6.2-2 +Resolves: rhbz#1850391 + +* Mon Jun 22 2020 John Kacur - 0.6.2-1 +- Add bitmasklist_test +- Clean-ups including using a more modern python spacing, tabbing, etc +- Fix to parse number of cpus correctly on s390(x) +Resolves: rhbz#1849215 + * Wed Apr 03 2019 Clark Williams - 0.6-7 - OSCI gating framework added Resolves: rhbz#1682424 diff --git a/sysctl-Fix-refreshing-cache.patch b/sysctl-Fix-refreshing-cache.patch deleted file mode 100644 index 5897e9cb7076f02869721f6a12d018364db0f52d..0000000000000000000000000000000000000000 --- a/sysctl-Fix-refreshing-cache.patch +++ /dev/null @@ -1,42 +0,0 @@ -From 6a84665b2422a98fbce8581ee9ae5eb60953f945 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Ond=C5=99ej=20Lyson=C4=9Bk?= -Date: Fri, 11 Jan 2019 15:24:00 +0100 -Subject: [PATCH] sysctl: Fix refreshing cache -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -Fix iterating over the 'cache' dictionary in refresh(). A dictionary is -not callable. This fixes the following error: - ->>> import procfs.sysctl ->>> s = procfs.sysctl() ->>> s.refresh() -Traceback (most recent call last): - File "", line 1, in - File "/usr/lib/python3.6/site-packages/procfs/sysctl.py", line 64, in refresh - for key in self.cache(): -TypeError: 'dict' object is not callable - -Signed-off-by: Ondřej Lysoněk -Signed-off-by: John Kacur ---- - procfs/sysctl.py | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/procfs/sysctl.py b/procfs/sysctl.py -index 8b256ab4317f..6a9145518c27 100755 ---- a/procfs/sysctl.py -+++ b/procfs/sysctl.py -@@ -61,7 +61,7 @@ class sysctl: - f.close() - - def refresh(self): -- for key in self.cache(): -+ for key in self.cache.keys(): - del self.cache[key] - value = self.read(key) - if value != None: --- -2.20.1 -