Add support for periods with sub-second units
authorAntoine Busque <abusque@efficios.com>
Wed, 28 Oct 2015 05:31:55 +0000 (01:31 -0400)
committerAntoine Busque <abusque@efficios.com>
Wed, 28 Oct 2015 05:31:55 +0000 (01:31 -0400)
Signed-off-by: Antoine Busque <abusque@efficios.com>
lttnganalyses/cli/command.py
lttnganalyses/core/analysis.py

index 1c76dc98a06461bbe159617eeb9a75de4f156203..a54e584128b3a9ac2a3ca6035258e6664dc6275d 100644 (file)
@@ -106,8 +106,15 @@ class Command:
         print(date)
 
     def _validate_transform_common_args(self, args):
+        refresh_period_ns = None
+        if args.refresh is not None:
+            try:
+                refresh_period_ns = common.duration_str_to_ns(args.refresh)
+            except ValueError as e:
+                self._cmdline_error(str(e))
+
         self._analysis_conf = analysis.AnalysisConfig()
-        self._analysis_conf.refresh_period = args.refresh
+        self._analysis_conf.refresh_period = refresh_period_ns
         self._analysis_conf.period_begin_ev_name = args.period_begin
         self._analysis_conf.period_end_ev_name = args.period_end
 
@@ -138,8 +145,9 @@ class Command:
 
         # common arguments
         ap.add_argument('path', metavar='<path/to/trace>', help='trace path')
-        ap.add_argument('-r', '--refresh', type=int,
-                        help='Refresh period in seconds')
+        ap.add_argument('-r', '--refresh', type=str,
+                        help='Refresh period, with optional units suffix '
+                        '(default units: s)')
         ap.add_argument('--limit', type=int, default=10,
                         help='Limit to top X (default = 10)')
         ap.add_argument('--no-progress', action='store_true',
index 0bb9c3df09ad2f2da1ea9da97c30dc0bb6e85cf6..ea519c8174c2100a71f241f6263fb8a0c3897606 100644 (file)
@@ -46,9 +46,6 @@ class Analysis:
         self._notification_cbs = {}
         self._cbs = {}
 
-        if self._conf.refresh_period is not None:
-            self._conf.refresh_period *= common.NSEC_PER_SEC
-
         self.started = False
         self.ended = False
 
This page took 0.025809 seconds and 5 git commands to generate.