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!
This commit is contained in:
Tim Abbott 2015-11-16 08:40:32 -08:00
parent ac35d26868
commit 7395003e6a
5 changed files with 14 additions and 5 deletions

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python2.7 -u #!/usr/bin/env python2.7
import os import os
import sys import sys
import subprocess import subprocess
@ -6,6 +6,8 @@ import datetime
import tempfile import tempfile
import glob import glob
os.environ["PYTHONUNBUFFERED"] = "y"
sys.path.append(os.path.join(os.path.dirname(__file__), '..', "..")) sys.path.append(os.path.join(os.path.dirname(__file__), '..', ".."))
from zulip_tools import DEPLOYMENTS_DIR, FAIL, ENDC, make_deploy_path from zulip_tools import DEPLOYMENTS_DIR, FAIL, ENDC, make_deploy_path

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python2.7 -u #!/usr/bin/env python2.7
import os import os
import sys import sys
import subprocess import subprocess
@ -6,6 +6,8 @@ import logging
import shutil import shutil
import time import time
os.environ["PYTHONUNBUFFERED"] = "y"
sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..')) sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..'))
from zulip_tools import DEPLOYMENTS_DIR, LOCK_DIR, FAIL, WARNING, ENDC, \ from zulip_tools import DEPLOYMENTS_DIR, LOCK_DIR, FAIL, WARNING, ENDC, \
su_to_zulip su_to_zulip

View File

@ -1,9 +1,11 @@
#!/usr/bin/env python2.7 -u #!/usr/bin/env python2.7
import subprocess import subprocess
import os import os
import sys import sys
import logging import logging
os.environ["PYTHONUNBUFFERED"] = "y"
sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..')) sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..'))
from zulip_tools import FAIL, WARNING, ENDC, su_to_zulip from zulip_tools import FAIL, WARNING, ENDC, su_to_zulip

View File

@ -12,4 +12,5 @@ esac
cd "$(dirname "$0")"/.. cd "$(dirname "$0")"/..
./tools/generate-fixtures ./tools/generate-fixtures
# "-u" uses unbuffered IO, which is important when wrapping it in subprocess # "-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 "$@"

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python2.7 -u #!/usr/bin/env python2.7
import os import os
import sys import sys
import subprocess import subprocess
@ -7,6 +7,8 @@ import datetime
import shutil import shutil
import time import time
os.environ["PYTHONUNBUFFERED"] = "y"
sys.path.append(os.path.join(os.path.dirname(__file__), '..')) sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
from zulip_tools import DEPLOYMENTS_DIR, LOCK_DIR, FAIL, WARNING, ENDC, make_deploy_path from zulip_tools import DEPLOYMENTS_DIR, LOCK_DIR, FAIL, WARNING, ENDC, make_deploy_path