Added warning to Python version checker script.

After the user has installed Python 3, if they use the Python 2
scripts, we want to alert them to start using (and therefore testing)
the ported Python 3 scripts.

Review: https://reviews.apache.org/r/67292/


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/ae4e7956
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/ae4e7956
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/ae4e7956

Branch: refs/heads/master
Commit: ae4e7956a2217ceaa02575d160a9d52a21825f07
Parents: 960df5c
Author: Andrew Schwartzmeyer <[email protected]>
Authored: Thu May 24 14:58:34 2018 -0700
Committer: Andrew Schwartzmeyer <[email protected]>
Committed: Thu May 24 15:01:58 2018 -0700

----------------------------------------------------------------------
 support/check-python3.py | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/ae4e7956/support/check-python3.py
----------------------------------------------------------------------
diff --git a/support/check-python3.py b/support/check-python3.py
index 4cb5365..08252d8 100644
--- a/support/check-python3.py
+++ b/support/check-python3.py
@@ -30,6 +30,15 @@ def print_error():
     print("The support scripts will be upgraded to Python 3 by July 1st.")
     print("Make sure to install Python 3.6 on your machine before.")
 
+def print_warning():
+    """Prints a warning requesting to use the Python 3 scripts."""
+    print("Congratulations! You have Python 3 installed correctly.")
+    print("Please start using the scripts in `support/python3`.")
+    # NOTE: This is only either unset, or set to 3.
+    if "MESOS_SUPPORT_PYTHON" not in os.environ:
+        print("Please also set the environment variable `MESOS_SUPPORT_PYTHON` 
to `3`")
+        print("so that the Git hooks use the Python 3 scripts.")
+
 if sys.version_info[0] < 3:
     # On Windows, system-wide installations of Python 3.6 gives a tools called
     # py and that we can use to know if Python 3 is installed.
@@ -51,6 +60,11 @@ if sys.version_info[0] < 3:
         for x in range(0, 6):
             if "3.%d." % (x) in VERSION:
                 print_error()
+                sys.exit()
+        # This script only gets invoked by the Python 2 scripts, so we
+        # can assume we need to warn the user to start using the
+        # Python 3 scripts.
+        print_warning()
 elif sys.version_info[1] < 6:
     # python is by default Python 3 but it's < 3.6.
     print_error()

Reply via email to