From 7395003e6abaab8247e0eeaf5fb0b2dc89b88ca3 Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Mon, 16 Nov 2015 08:40:32 -0800 Subject: [PATCH] Fix buggy #! lines using "/usr/bin/env python2.7 -u". The #! line processing interpreted the argument to pass to `env` as "python2.7 -u", which obviously isn't a real program. We fix this by setting the PYTHONUNBUFFERED environment variable inside the program, which has the same effect. Thanks to Dan Fedele for the bug report and suggested solution! --- scripts/lib/unpack-zulip | 4 +++- scripts/lib/upgrade-zulip | 4 +++- scripts/lib/upgrade-zulip-stage-2 | 4 +++- tools/test-backend | 3 ++- tools/update-deployment | 4 +++- 5 files changed, 14 insertions(+), 5 deletions(-) diff --git a/scripts/lib/unpack-zulip b/scripts/lib/unpack-zulip index 6ce0d88f34..112fd1401f 100755 --- a/scripts/lib/unpack-zulip +++ b/scripts/lib/unpack-zulip @@ -1,4 +1,4 @@ -#!/usr/bin/env python2.7 -u +#!/usr/bin/env python2.7 import os import sys import subprocess @@ -6,6 +6,8 @@ import datetime import tempfile import glob +os.environ["PYTHONUNBUFFERED"] = "y" + sys.path.append(os.path.join(os.path.dirname(__file__), '..', "..")) from zulip_tools import DEPLOYMENTS_DIR, FAIL, ENDC, make_deploy_path diff --git a/scripts/lib/upgrade-zulip b/scripts/lib/upgrade-zulip index 674171af89..fa21095087 100755 --- a/scripts/lib/upgrade-zulip +++ b/scripts/lib/upgrade-zulip @@ -1,4 +1,4 @@ -#!/usr/bin/env python2.7 -u +#!/usr/bin/env python2.7 import os import sys import subprocess @@ -6,6 +6,8 @@ import logging import shutil import time +os.environ["PYTHONUNBUFFERED"] = "y" + sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..')) from zulip_tools import DEPLOYMENTS_DIR, LOCK_DIR, FAIL, WARNING, ENDC, \ su_to_zulip diff --git a/scripts/lib/upgrade-zulip-stage-2 b/scripts/lib/upgrade-zulip-stage-2 index 07854e3f5a..fba5e62232 100755 --- a/scripts/lib/upgrade-zulip-stage-2 +++ b/scripts/lib/upgrade-zulip-stage-2 @@ -1,9 +1,11 @@ -#!/usr/bin/env python2.7 -u +#!/usr/bin/env python2.7 import subprocess import os import sys import logging +os.environ["PYTHONUNBUFFERED"] = "y" + sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..')) from zulip_tools import FAIL, WARNING, ENDC, su_to_zulip diff --git a/tools/test-backend b/tools/test-backend index bbb324ccb9..2e73744a6d 100755 --- a/tools/test-backend +++ b/tools/test-backend @@ -12,4 +12,5 @@ esac cd "$(dirname "$0")"/.. ./tools/generate-fixtures # "-u" uses unbuffered IO, which is important when wrapping it in subprocess -/usr/bin/env python2.7 -u ./manage.py test "$target" --settings=zproject.test_settings "$@" +export PYTHONUNBUFFERED="y" +/usr/bin/env python2.7 ./manage.py test "$target" --settings=zproject.test_settings "$@" diff --git a/tools/update-deployment b/tools/update-deployment index d5c7e941a0..8584579852 100755 --- a/tools/update-deployment +++ b/tools/update-deployment @@ -1,4 +1,4 @@ -#!/usr/bin/env python2.7 -u +#!/usr/bin/env python2.7 import os import sys import subprocess @@ -7,6 +7,8 @@ import datetime import shutil import time +os.environ["PYTHONUNBUFFERED"] = "y" + sys.path.append(os.path.join(os.path.dirname(__file__), '..')) from zulip_tools import DEPLOYMENTS_DIR, LOCK_DIR, FAIL, WARNING, ENDC, make_deploy_path