CLI: store api_map_list with the related trace 56/160156/5
authorAlexander Aksenov <a.aksenov@samsung.com>
Tue, 14 Nov 2017 15:04:06 +0000 (18:04 +0300)
committerAlexander Aksenov <a.aksenov@samsung.com>
Thu, 16 Nov 2017 17:09:10 +0000 (20:09 +0300)
Change-Id: Ib38880da64e538814421978af9d979cbf50311b2
Signed-off-by: Alexander Aksenov <a.aksenov@samsung.com>
src/cli/swap_cli/swap.py

index 044a6d47c60a2d49bfb37ff2fb2dec3bfc7e50b0..e3e77d4c7b464b9d78efb018f8fd44e86319b94b 100644 (file)
@@ -19,6 +19,7 @@ class Client(object):
     __VERSION = "0.0.1"
     __TRACE_FILE = "/trace.bin"
     __SESSION_INFO_FILE = "session_info.json"
+    __API_MAP = "api_map_list"
     __DEV_KEY = "dev_for_energy_profiling"
 
     def __init__(self, target_conf):
@@ -34,7 +35,6 @@ class Client(object):
         log_level = logging.DEBUG
         self.__conf = config.Config()
         self.__conf.load_target_conf(target_conf)
-        self.__api_map_path = 'api_map_list'    # TODO: Move to config
         self.__intr = None
         self.__net = None
         self.__commands = None
@@ -53,7 +53,6 @@ class Client(object):
         proto_data = raw_interface.RawInterfaceData(self.__net.sock())
         self.__commands = proto_data.get_commands()
         self.__commands.init(self.__net.sock(), self.__conf.instrumentation())
-        self.__get_api_map_list()
         self.__handler.set_data_messages(proto_data.get_data_messages())
         self.__conf.features.init_features(self.__handler, self.__intr,
                                            self.__outdir)
@@ -62,18 +61,19 @@ class Client(object):
         del self.__net
         del self.__intr
 
-    def __get_api_map_list(self):
+    def __get_api_map_list(self, outdir):
         # Get API map list
+        api_map_path = os.path.join(outdir, self.__API_MAP)
         ver = self.__commands.version()
         self.__proto_ver = ver
         if ver == '3.0' or ver == 'no_version':
-            res = self.__intr.pull("/usr/lib/da_api_map", self.__api_map_path)
+            res = self.__intr.pull("/usr/lib/da_api_map", api_map_path)
             if res[0] == -1:
                 logging.error('Cannot get API map list')
         else:
             # protocol_ver >= 4.0
             api_map = self.__commands.get_probemap()
-            f = open(self.__api_map_path, 'w')
+            f = open(api_map_path, 'w')
             if f is not None:
                 for n in api_map:
                     f.write('%s %s\n' % (n - 1, api_map[n]))
@@ -160,6 +160,7 @@ class Client(object):
         self.__create_folder_on_demand(outdir)
         self.__trace = nc.NetCat()
         self.__connect()
+        self.__get_api_map_list(outdir)
         self.__handler.prepare_to_start()
 
         self.__trace.start(self.__net.ip, self.__net.port,