|
|
92c0da |
From 1694ab2ab3628cead18ba7aa59e134e80675c601 Mon Sep 17 00:00:00 2001
|
|
|
92c0da |
From: John Kacur <jkacur@redhat.com>
|
|
|
92c0da |
Date: Fri, 30 Nov 2018 11:50:34 -0500
|
|
|
92c0da |
Subject: [PATCH 1/2] python-linux-procfs: pflags: Use argparse to create a
|
|
|
92c0da |
help option
|
|
|
92c0da |
|
|
|
92c0da |
The purpose of this change is to create a -h or --help option.
|
|
|
92c0da |
In addition the handling of pids or process names is improved. Instead of a
|
|
|
92c0da |
command separated list (without spaces), the more standard unix way of
|
|
|
92c0da |
space separated command line arguments are used.
|
|
|
92c0da |
|
|
|
92c0da |
This is explained in the help.
|
|
|
92c0da |
|
|
|
92c0da |
./pflags -h
|
|
|
92c0da |
usage: pflags [-h] [pid [pid ...]]
|
|
|
92c0da |
|
|
|
92c0da |
Print process flags
|
|
|
92c0da |
|
|
|
92c0da |
positional arguments:
|
|
|
92c0da |
pid a list of pids or names
|
|
|
92c0da |
|
|
|
92c0da |
optional arguments:
|
|
|
92c0da |
-h, --help show this help message and exit
|
|
|
92c0da |
|
|
|
92c0da |
Signed-off-by: John Kacur <jkacur@redhat.com>
|
|
|
92c0da |
---
|
|
|
92c0da |
pflags-cmd.py | 8 +++++++-
|
|
|
92c0da |
1 file changed, 7 insertions(+), 1 deletion(-)
|
|
|
92c0da |
|
|
|
92c0da |
diff --git a/pflags-cmd.py b/pflags-cmd.py
|
|
|
92c0da |
index 9228c688e7a2..f180ed505977 100755
|
|
|
92c0da |
--- a/pflags-cmd.py
|
|
|
92c0da |
+++ b/pflags-cmd.py
|
|
|
92c0da |
@@ -15,6 +15,7 @@
|
|
|
92c0da |
# General Public License for more details.
|
|
|
92c0da |
|
|
|
92c0da |
import procfs, re, fnmatch, sys
|
|
|
92c0da |
+import argparse
|
|
|
92c0da |
|
|
|
92c0da |
ps = None
|
|
|
92c0da |
|
|
|
92c0da |
@@ -35,8 +36,13 @@ def main(argv):
|
|
|
92c0da |
global ps
|
|
|
92c0da |
ps = procfs.pidstats()
|
|
|
92c0da |
|
|
|
92c0da |
+ parser = argparse.ArgumentParser(description='Print process flags')
|
|
|
92c0da |
+ parser.add_argument('pid', nargs='*', help='a list of pids or names')
|
|
|
92c0da |
+ args = parser.parse_args()
|
|
|
92c0da |
+
|
|
|
92c0da |
if (len(argv) > 1):
|
|
|
92c0da |
- pids = reduce(lambda i, j: i + j, map(thread_mapper, argv[1].split(",")))
|
|
|
92c0da |
+ pids = args.pid
|
|
|
92c0da |
+ pids = reduce(lambda i, j: i + j, list(map(thread_mapper, pids)))
|
|
|
92c0da |
else:
|
|
|
92c0da |
pids = ps.processes.keys()
|
|
|
92c0da |
|
|
|
92c0da |
--
|
|
|
92c0da |
2.19.2
|
|
|
92c0da |
|