Merge "Show waiting for boot failure when boot actually fails."
diff --git a/public/acloud_main.py b/public/acloud_main.py
index 780a61d..dd85b92 100644
--- a/public/acloud_main.py
+++ b/public/acloud_main.py
@@ -45,11 +45,34 @@
 Try $acloud [cmd] --help for further details.
 
 """
+
+from __future__ import print_function
 import argparse
 import getpass
 import logging
+import platform
 import sys
 
+# TODO: Remove this once we switch over to embedded launcher.
+# Exit out if python version is < 2.7.13 due to b/120883119.
+if (sys.version_info.major == 2
+        and sys.version_info.minor == 7
+        and sys.version_info.micro < 13):
+    print("Acloud requires python version 2.7.13+ (currently @ %d.%d.%d)" %
+          (sys.version_info.major, sys.version_info.minor,
+           sys.version_info.micro))
+    print("Update your 2.7 python with:")
+    # pylint: disable=invalid-name
+    os_type = platform.system().lower()
+    if os_type == "linux":
+        print("  apt-get install python2.7")
+    elif os_type == "darwin":
+        print("  brew install python@2 (and then follow instructions at "
+              "https://docs.python-guide.org/starting/install/osx/)")
+        print("  - or -")
+        print("  POSIXLY_CORRECT=1 port -N install python27")
+    sys.exit(1)
+
 # Needed to silence oauth2client.
 # This is a workaround to get rid of below warning message:
 # 'No handlers could be found for logger "oauth2client.contrib.multistore_file'
diff --git a/setup/pre_setup_sh/acloud_pre_setup.sh b/setup/pre_setup_sh/acloud_pre_setup.sh
index d6ad80e..45b1aed 100755
--- a/setup/pre_setup_sh/acloud_pre_setup.sh
+++ b/setup/pre_setup_sh/acloud_pre_setup.sh
@@ -1,8 +1,10 @@
 #!/bin/bash
 
+source "$ANDROID_BUILD_TOP/tools/acloud/setup/pre_setup_sh/setup_utils.sh"
+
 # Run any scripts in this dir and in any extra specified locations.
 SCRIPT_LOCATIONS=(
-  $(dirname $(realpath $0))
+  $(dirname $(get_real_path $0))
   "$ANDROID_BUILD_TOP/vendor/google/tools/acloud"
 )
 
diff --git a/setup/pre_setup_sh/setup_utils.sh b/setup/pre_setup_sh/setup_utils.sh
new file mode 100755
index 0000000..90a9c1e
--- /dev/null
+++ b/setup/pre_setup_sh/setup_utils.sh
@@ -0,0 +1,11 @@
+#!/bin/bash
+
+# Just in case realpath doesn't exist, try a perl approach.
+function get_real_path()
+{
+  if realpath $0 &> /dev/null; then
+    realpath $0
+    return
+  fi
+  perl -e 'use Cwd "abs_path";print abs_path(shift)' $0
+}