support/buildbot/generate_headers.py
changeset 878 d907f4f4eeb6
parent 874 7ff2546e4b65
     1.1 --- a/support/buildbot/generate_headers.py	Mon Nov 18 10:33:05 2013 -0800
     1.2 +++ b/support/buildbot/generate_headers.py	Mon Nov 18 10:42:49 2013 -0800
     1.3 @@ -13,9 +13,20 @@
     1.4  
     1.5  def get_hg_version():
     1.6    argv = ['hg', 'parent', '-R', SourceFolder]
     1.7 -  text = subprocess.check_output(argv)
     1.8 -  if str != bytes:
     1.9 -    text = str(text, 'utf-8')
    1.10 +
    1.11 +  # Python 2.6 doesn't have check_output.
    1.12 +  if hasattr(subprocess, 'check_output'):
    1.13 +    text = subprocess.check_output(argv)
    1.14 +    if str != bytes:
    1.15 +      text = str(text, 'utf-8')
    1.16 +  else:
    1.17 +    p = subprocess.Popen(argv, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    1.18 +    output, ignored = p.communicate()
    1.19 +    rval = p.poll()
    1.20 +    if rval:
    1.21 +      raise subprocess.CalledProcessError(rval, argv)
    1.22 +    text = output.decode('utf8')
    1.23 +
    1.24    m = re.match('changeset:\s+(\d+):(.+)', text)
    1.25    if m == None:
    1.26      raise Exception('Could not determine repository version')