cli: add --mi-version to print produced MI version
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Sat, 23 Apr 2016 00:50:22 +0000 (20:50 -0400)
committerAntoine Busque <abusque@efficios.com>
Tue, 26 Apr 2016 17:08:36 +0000 (13:08 -0400)
The MI version can be printed as a simple plain text string
with this option to allow an eventual major bump of the protocol
changing the format from JSON to something else.

This option is specified by LAMI 1.0.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
lttnganalyses/cli/command.py
lttnganalyses/cli/mi.py

index 3250a36bb9491114c34d4ac7b9f984ab3ee8dc06..602d7dd722d5baa05e184b4897dadc530925d72f 100644 (file)
@@ -393,6 +393,11 @@ class Command:
                 args.freq_uniform = True
 
         if self._mi_mode:
+            # print MI version if required
+            if args.mi_version:
+                print(mi.get_version_string())
+                sys.exit(0)
+
             # print MI metadata if required
             if args.metadata:
                 self._mi_print_metadata()
@@ -451,8 +456,10 @@ class Command:
 
         # MI mode-dependent arguments
         if self._mi_mode:
+            ap.add_argument('--mi-version', action='store_true',
+                            help='Print MI version')
             ap.add_argument('--metadata', action='store_true',
-                            help='Show analysis\'s metadata')
+                            help='Print analysis\' metadata')
             ap.add_argument('path', metavar='<path/to/trace>',
                             help='trace path', nargs='*')
             ap.add_argument('--output-progress', action='store_true',
index 0f5e5eacef4cf65c2d8b5d72b9dd889797020cc9..a2dd0515e6f995c562b978d61358c4753322567a 100644 (file)
@@ -24,6 +24,9 @@ from collections import namedtuple
 import sys
 
 
+_MI_VERSION = (1, 0)
+
+
 class Tags:
     CPU = 'cpu'
     MEMORY = 'memory'
@@ -512,8 +515,8 @@ def get_metadata(version, title, description, authors, url, tags,
 
     return {
         'mi-version': {
-            'major': 0,
-            'minor': 1,
+            'major': _MI_VERSION[0],
+            'minor': _MI_VERSION[1],
         },
         'version': {
             'major': version.major,
@@ -553,6 +556,10 @@ def get_progress(at=None, msg=None):
     return '{}{}'.format(at, add)
 
 
+def get_version_string():
+    return '{}.{}'.format(_MI_VERSION[0], _MI_VERSION[1])
+
+
 def print_progress(at=None, msg=None):
     print(get_progress(at, msg))
     sys.stdout.flush()
This page took 0.026501 seconds and 5 git commands to generate.