summaryrefslogtreecommitdiff
path: root/buildscripts/utils.py
diff options
context:
space:
mode:
authorAntonin Kral <a.kral@bobek.cz>2012-03-30 21:40:45 +0200
committerAntonin Kral <a.kral@bobek.cz>2012-03-30 21:40:45 +0200
commiteaaa7b30c99b89b5483e0a372bb73fe8c8695185 (patch)
tree6c08f243b00c0f6b7a4897a236774cf484e61314 /buildscripts/utils.py
parentba59b00736b5b8dc0f0bd46397575aaf0cd4d44f (diff)
downloadmongodb-eaaa7b30c99b89b5483e0a372bb73fe8c8695185.tar.gz
Imported 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"
+