Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

some cleanup of Jack's get_python_version code

  • Loading branch information...
commit 33d19eba80f73aa046bb481601474c984e083d29 1 parent f1e2a40
@ctb authored
View
3  client/build-quixote
@@ -11,7 +11,8 @@ python_exe = options.python_executable
repo_url = 'git://quixote.ca/quixote'
-tags = [get_python_version(python_exe)] + options.tagset
+python_ver = 'python' + get_python_version(python_exe)
+tags = [python_ver] + options.tagset
name = 'quixote'
server_url = options.server_url
View
20 client/pony_client.py
@@ -888,13 +888,21 @@ def __str__(self):
return repr(self.python_exe + " not found on system.")
-def get_python_version(python_exe):
- result = subprocess.Popen(python_exe + " -c \"import sys \nprint" \
- " str(sys.version_info[0]) + '.' + str(sys.version_info[1])\"", shell=True, \
- stdout=subprocess.PIPE).communicate()
- if result[0] == '':
+def get_python_version(python_exe='python'):
+ """
+ Return the major.minor number for the given Python executable.
+ """
+
+ cmd = python_exe + " -c \"import sys \nprint" \
+ " str(sys.version_info[0]) + '.' + str(sys.version_info[1])\""
+
+ p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE)
+ (stdout, stderr) = p.communicate()
+
+ if not stdout:
raise PythonVersionNotFound(python_exe)
- return "python" + str(result[0][:-1])
+
+ return stdout.strip()
###
View
9 client/test_client/__init__.py
@@ -1,4 +1,13 @@
+import sys
import pony_client
def setup():
pony_client.set_log_level(pony_client.DEBUG_LEVEL)
+
+def test_python_version():
+ my_version = "%d.%d" % (sys.version_info[:2])
+
+ reported_version = pony_client.get_python_version(sys.executable)
+ reported_version = reported_version
+
+ assert my_version == reported_version, (my_version, reported_version)
Please sign in to comment.
Something went wrong with that request. Please try again.