Discussion:
[PATCH 0/2] python-linux-procfs and pflag changes
John Kacur
2018-11-28 13:07:36 UTC
Permalink
Please pick-up the following patches
You can also fetch them via git

Repo: git://git.kernel.org:/pub/scm/linux/kernel/git/jkacur/python-schedutils.git
Branch: jkacur/jkacur/rhel8-py3


John Kacur (2):
procfs: Reduce not in python3 by default
python-linux-procfs: pflags: Use argparse to create a help option

pflags | 12 +++++++++---
procfs/procfs.py | 1 +
2 files changed, 10 insertions(+), 3 deletions(-)

--
2.19.1
_______________________________________________
tuna-devel mailing list -- tuna-***@lists.fedorahosted.org
To unsubscribe send an email to tuna-devel-***@lists.fedorahosted.org
Fedora Code of Conduct: https://getfedora.org/code-of-conduct.html
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: https://lists.fedorahosted.org/archives/list/tuna-***@lists.fed
John Kacur
2018-11-28 13:07:37 UTC
Permalink
Reduce not in python3 by default, so import it from functools

Signed-off-by: John Kacur <***@redhat.com>
---
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.19.1
_______________________________________________
tuna-devel mailing list -- tuna-***@lists.fedorahosted.org
To unsubscribe send an email to tuna-devel-***@lists.fedorahosted.org
Fedora Code of Conduct: https://getfedora.org/code-of-conduct.html
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: https://lists.fedorahosted.org/
John Kacur
2018-11-28 13:07:38 UTC
Permalink
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 <***@redhat.com>
---
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
_______________________________________________
tuna-devel mailing list -- tuna-***@lists.fedorahosted.org
To unsubscribe send an email to tuna-devel-***@lists.fedorahosted.org
Fedora Code of Conduct: https://getfedora.org/code-of-conduct.html
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: https://lists.fedorahosted.org/archives/list/tuna-***@lists.fedo
John Kacur
2018-11-29 14:06:18 UTC
Permalink
Note that since argparse is in python-2.7 this works there too (without
the change to the shabang - !#/usr/bin/python).
I tested this on a rhel7 with python-2.7
Post by John Kacur
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
pid a list of pids or names
-h, --help show this help message and exit
---
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
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()
+
- 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)))
pids = list(ps.processes.keys())
--
2.19.1
_______________________________________________
tuna-devel mailing list -- tuna-***@lists.fedorahosted.org
To unsubscribe send an email to tuna-devel-***@lists.fedorahosted.org
Fedora Code of Conduct: https://getfedora.org/code-of-conduct.html
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: https://lists.fedorahosted.org/archives/list/tuna-***@lists.fe
John Kacur
2018-12-04 19:34:20 UTC
Permalink
I've restructured my repositories for python-linux-procfs
and python-schedutils, to make them less confusing,
so you will now find the patches here.

Repo: git://git.kernel.org/pub/scm/linux/kernel/git/jkacur/python-linux-procfs
Branch: py3/rhel8

Please apply
Post by John Kacur
Please pick-up the following patches
You can also fetch them via git
Repo: git://git.kernel.org:/pub/scm/linux/kernel/git/jkacur/python-schedutils.git
Branch: jkacur/jkacur/rhel8-py3
procfs: Reduce not in python3 by default
python-linux-procfs: pflags: Use argparse to create a help option
pflags | 12 +++++++++---
procfs/procfs.py | 1 +
2 files changed, 10 insertions(+), 3 deletions(-)
--
2.19.1
_______________________________________________
tuna-devel mailing list -- tuna-***@lists.fedorahosted.org
To unsubscribe send an email to tuna-devel-***@lists.fedorahosted.org
Fedora Code of Conduct: https://getfedora.org/code-of-conduct.html
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: https://lists.fedorahosted.org/archives/list/tuna-
Loading...