From 12eebf027d70f1e66795559c059f6d541b33563c Mon Sep 17 00:00:00 2001 From: CentOS Sources Date: Aug 01 2019 20:59:53 +0000 Subject: import python-linux-procfs-0.6-7.el8 --- diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0951324 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +SOURCES/python-linux-procfs-0.6.tar.xz diff --git a/.python-linux-procfs.metadata b/.python-linux-procfs.metadata new file mode 100644 index 0000000..43336c3 --- /dev/null +++ b/.python-linux-procfs.metadata @@ -0,0 +1 @@ +924eef33607e2229da5133ae510c95d36902d86a SOURCES/python-linux-procfs-0.6.tar.xz diff --git a/SOURCES/pflags_Ignore_non-existent_pids.patch b/SOURCES/pflags_Ignore_non-existent_pids.patch new file mode 100644 index 0000000..8d1caa8 --- /dev/null +++ b/SOURCES/pflags_Ignore_non-existent_pids.patch @@ -0,0 +1,39 @@ +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/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..1b66c64 --- /dev/null +++ b/SOURCES/pflags_use_argparse_to_create_help_option.patch @@ -0,0 +1,71 @@ +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/SOURCES/procfs-Fix-removing-vanished-processes-in-pidstats.patch b/SOURCES/procfs-Fix-removing-vanished-processes-in-pidstats.patch new file mode 100644 index 0000000..436f9a1 --- /dev/null +++ b/SOURCES/procfs-Fix-removing-vanished-processes-in-pidstats.patch @@ -0,0 +1,72 @@ +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/SOURCES/procfs-Reduce-not-in-python3-by-default.patch b/SOURCES/procfs-Reduce-not-in-python3-by-default.patch new file mode 100644 index 0000000..97f6ac9 --- /dev/null +++ b/SOURCES/procfs-Reduce-not-in-python3-by-default.patch @@ -0,0 +1,27 @@ +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/SOURCES/sysctl-Fix-refreshing-cache.patch b/SOURCES/sysctl-Fix-refreshing-cache.patch new file mode 100644 index 0000000..5897e9c --- /dev/null +++ b/SOURCES/sysctl-Fix-refreshing-cache.patch @@ -0,0 +1,42 @@ +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 + diff --git a/SPECS/python-linux-procfs.spec b/SPECS/python-linux-procfs.spec new file mode 100644 index 0000000..1bd2e7c --- /dev/null +++ b/SPECS/python-linux-procfs.spec @@ -0,0 +1,198 @@ +Name: python-linux-procfs +Version: 0.6 +Release: 7%{?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 +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 + +%package -n python3-linux-procfs +Summary: %summary +%{?python_provide:%python_provide python3-linux-procfs} + +Requires: python3-six + +%description -n python3-linux-procfs %_description + +%prep +%autosetup -p1 + +%build +%py3_build + +%install +rm -rf %{buildroot} +%py3_install + +%clean +rm -rf %{buildroot} + +%files -n python3-linux-procfs +%defattr(0755,root,root,0755) +%{_bindir}/pflags +%{python3_sitelib}/procfs/ +%defattr(0644,root,root,0755) +%{python3_sitelib}/python_linux_procfs*.egg-info +%license COPYING + +%changelog +* Wed Apr 03 2019 Clark Williams - 0.6-7 +- OSCI gating framework added +Resolves: rhbz#1682424 + +* Mon Jan 28 2019 John Kacur - 0.6-6 +- fix refreshing the cache +- fix removing vanished processes in pidstats +Resolves: rhbz#1669294 + +* Fri Nov 30 2018 John Kacur - 0.6-5 +- pflags - Ignore non-existent pids or process names +Resolves: rhbz#1654312 + +* Wed Nov 28 2018 John Kacur - 0.6-4 +- Use argparse to create a help option +Resolves: rhbz#1650159 + +* Tue Oct 16 2018 John Kacur - 0.6-3 +- python3 doesn't supply "reduce" by default, so import it +Resolves: rhbz#1639430 + +* Mon Aug 13 2018 John Kacur - 0.6-2 +- Obsoltes python-linux-procfs (just build the python3 version) +Resolves: rhbz#1589042 + +* Fri Aug 10 2018 John Kacur - 0.6-1 +- Sync with upstream source +Resolves: rhbz#1614869 + +* Wed Aug 8 2018 John Kacur - 0.5.1-7 +- Add some functions related to affinity from tuna +Resolves: rhbz#1522868 + +* Tue Jun 26 2018 John Kacur - 0.5.1-6 +- Fix upstream URL reference and source +Resolves: rhbz#1589938 + +* Thu May 31 2018 John Kacur - 0.5.1-5 +- Build only the python3 subpackage (needs to be done in rhel-8.0 too) +Resolves: rhbz#1567234 + +* Fri Feb 09 2018 Fedora Release Engineering - 0.5.1-4 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild + +* Thu Jan 25 2018 Iryna Shcherbina - 0.5.1-3 +- Update Python 2 dependency declarations to new packaging standards + (See https://fedoraproject.org/wiki/FinalizingFedoraSwitchtoPython3) + +* Tue Nov 21 2017 Jiri Kastner - 0.5.1-2 +- missing defattr for _bindir + +* Tue Nov 21 2017 Jiri Kastner - 0.5.1-1 +- missed snippet in specfile for python2 only +- added scripts to setup.py, pflags renamed and added to setup.py + +* Mon Nov 20 2017 Jiri Kastner - 0.5-1 +- update to 0.5 + +* Sat Aug 19 2017 Zbigniew Jędrzejewski-Szmek - 0.4.10-4 +- Python 2 binary package renamed to python2-linux-procfs + See https://fedoraproject.org/wiki/FinalizingFedoraSwitchtoPython3 + +* Thu Jul 27 2017 Fedora Release Engineering - 0.4.10-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild + +* Sat Feb 11 2017 Fedora Release Engineering - 0.4.10-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild + +* Thu Dec 22 2016 Jiri Kastner - 0.4.10-1 +- update to latest release + +* Tue Jul 19 2016 Fedora Release Engineering - 0.4.6-7 +- https://fedoraproject.org/wiki/Changes/Automatic_Provides_for_Python_RPM_Packages + +* Thu Feb 04 2016 Fedora Release Engineering - 0.4.6-6 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild + +* Thu Jun 18 2015 Fedora Release Engineering - 0.4.6-5 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild + +* Fri Oct 10 2014 Jiri Kastner - 0.4.6-4 +- fix source and url + +* Sat Jun 07 2014 Fedora Release Engineering - 0.4.6-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild + +* Sun Aug 04 2013 Fedora Release Engineering - 0.4.6-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_20_Mass_Rebuild + +* Fri Jun 14 2013 Jiri Kastner - 0.4.6-1 +- updated to 0.4.6 + +* Thu Jun 6 2013 Jiri Kastner - 0.4.5-1 +- Added support for parsing cgroups as a per thread attribute + +* Thu Feb 14 2013 Fedora Release Engineering - 0.4.4-8 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_19_Mass_Rebuild + +* Sat Jul 21 2012 Fedora Release Engineering - 0.4.4-7 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild + +* Sat Jan 14 2012 Fedora Release Engineering - 0.4.4-6 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild + +* Tue Feb 08 2011 Fedora Release Engineering - 0.4.4-5 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild + +* Thu Jul 22 2010 David Malcolm - 0.4.4-4 +- Rebuilt for https://fedoraproject.org/wiki/Features/Python_2.7/MassRebuild + +* Sun Jul 26 2009 Fedora Release Engineering - 0.4.4-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_12_Mass_Rebuild + +* Thu Feb 26 2009 Fedora Release Engineering - 0.4.4-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_11_Mass_Rebuild + +* Tue Feb 10 2009 Arnaldo Carvalho de Melo - 0.4.4-1 +- Even more fixes due to the fedora review process + +* Mon Feb 9 2009 Arnaldo Carvalho de Melo - 0.4.3-1 +- Fixups due to the fedora review process + +* Tue Aug 12 2008 Arnaldo Carvalho de Melo - 0.4.2-1 +- interrupts: Add find_by_user_regex +- process: Always set the "cmdline" array, even if empty +- pidstats: Remove dead processes in find_by_name() +- pidstats: Add process class to catch dict references for late parsing +- pidstats: Move the /proc/PID/{stat,status} parsing to classes +- pidstats: Introduce process_flags method + +* Tue Aug 12 2008 Arnaldo Carvalho de Melo - 0.4-1 +- Per process flags needed by tuna + +* Fri Jun 13 2008 Arnaldo Carvalho de Melo - 0.3-1 +- Support CPU hotplug + +* Mon Feb 25 2008 Arnaldo Carvalho de Melo - 0.1-1 +- package created