X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=resources%2Flibraries%2Fpython%2FPapiHistory.py;h=ec5b1675eb654f02890af624f70b1e8dee5c93c5;hb=1999c2ecc15760a57bdf34498635432ddb0321e0;hp=13c483b4bceeca1423fa2c274e9413e61b076b77;hpb=2251c68ea3d862b08df030231a1ddf618a2cec2b;p=csit.git diff --git a/resources/libraries/python/PapiHistory.py b/resources/libraries/python/PapiHistory.py index 13c483b4bc..ec5b1675eb 100644 --- a/resources/libraries/python/PapiHistory.py +++ b/resources/libraries/python/PapiHistory.py @@ -48,16 +48,19 @@ class PapiHistory(object): PapiHistory.reset_papi_history(node) @staticmethod - def add_to_papi_history(node, cmd, papi=True, **kwargs): + def add_to_papi_history(node, csit_papi_command, papi=True, **kwargs): """Add command to PAPI command history on DUT node. + The argument name 'csit_papi_command' must be unique enough as it cannot + be repeated in kwargs. + :param node: DUT node to add command to PAPI command history for. - :param cmd: Command to be added to PAPI command history. + :param csit_papi_command: Command to be added to PAPI command history. :param papi: Says if the command to store is PAPi or VAT. Remove when VAT executor is completely removed. :param kwargs: Optional key-value arguments. :type node: dict - :type cmd: str + :type csit_papi_command: str :type papi: bool :type kwargs: dict """ @@ -65,12 +68,13 @@ class PapiHistory(object): args = list() for key, val in kwargs.iteritems(): args.append("{key}={val}".format(key=key, val=val)) - item = "{cmd}({args})".format(cmd=cmd, args=",".join(args)) + item = "{cmd}({args})".format(cmd=csit_papi_command, + args=",".join(args)) else: # This else part is here to store VAT commands. # VAT history is not used. # TODO: Remove when VatExecutor is completely removed. - item = "{cmd}".format(cmd=cmd) + item = "{cmd}".format(cmd=csit_papi_command) DICT__DUTS_PAPI_HISTORY[node['host']].append(item) @staticmethod @@ -80,12 +84,12 @@ class PapiHistory(object): :param node: DUT node to show PAPI command history for. :type node: dict """ - history = "\nNo PAPI command executed" - if DICT__DUTS_PAPI_HISTORY[node['host']]: - history = "".join(["\n{}".format( - cmd) for cmd in DICT__DUTS_PAPI_HISTORY[node['host']]]) + history_list = DICT__DUTS_PAPI_HISTORY[node['host']] + if not history_list: + history_list = ("No PAPI command executed", ) logger.trace( - "{0} PAPI command history:\n{1}\n".format(node['host'], history)) + "{0} PAPI command history:\n{1}\n".format( + node['host'], "\n".join(history_list))) @staticmethod def show_papi_history_on_all_duts(nodes):