summaryrefslogtreecommitdiff
path: root/buildscripts/utils.py
diff options
context:
space:
mode:
authorAntonin Kral <a.kral@bobek.cz>2012-03-30 21:40:47 +0200
committerAntonin Kral <a.kral@bobek.cz>2012-03-30 21:40:47 +0200
commitf4cdad7de83b306b815e03435883794423b7a010 (patch)
tree3bf78e89033459d7bd6e7a92265a5085308c2b08 /buildscripts/utils.py
parent4bf70009546d751d87bc4912e9193341429f4b54 (diff)
parenteaaa7b30c99b89b5483e0a372bb73fe8c8695185 (diff)
downloadmongodb-f4cdad7de83b306b815e03435883794423b7a010.tar.gz
Merge tag 'upstream/2.0.4'
Upstream version 2.0.4
Diffstat (limited to 'buildscripts/utils.py')
-rw-r--r--buildscripts/utils.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/buildscripts/utils.py b/buildscripts/utils.py
index 8021d87..91409c7 100644
--- a/buildscripts/utils.py
+++ b/buildscripts/utils.py
@@ -134,3 +134,26 @@ def didMongodStart( port=27017 , timeout=20 ):
timeout = timeout - 1
return False
+def smoke_python_name():
+ # if this script is being run by py2.5 or greater,
+ # then we assume that "python" points to a 2.5 or
+ # greater python VM. otherwise, explicitly use 2.5
+ # which we assume to be installed.
+ import subprocess
+ version = re.compile(r'[Pp]ython ([\d\.]+)', re.MULTILINE)
+ binaries = ['python2.5', 'python2.6', 'python2.7', 'python25', 'python26', 'python27', 'python']
+ for binary in binaries:
+ try:
+ # py-2.4 compatible replacement for shell backticks
+ out, err = subprocess.Popen([binary, '-V'], stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
+ for stream in (out, err):
+ match = version.search(stream)
+ if match:
+ versiontuple = tuple(map(int, match.group(1).split('.')))
+ if versiontuple >= (2, 5):
+ return binary
+ except:
+ pass
+ # if that all fails, fall back to "python"
+ return "python"
+