Bug 1380780 - Drop support for python < 2.7 in client.py. r=jorgk
authorTom Prince <mozilla@hocat.ca>
Thu, 13 Jul 2017 13:27:58 -0600
changeset 28442 0e10366a7f2b91d381c0f761a09578225e87f8f0
parent 28441 3a4c51fcb4aa98885607679be7c4c7b5082641d4
child 28443 7be30a48e5cf2c7d70fadb1f348879c17806c5f5
push idunknown
push userunknown
push dateunknown
reviewersjorgk
bugs1380780
Bug 1380780 - Drop support for python < 2.7 in client.py. r=jorgk Python 2.7 is already required elsewhere, so get rid of old compatability code. MozReview-Commit-ID: 8jOETZlW9yu
client.py
--- a/client.py
+++ b/client.py
@@ -1,17 +1,13 @@
 #!/usr/bin/env python
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-
-# Warning, this file must be compatible with Python 2.4, for our
-# various tools, such as http://mxr.mozilla.org/ see-also: Bug 601207
-
 # Repo Defaults
 # 'REV' controls the default rev for All the various repo's
 # Define x_REV to override. Where x can be one of:
 #  "COMM", "MOZILLA", "CHATZILLA", "INSPECTOR"
 DEFAULTS = {
     # Global Default Revision
     'REV': "default",
 
@@ -61,67 +57,37 @@ SWITCH_MOZILLA_REPO_BACKUP_LOCATION = ".
 # switched. Can be blank for no effect.
 SWITCH_MOZILLA_REPO_OLD_REPO_LOCATION = ".mozilla-trunk"
 # This should be the same as DEFAULTS['MOZILLA_REPO'] but using %s instead
 # of http for the scheme.
 SWITCH_MOZILLA_REPO_REPLACE = '%s://hg.mozilla.org/mozilla-central/'
 SWITCH_MOZILLA_BASE_REV = "GECKO_1_9_1_BASE"
 
 import sys
-# Test Python Version. 2.4 required for `import subprocess`
 pyver = sys.version_info
-if pyver[0] <= 1 or (pyver[0] == 2 and pyver[1] < 4):
-    sys.exit("ERROR: Python 2.4 or newer required")
+if pyver[0] <= 1 or (pyver[0] == 2 and pyver[1] < 7):
+    sys.exit("ERROR: Python 2.7 or newer required")
 elif pyver[0] >= 3:
     # Python series 3 will syntax error here, Hack needed per Bug 601649c#8
-    print "ERROR: Python series 3 is not supported, use series 2 >= 2.4"
+    print "ERROR: Python series 3 is not supported, use python 2.7"
     sys.exit()  # Do an explicit sys.exit for code clarity.
 del pyver
 
 import os
 from optparse import OptionParser, OptionValueError
 import urllib2
 import re
 
 topsrcdir = os.path.dirname(__file__)
 if topsrcdir == '':
     topsrcdir = '.'
 
 TREE_STATE_FILE = os.path.join(topsrcdir, '.treestate')
 
-try:
-    from subprocess import check_call
-except ImportError:
-    import subprocess
-
-    def check_call(*popenargs, **kwargs):
-        retcode = subprocess.call(*popenargs, **kwargs)
-        if retcode:
-            cmd = kwargs.get("args")
-            if cmd is None:
-                cmd = popenargs[0]
-                raise Exception("Command '%s' returned non-zero exit status %i" % (cmd, retcode))
-
-try:
-    from subprocess import check_output
-except ImportError:
-    import subprocess
-
-    def check_output(*popenargs, **kwargs):
-        if 'stdout' in kwargs:
-            raise ValueError('stdout argument not allowed, it will be overridden.')
-        process = subprocess.Popen(stdout=subprocess.PIPE, *popenargs, **kwargs)
-        output, unused_err = process.communicate()
-        retcode = process.poll()
-        if retcode:
-            cmd = kwargs.get("args")
-            if cmd is None:
-                cmd = popenargs[0]
-            raise CalledProcessError(retcode, cmd, output=output)
-        return output
+from subprocess import check_call, check_output
 
 
 def check_call_output(cmd, *args, **kwargs):
     return check_output(cmd, *args, **kwargs)
 
 
 def check_call_noisy(cmd, retryMax=0, *args, **kwargs):
     """Wrapper around execute_check_call() to allow retries before failing.