Merge "Increase Ping scenario ssh timeout limit to 600 seconds"
[yardstick.git] / yardstick / benchmark / scenarios / availability / result_checker / result_checker_general.py
index ae896c2..275aff0 100644 (file)
@@ -20,7 +20,7 @@ class GeneralResultChecker(BaseResultChecker):
     __result_checker__type__ = "general-result-checker"
 
     def setup(self):
-        LOG.debug("config:%s context:%s" % (self._config, self._context))
+        LOG.debug("config:%s context:%s", self._config, self._context)
         host = self._context.get(self._config['host'], None)
         ip = host.get("ip", None)
         user = host.get("user", "root")
@@ -53,21 +53,23 @@ class GeneralResultChecker(BaseResultChecker):
 
     def verify(self):
         if "parameter" in self._config:
-            exit_status, stdout, stderr = self.connection.execute(
-                self.shell_cmd,
-                stdin=open(self.verify_script, "r"))
+            with open(self.verify_script, "r") as stdin_file:
+                exit_status, stdout, stderr = self.connection.execute(
+                    self.shell_cmd,
+                    stdin=stdin_file)
             LOG.debug("action script of the operation is: {0}"
                       .format(self.verify_script))
             LOG.debug("action parameter the of operation is: {0}"
                       .format(self.shell_cmd))
         else:
-            exit_status, stdout, stderr = self.connection.execute(
-                "/bin/bash -s ",
-                stdin=open(self.verify_script, "r"))
+            with open(self.verify_script, "r") as stdin_file:
+                exit_status, stdout, stderr = self.connection.execute(
+                    "/bin/bash -s ",
+                    stdin=stdin_file)
             LOG.debug("action script of the operation is: {0}"
                       .format(self.verify_script))
 
-        LOG.debug("exit_status ,stdout : {0} ,{1}".format(exit_status, stdout))
+        LOG.debug("exit_status ,stdout : %s ,%s", exit_status, stdout)
         if exit_status == 0 and stdout:
             self.actualResult = stdout
             LOG.debug("verifying resultchecker: {0}".format(self.key))
@@ -104,6 +106,6 @@ class GeneralResultChecker(BaseResultChecker):
             LOG.error(stderr)
 
         LOG.debug(
-            "verifying resultchecker: {0},the result is : {1}"
-            .format(self.key, self.success))
+            "verifying resultchecker: %s,the result is : %s", self.key,
+            self.success)
         return self.success