Use CrosRunCommand to find if cherrypy is available. Fixed bug in CrosRunCommand

Call CrosRunCommand instead of calling ssh directly to find if cherrypy
is available.
Also fix bug in CrosRunCommand. The retval returned was always 0.

BUG=None
TEST=Reproduced with small test cases.

Change-Id: I277416b1809eb7287a75bd224b4154f442132a52
Reviewed-on: https://chrome-internal-review.googlesource.com/161123
Reviewed-by: Han Shen <shenhan@google.com>
Tested-by: Luis Lozano <llozano@chromium.org>
Commit-Queue: Caroline Tice <cmtice@google.com>
diff --git a/image_chromeos.py b/image_chromeos.py
index 60e1e9e..460215a 100755
--- a/image_chromeos.py
+++ b/image_chromeos.py
@@ -47,15 +47,10 @@
     chroot_has_cros_flash = True
 
   # Check to see if remote machine has cherrypy.
-  keypath = os.path.join (os.path.realpath(chromeos_root),
-                          "src/scripts/mod_for_test_scripts/ssh_keys/"
-                          "testing_rsa")
-
-  command = ("ssh -i %s -o StrictHostKeyChecking=no -o CheckHostIP=no "
-             "-o BatchMode=yes -o UserKnownHostsFile=/dev/null "
-             "root@%s \"python -c 'import cherrypy'\" " %
-             (keypath,remote) )
-  retval = cmd_executer.RunCommand (command)
+  command = "python -c 'import cherrypy'"
+  retval = cmd_executer.CrosRunCommand (command,
+                                        chromeos_root=chromeos_root,
+                                        machine=remote)
   logger.GetLogger().LogFatalIf(retval == 255, "Failed ssh to %s" % remote)
   if retval == 0:
     remote_has_cherrypy = True
diff --git a/utils/command_executer.py b/utils/command_executer.py
index 60aeef1..d4c329e 100644
--- a/utils/command_executer.py
+++ b/utils/command_executer.py
@@ -209,7 +209,7 @@
 
     command = self.RemoteAccessInitCommand(chromeos_root, machine)
     command += "\nremote_sh bash %s" % command_file
-    command += "\necho \"$REMOTE_OUT\""
+    command += "\nl_retval=$?; echo \"$REMOTE_OUT\"; exit $l_retval"
     retval = self.RunCommand(command, return_output,
                              command_terminator=command_terminator,
                              command_timeout=command_timeout,