Add a --py2 command line flag (#26507)

This is to help with the transition to Python 3
diff --git a/tools/wpt/wpt.py b/tools/wpt/wpt.py
index efa985c..9bc6ce6 100644
--- a/tools/wpt/wpt.py
+++ b/tools/wpt/wpt.py
@@ -50,7 +50,10 @@
                         dest="skip_venv_setup",
                         help="Whether to use the virtualenv as-is. Must set --venv as well")
     parser.add_argument("--debug", action="store_true", help="Run the debugger in case of an exception")
-    parser.add_argument("--py3", action="store_true", help="Run with python3")
+    parser.add_argument("--py3", action="store_true",
+                        help="Run with Python 3 (requires a `python3` binary on the PATH)")
+    parser.add_argument("--py2", action="store_true",
+                        help="Run with Python 2 (requires a `python2` binary on the PATH)")
     subparsers = parser.add_subparsers(dest="command")
     for command, props in iteritems(commands):
         subparsers.add_parser(command, help=props["help"], add_help=False)
diff --git a/wpt b/wpt
index 329ea66..9fea20d 100755
--- a/wpt
+++ b/wpt
@@ -7,7 +7,20 @@
     commands = wpt.load_commands()
     py3only = commands[args.command]["py3only"]
 
-    if (args.py3 or py3only) and sys.version_info.major < 3:
+    if (args.py2) and sys.version_info.major > 2:
+        if py3only:
+            sys.stderr.write("This command only works with Python 3\n")
+            sys.exit(1)
+        from subprocess import call
+        try:
+            sys.exit(call(['python2'] + sys.argv))
+        except OSError as e:
+            if e.errno == 2:
+                sys.stderr.write("python2 is needed to run this command\n")
+                sys.exit(1)
+            else:
+                raise
+    elif (args.py3 or py3only) and sys.version_info.major < 3:
         from subprocess import call
         try:
             sys.exit(call(['python3'] + sys.argv))