X-Git-Url: https://gerrit.fd.io/r/gitweb?p=csit.git;a=blobdiff_plain;f=resources%2Flibraries%2Fpython%2FVatExecutor.py;h=26d4b75781e36fdd33c2daf874b35ebd7e6bd9d3;hp=2d6a03327b0a9294ab84aceda060ef1b84443b07;hb=b55e324d526e5b05baef015c3614b9743c955992;hpb=d68951ac245150eeefa6e0f4156e4c1b5c9e9325 diff --git a/resources/libraries/python/VatExecutor.py b/resources/libraries/python/VatExecutor.py index 2d6a03327b..26d4b75781 100644 --- a/resources/libraries/python/VatExecutor.py +++ b/resources/libraries/python/VatExecutor.py @@ -1,4 +1,4 @@ -# Copyright (c) 2019 Cisco and/or its affiliates. +# Copyright (c) 2020 Cisco and/or its affiliates. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at: @@ -20,6 +20,8 @@ from os import remove from paramiko.ssh_exception import SSHException from robot.api import logger +import resources.libraries.python.DUTSetup as PidLib + from resources.libraries.python.Constants import Constants from resources.libraries.python.PapiHistory import PapiHistory from resources.libraries.python.ssh import SSH, SSHTimeout @@ -60,9 +62,7 @@ def get_vpp_pid(node): running on the DUT node. :rtype: int or list """ - # pylint: disable=import-outside-toplevel - import resources.libraries.python.DUTSetup as PidLib - pid = PidLib.DUTSetup.get_vpp_pid(node) + pid = PidLib.DUTSetup.get_pid(node, u"vpp") return pid @@ -113,7 +113,7 @@ class VatExecutor: ssh.scp(vat_name, vat_name) remote_file_path = vat_name if history: - with open(vat_name, "r") as vat_file: + with open(vat_name, u"rt") as vat_file: for line in vat_file: PapiHistory.add_to_papi_history( node, line.replace(u"\n", u""), papi=False @@ -155,7 +155,7 @@ class VatExecutor: :type timeout: int :type json_out: bool """ - with open(tmp_fn, "w") as tmp_f: + with open(tmp_fn, u"wt") as tmp_f: tmp_f.writelines(commands) self.execute_script( @@ -251,7 +251,8 @@ class VatTerminal: self._tty = self._ssh.interactive_terminal_open() except Exception: raise RuntimeError( - f"Cannot open interactive terminal on node {self._node}" + f"Cannot open interactive terminal on node " + f"{self._node[u'host']}" ) for _ in range(3): @@ -387,7 +388,7 @@ class VatTerminal: """ file_path = f"{Constants.RESOURCES_TPL_VAT}/{vat_template_file}" - with open(file_path, "r") as template_file: + with open(file_path, u"rt") as template_file: cmd_template = template_file.readlines() ret = list() for line_tmpl in cmd_template: