summaryrefslogtreecommitdiff
path: root/scripts/python-check
diff options
context:
space:
mode:
authorRichard Maw <richard.maw@codethink.co.uk>2012-11-13 15:45:40 +0000
committerRichard Maw <richard.maw@codethink.co.uk>2012-11-13 16:15:04 +0000
commit75453f4ce61e6ad9e44b39c3681b5ede133af447 (patch)
tree0197190e5cbacd76efd08c464a807a78a2fbf08e /scripts/python-check
parent2ac6f661130322e63b8d2737145ea11d445aaa79 (diff)
downloadmorph-75453f4ce61e6ad9e44b39c3681b5ede133af447.tar.gz
Consolidate checks for python version
Most of the bespoke logic for the version check is unnecessary, since the output to display can be easily inferred from the filename. This fixes some test failures where the version check would cat a file to fake the output, but fail because the file was removed.
Diffstat (limited to 'scripts/python-check')
-rw-r--r--scripts/python-check36
1 files changed, 36 insertions, 0 deletions
diff --git a/scripts/python-check b/scripts/python-check
new file mode 100644
index 00000000..6b79897f
--- /dev/null
+++ b/scripts/python-check
@@ -0,0 +1,36 @@
+#!/bin/sh
+# Copyright (C) 2012 Codethink Limited
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+# When sourced by scripts, if the python version is too old
+# fake the output and exit.
+
+if ! python --version 2>&1 | grep '^Python 2\.[78]' > /dev/null
+then
+ outpath="$(dirname "$0")/$(basename "$0" .script).stdout"
+ errpath="$(dirname "$0")/$(basename "$0" .script).stderr"
+ exitpath="$(dirname "$0")/$(basename "$0" .script).exit"
+ if [ -r "$outpath" ]; then
+ cat "$outpath"
+ fi
+ if [ -r "$errpath" ]; then
+ cat "$errpath" >&2
+ fi
+ if [ -r "$exitpath" ]; then
+ exit "$(cat "$exitpath")"
+ else
+ exit 0
+ fi
+fi