from . import features_handler
import os
import errno
+import json
class Client(object):
__VERSION = "0.0.1"
__TRACE_FILE = "/trace.bin"
+ __SESSION_INFO_FILE = "session_info.json"
+ __DEV_KEY = "dev_for_energy_profiling"
def __init__(self, target_conf):
'''
self.__trace = None
self.__handler = handler.MessageHandler()
self.__outdir = None
+ self.__proto_ver = ""
logging.basicConfig(format=log_fmt, level=log_level)
def __connect(self):
def __get_api_map_list(self):
# Get API map list
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)
if res[0] == -1:
if e.errno != errno.EEXIST and not os.path.isdir(outdir):
raise
+ def __store_session_info(self, target_info):
+ store_info = {'device_num': len(target_info[self.__DEV_KEY]),
+ 'version': self.__proto_ver}
+ store_info.update(target_info)
+
+ json_info = json.dumps(store_info)
+ with open(os.path.join(self.__outdir, self.__SESSION_INFO_FILE), 'w') as f:
+ f.write(json_info)
+
+
def get_version(self):
'''
self.__trace.start(self.__net.ip, self.__net.port,
outdir + self.__TRACE_FILE, self.__handler)
+ self.__store_session_info(self.__commands.get_target_info())
self.__commands.swap_inst_add()
self.__commands.config()
self.__commands.start()