pcp
[Top] [All Lists]

pmrep: fix cmd line options handling

To: pcp developers <pcp@xxxxxxxxxxx>
Subject: pmrep: fix cmd line options handling
From: Marko Myllynen <myllynen@xxxxxxxxxx>
Date: Thu, 3 Dec 2015 23:43:56 +0200
Delivered-to: pcp@xxxxxxxxxxx
Organization: Red Hat
Reply-to: myllynen@xxxxxxxxxx
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.4.0
The easiest solution seems to work.

---
 src/pmrep/TODO     |  1 -
 src/pmrep/pmrep.py | 15 ++-------------
 2 files changed, 2 insertions(+), 14 deletions(-)

diff --git a/src/pmrep/TODO b/src/pmrep/TODO
index e01d233..ea9c9d2 100644
--- a/src/pmrep/TODO
+++ b/src/pmrep/TODO
@@ -1,6 +1,5 @@
 -  after first release: drop all compat code
 -  after first release: check all code marked with BZ references
--  fix get_cmd_line_metrics
 -  allow defining instances to display
 -  opt to write cols per row with stdout output
 -  adjust unit/scale handling to ~match fetchgroup
diff --git a/src/pmrep/pmrep.py b/src/pmrep/pmrep.py
index 80161b6..f935617 100644
--- a/src/pmrep/pmrep.py
+++ b/src/pmrep/pmrep.py
@@ -418,19 +418,8 @@ class PMReporter(object):
 
     def get_cmd_line_metrics(self):
         """ Get metric set specifications from the command line """
-        metrics = []
-        for arg in sys.argv[1:]:
-            if arg in self.arghelp:
-                return 0
-        for arg in reversed(sys.argv[1:]):
-            if arg.startswith('-'):
-                if len(metrics):
-                    if arg not in self.argless and '=' not in arg:
-                        del metrics[-1]
-                break
-            metrics.append(arg)
-        metrics.reverse()
-        return metrics
+        pmapi.c_api.pmGetOptionsFromList(sys.argv) # RHBZ#1287778
+        return self.opts.pmNonOptionsFromList(sys.argv)
 
     def parse_metric_info(self, metrics, key, value):
         """ Parse metric information """

Thanks,

-- 
Marko Myllynen

<Prev in Thread] Current Thread [Next in Thread>