diff --git a/analytics/management/commands/analyze_user_activity.py b/analytics/management/commands/analyze_user_activity.py index 716bf9fdde..9bf5a0b510 100644 --- a/analytics/management/commands/analyze_user_activity.py +++ b/analytics/management/commands/analyze_user_activity.py @@ -42,7 +42,7 @@ It will correctly not count server-initiated reloads in the activity statistics. The duration flag can be used to control how many days to show usage duration for -Usage: python manage.py analyze_user_activity [--realm=zulip.com] [--date=2013-09-10] [--duration=1] +Usage: python2.7 manage.py analyze_user_activity [--realm=zulip.com] [--date=2013-09-10] [--duration=1] By default, if no date is selected 2013-09-10 is used. If no realm is provided, information is shown for all realms""" diff --git a/analytics/management/commands/client_activity.py b/analytics/management/commands/client_activity.py index 2aafb0a3f9..845db68475 100644 --- a/analytics/management/commands/client_activity.py +++ b/analytics/management/commands/client_activity.py @@ -13,9 +13,9 @@ class Command(BaseCommand): Usage examples: -python manage.py client_activity -python manage.py client_activity zulip.com -python manage.py client_activity jesstess@zulip.com""" +python2.7 manage.py client_activity +python2.7 manage.py client_activity zulip.com +python2.7 manage.py client_activity jesstess@zulip.com""" def add_arguments(self, parser): parser.add_argument('arg', metavar='', type=str, nargs='?', default=None, diff --git a/api/bin/zulip-send b/api/bin/zulip-send index 3cd31ad088..b314863294 100755 --- a/api/bin/zulip-send +++ b/api/bin/zulip-send @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2.7 # -*- coding: utf-8 -*- # zulip-send -- Sends a message to the specified recipients. diff --git a/api/examples/create-user b/api/examples/create-user index c492fdd0a5..6f2a3795ca 100755 --- a/api/examples/create-user +++ b/api/examples/create-user @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python2.7 # -*- coding: utf-8 -*- # Copyright © 2012-2014 Zulip, Inc. diff --git a/api/examples/edit-message b/api/examples/edit-message index af61fb7ce1..609f2912cb 100755 --- a/api/examples/edit-message +++ b/api/examples/edit-message @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2.7 # -*- coding: utf-8 -*- # Copyright © 2012 Zulip, Inc. diff --git a/api/examples/get-public-streams b/api/examples/get-public-streams index c71c354559..2137d130c5 100755 --- a/api/examples/get-public-streams +++ b/api/examples/get-public-streams @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2.7 # -*- coding: utf-8 -*- # Copyright © 2012 Zulip, Inc. diff --git a/api/examples/list-members b/api/examples/list-members index d7829ae72a..70c1c1b1af 100755 --- a/api/examples/list-members +++ b/api/examples/list-members @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2.7 # -*- coding: utf-8 -*- # Copyright © 2014 Zulip, Inc. diff --git a/api/examples/list-subscriptions b/api/examples/list-subscriptions index 67d26b9c74..6223dab727 100755 --- a/api/examples/list-subscriptions +++ b/api/examples/list-subscriptions @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2.7 # -*- coding: utf-8 -*- # Copyright © 2012 Zulip, Inc. diff --git a/api/examples/print-events b/api/examples/print-events index 06c1450884..a3d04576b9 100755 --- a/api/examples/print-events +++ b/api/examples/print-events @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2.7 # -*- coding: utf-8 -*- # Copyright © 2012 Zulip, Inc. diff --git a/api/examples/print-messages b/api/examples/print-messages index eda3503afa..f1a521e487 100755 --- a/api/examples/print-messages +++ b/api/examples/print-messages @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2.7 # -*- coding: utf-8 -*- # Copyright © 2012 Zulip, Inc. diff --git a/api/examples/print-next-message b/api/examples/print-next-message index 901a19a7d7..cf41e3283d 100755 --- a/api/examples/print-next-message +++ b/api/examples/print-next-message @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2.7 # -*- coding: utf-8 -*- # Copyright © 2012 Zulip, Inc. diff --git a/api/examples/send-message b/api/examples/send-message index 582ae6b330..f257e5784f 100755 --- a/api/examples/send-message +++ b/api/examples/send-message @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2.7 # -*- coding: utf-8 -*- # Copyright © 2012 Zulip, Inc. diff --git a/api/examples/subscribe b/api/examples/subscribe index 6e94d36444..548a02ed07 100755 --- a/api/examples/subscribe +++ b/api/examples/subscribe @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2.7 # -*- coding: utf-8 -*- # Copyright © 2012 Zulip, Inc. diff --git a/api/examples/unsubscribe b/api/examples/unsubscribe index 4e9d69a36b..3b72173582 100755 --- a/api/examples/unsubscribe +++ b/api/examples/unsubscribe @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2.7 # -*- coding: utf-8 -*- # Copyright © 2012 Zulip, Inc. diff --git a/api/integrations/asana/zulip_asana_config.py b/api/integrations/asana/zulip_asana_config.py index 6020f6df9d..c14db0b2d8 100644 --- a/api/integrations/asana/zulip_asana_config.py +++ b/api/integrations/asana/zulip_asana_config.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2.7 # -*- coding: utf-8 -*- # # Copyright © 2014 Zulip, Inc. diff --git a/api/integrations/asana/zulip_asana_mirror b/api/integrations/asana/zulip_asana_mirror index c0ee4d816b..1fbb0beef8 100755 --- a/api/integrations/asana/zulip_asana_mirror +++ b/api/integrations/asana/zulip_asana_mirror @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2.7 # -*- coding: utf-8 -*- # # Asana integration for Zulip diff --git a/api/integrations/basecamp/zulip_basecamp_config.py b/api/integrations/basecamp/zulip_basecamp_config.py index c343a69772..024ace0603 100644 --- a/api/integrations/basecamp/zulip_basecamp_config.py +++ b/api/integrations/basecamp/zulip_basecamp_config.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2.7 # -*- coding: utf-8 -*- # # Copyright © 2014 Zulip, Inc. diff --git a/api/integrations/basecamp/zulip_basecamp_mirror b/api/integrations/basecamp/zulip_basecamp_mirror index f56fccff9b..abacb3105a 100755 --- a/api/integrations/basecamp/zulip_basecamp_mirror +++ b/api/integrations/basecamp/zulip_basecamp_mirror @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2.7 # -*- coding: utf-8 -*- # # Zulip mirror of Basecamp activity diff --git a/api/integrations/codebase/zulip_codebase_config.py b/api/integrations/codebase/zulip_codebase_config.py index d13d80d056..fb37981322 100644 --- a/api/integrations/codebase/zulip_codebase_config.py +++ b/api/integrations/codebase/zulip_codebase_config.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2.7 # -*- coding: utf-8 -*- # # Copyright © 2014 Zulip, Inc. diff --git a/api/integrations/codebase/zulip_codebase_mirror b/api/integrations/codebase/zulip_codebase_mirror index 6f7d8fc282..c3e7863619 100755 --- a/api/integrations/codebase/zulip_codebase_mirror +++ b/api/integrations/codebase/zulip_codebase_mirror @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2.7 # -*- coding: utf-8 -*- # # Zulip mirror of Codebase HQ activity diff --git a/api/integrations/git/post-receive b/api/integrations/git/post-receive index df8b97fb97..eaeb1e5c42 100755 --- a/api/integrations/git/post-receive +++ b/api/integrations/git/post-receive @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2.7 # -*- coding: utf-8 -*- # # Zulip notification post-receive hook. diff --git a/api/integrations/git/zulip_git_config.py b/api/integrations/git/zulip_git_config.py index 9b3157a914..b0be000657 100644 --- a/api/integrations/git/zulip_git_config.py +++ b/api/integrations/git/zulip_git_config.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2.7 # -*- coding: utf-8 -*- # # Copyright © 2014 Zulip, Inc. diff --git a/api/integrations/hg/zulip-changegroup.py b/api/integrations/hg/zulip-changegroup.py index f1ec24d123..427702c52d 100755 --- a/api/integrations/hg/zulip-changegroup.py +++ b/api/integrations/hg/zulip-changegroup.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2.7 # -*- coding: utf-8 -*- # # Zulip hook for Mercurial changeset pushes. diff --git a/api/integrations/nagios/nagios-notify-zulip b/api/integrations/nagios/nagios-notify-zulip index 6145952fef..8f2dd28967 100755 --- a/api/integrations/nagios/nagios-notify-zulip +++ b/api/integrations/nagios/nagios-notify-zulip @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2.7 import optparse import zulip diff --git a/api/integrations/perforce/git_p4.py b/api/integrations/perforce/git_p4.py index 494b0ef487..ffe2fc9bb6 100644 --- a/api/integrations/perforce/git_p4.py +++ b/api/integrations/perforce/git_p4.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2.7 # # git-p4.py -- A tool for bidirectional operation between a Perforce depot and git. # diff --git a/api/integrations/perforce/zulip_change-commit.py b/api/integrations/perforce/zulip_change-commit.py index 35962673e0..f1cdee40f0 100755 --- a/api/integrations/perforce/zulip_change-commit.py +++ b/api/integrations/perforce/zulip_change-commit.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2.7 # -*- coding: utf-8 -*- # # Copyright © 2012-2014 Zulip, Inc. diff --git a/api/integrations/perforce/zulip_perforce_config.py b/api/integrations/perforce/zulip_perforce_config.py index 2928a0cd36..de36c30683 100644 --- a/api/integrations/perforce/zulip_perforce_config.py +++ b/api/integrations/perforce/zulip_perforce_config.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2.7 # -*- coding: utf-8 -*- # # Copyright © 2014 Zulip, Inc. diff --git a/api/integrations/rss/rss-bot b/api/integrations/rss/rss-bot index 0511e2b626..9aa7925339 100755 --- a/api/integrations/rss/rss-bot +++ b/api/integrations/rss/rss-bot @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2.7 # -*- coding: utf-8 -*- # # RSS integration for Zulip diff --git a/api/integrations/svn/post-commit b/api/integrations/svn/post-commit index dabfb125d7..7f67e13f10 100755 --- a/api/integrations/svn/post-commit +++ b/api/integrations/svn/post-commit @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2.7 # -*- coding: utf-8 -*- # # Zulip notification post-commit hook. diff --git a/api/integrations/svn/zulip_svn_config.py b/api/integrations/svn/zulip_svn_config.py index 70a84c9387..a69fc04083 100644 --- a/api/integrations/svn/zulip_svn_config.py +++ b/api/integrations/svn/zulip_svn_config.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2.7 # -*- coding: utf-8 -*- # # Copyright © 2014 Zulip, Inc. diff --git a/api/integrations/twitter/twitter-bot b/api/integrations/twitter/twitter-bot index 30c890fd5e..ec3ad033f0 100755 --- a/api/integrations/twitter/twitter-bot +++ b/api/integrations/twitter/twitter-bot @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2.7 # -*- coding: utf-8 -*- # # Twitter integration for Zulip diff --git a/api/integrations/twitter/twitter-search-bot b/api/integrations/twitter/twitter-search-bot index 64e42d8edb..64938f5575 100755 --- a/api/integrations/twitter/twitter-search-bot +++ b/api/integrations/twitter/twitter-search-bot @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2.7 # -*- coding: utf-8 -*- # # Twitter search integration for Zulip diff --git a/api/setup.py b/api/setup.py index e12955db12..129303d840 100644 --- a/api/setup.py +++ b/api/setup.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2.7 # -*- coding: utf-8 -*- import os diff --git a/assets/favicon/generate b/assets/favicon/generate index eecf036e0c..790e418114 100755 --- a/assets/favicon/generate +++ b/assets/favicon/generate @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2.7 import xml.etree.ElementTree as ET import subprocess diff --git a/bin/get-django-setting b/bin/get-django-setting index 3e5c41f37e..675733219a 100755 --- a/bin/get-django-setting +++ b/bin/get-django-setting @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2.7 from __future__ import absolute_import import os diff --git a/bin/log-management-command b/bin/log-management-command index e4c7dd061c..ecae13c3c8 100755 --- a/bin/log-management-command +++ b/bin/log-management-command @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2.7 import sys import logging import os diff --git a/bots/check-mirroring b/bots/check-mirroring index 50a4718ec1..bfc55882dc 100755 --- a/bots/check-mirroring +++ b/bots/check-mirroring @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2.7 import sys import time import optparse diff --git a/bots/check-rabbitmq-consumers b/bots/check-rabbitmq-consumers index fd3661ba74..4f4c7ffa7a 100755 --- a/bots/check-rabbitmq-consumers +++ b/bots/check-rabbitmq-consumers @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2.7 import sys import time diff --git a/bots/check-rabbitmq-queue b/bots/check-rabbitmq-queue index 5c9af8daf8..ba359f329f 100755 --- a/bots/check-rabbitmq-queue +++ b/bots/check-rabbitmq-queue @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2.7 import sys import re diff --git a/bots/cron_file_helper.py b/bots/cron_file_helper.py index 7aa6460eee..b61609cd03 100644 --- a/bots/cron_file_helper.py +++ b/bots/cron_file_helper.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2.7 import time def nagios_from_file(results_file): diff --git a/bots/gcal-bot b/bots/gcal-bot index ff33d7b6c9..90b92aa852 100755 --- a/bots/gcal-bot +++ b/bots/gcal-bot @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2.7 import sys import time import datetime diff --git a/bots/irc-mirror.py b/bots/irc-mirror.py index b5102ad486..40af27aa49 100644 --- a/bots/irc-mirror.py +++ b/bots/irc-mirror.py @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python2.7 # # EXPERIMENTAL # IRC <=> Zulip mirroring bot @@ -92,11 +92,11 @@ class IRCBot(irc.bot.SingleServerIRCBot): return self.dcc_connect(address, port) -usage = """python irc-mirror.py --server=IRC_SERVER --channel= --nick-prefix= [optional args] +usage = """python2.7 irc-mirror.py --server=IRC_SERVER --channel= --nick-prefix= [optional args] Example: -python irc-mirror.py --irc-server=127.0.0.1 --channel='#test' --nick-prefix=username +python2.7 irc-mirror.py --irc-server=127.0.0.1 --channel='#test' --nick-prefix=username --site=https://zulip.example.com --user=irc-bot@example.com --api-key=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx diff --git a/bots/jabber_mirror.py b/bots/jabber_mirror.py index 7146d14045..3f609a3812 100755 --- a/bots/jabber_mirror.py +++ b/bots/jabber_mirror.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2.7 # Copyright (C) 2014 Zulip, Inc. # # Permission is hereby granted, free of charge, to any person diff --git a/bots/jabber_mirror_backend.py b/bots/jabber_mirror_backend.py index b86cbe79e2..c22f189c9e 100755 --- a/bots/jabber_mirror_backend.py +++ b/bots/jabber_mirror_backend.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python2.7 # # Copyright (C) 2013 Permabit, Inc. # Copyright (C) 2013--2014 Zulip, Inc. diff --git a/bots/log2zulip b/bots/log2zulip index 2c3bfacdca..d8750c8819 100755 --- a/bots/log2zulip +++ b/bots/log2zulip @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python2.7 import subprocess import os import sys diff --git a/bots/process_ccache b/bots/process_ccache index 091f946c80..89363b6653 100755 --- a/bots/process_ccache +++ b/bots/process_ccache @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python2.7 import sys import subprocess import base64 diff --git a/bots/sync-public-streams b/bots/sync-public-streams index a535e76d05..e890586390 100755 --- a/bots/sync-public-streams +++ b/bots/sync-public-streams @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2.7 import sys import os import logging diff --git a/bots/tddium-notify-humbug b/bots/tddium-notify-humbug index 6ab221cdfa..2a97225781 100755 --- a/bots/tddium-notify-humbug +++ b/bots/tddium-notify-humbug @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2.7 # Copyright (C) 2012 Zulip, Inc. # # Permission is hereby granted, free of charge, to any person diff --git a/bots/zephyr_mirror.py b/bots/zephyr_mirror.py index 356725ee6e..26b56b63d8 100755 --- a/bots/zephyr_mirror.py +++ b/bots/zephyr_mirror.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2.7 # Copyright (C) 2012 Zulip, Inc. # # Permission is hereby granted, free of charge, to any person diff --git a/bots/zephyr_mirror_backend.py b/bots/zephyr_mirror_backend.py index 77148d313c..39e33bee43 100755 --- a/bots/zephyr_mirror_backend.py +++ b/bots/zephyr_mirror_backend.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2.7 # Copyright (C) 2012 Zulip, Inc. # # Permission is hereby granted, free of charge, to any person diff --git a/docs/code-style.rst b/docs/code-style.rst index 7b3d75897b..ba2f5a6c6c 100644 --- a/docs/code-style.rst +++ b/docs/code-style.rst @@ -352,8 +352,8 @@ styles (separate lines for each selector):: Python ------ -- Scripts should start with ``#!/usr/bin/env python`` and not - ``#!/usr/bin/python``. See commit ``437d4aee`` for an explanation of +- Scripts should start with ``#!/usr/bin/env python2.7`` and not + ``#!/usr/bin/env python2.7``. See commit ``437d4aee`` for an explanation of why. Don't put such a line on a Python file unless it's meaningful to run it as a script. (Some libraries can also be run as scripts, e.g. to run a test suite.) diff --git a/docs/html_unescape.py b/docs/html_unescape.py index e52ff09ef6..64da6444d5 100755 --- a/docs/html_unescape.py +++ b/docs/html_unescape.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python3 +#!/usr/bin/env python2.7 # Remove HTML entity escaping left over from MediaWiki->rST conversion. diff --git a/manage.py b/manage.py index a81674a0e1..1f6fe59b00 100755 --- a/manage.py +++ b/manage.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2.7 import os import sys import logging diff --git a/puppet/zulip/files/nagios_plugins/check_queue_worker_errors b/puppet/zulip/files/nagios_plugins/check_queue_worker_errors index 3cb6f04aa3..4c2ffb4d7f 100755 --- a/puppet/zulip/files/nagios_plugins/check_queue_worker_errors +++ b/puppet/zulip/files/nagios_plugins/check_queue_worker_errors @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2.7 """ Nagios plugin to check that none of our queue workers have reported errors. diff --git a/puppet/zulip/files/postgresql/process_fts_updates b/puppet/zulip/files/postgresql/process_fts_updates index 545c978621..484f6db97c 100755 --- a/puppet/zulip/files/postgresql/process_fts_updates +++ b/puppet/zulip/files/postgresql/process_fts_updates @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2.7 import psycopg2 import psycopg2.extensions import select diff --git a/puppet/zulip/files/supervisor/conf.d/zulip.conf b/puppet/zulip/files/supervisor/conf.d/zulip.conf index 08f4a99dbb..827030d1ef 100644 --- a/puppet/zulip/files/supervisor/conf.d/zulip.conf +++ b/puppet/zulip/files/supervisor/conf.d/zulip.conf @@ -8,7 +8,7 @@ ; variables can be expanded using this syntax: "%(ENV_HOME)s". [fcgi-program:zulip-django] -command=python /home/zulip/deployments/current/manage.py runfcgi daemonize=False maxchildren=20 ; the program (relative uses PATH, can take args) +command=python2.7 /home/zulip/deployments/current/manage.py runfcgi daemonize=False maxchildren=20 ; the program (relative uses PATH, can take args) ;process_name=%(program_name)s ; process_name expr (default %(program_name)s) ;numprocs=1 ; number of processes copies to start (def 1) ;directory=/tmp ; directory to cwd to before exec (def no cwd) @@ -43,7 +43,7 @@ socket_owner=zulip:zulip socket_mode=0700 [program:zulip-tornado] -command=python /home/zulip/deployments/current/manage.py runtornado localhost:9993 +command=python2.7 /home/zulip/deployments/current/manage.py runtornado localhost:9993 priority=200 ; the relative start priority (default 999) autostart=true ; start at supervisord start (default: true) autorestart=true ; whether/when to restart (default: unexpected) @@ -57,7 +57,7 @@ stdout_logfile_backups=10 ; # of stdout logfile backups (default 10) directory=/home/zulip/deployments/current/ [program:zulip-events-user-activity] -command=python /home/zulip/deployments/current/manage.py process_queue user_activity +command=python2.7 /home/zulip/deployments/current/manage.py process_queue user_activity priority=300 ; the relative start priority (default 999) autostart=true ; start at supervisord start (default: true) autorestart=true ; whether/when to restart (default: unexpected) @@ -71,7 +71,7 @@ stdout_logfile_backups=10 ; # of stdout logfile backups (default 10) directory=/home/zulip/deployments/current/ [program:zulip-events-user-activity-interval] -command=python /home/zulip/deployments/current/manage.py process_queue user_activity_interval +command=python2.7 /home/zulip/deployments/current/manage.py process_queue user_activity_interval priority=300 ; the relative start priority (default 999) autostart=true ; start at supervisord start (default: true) autorestart=true ; whether/when to restart (default: unexpected) @@ -85,7 +85,7 @@ stdout_logfile_backups=10 ; # of stdout logfile backups (default 10) directory=/home/zulip/deployments/current/ [program:zulip-events-user-presence] -command=python /home/zulip/deployments/current/manage.py process_queue user_presence +command=python2.7 /home/zulip/deployments/current/manage.py process_queue user_presence priority=300 ; the relative start priority (default 999) autostart=true ; start at supervisord start (default: true) autorestart=true ; whether/when to restart (default: unexpected) @@ -99,7 +99,7 @@ stdout_logfile_backups=10 ; # of stdout logfile backups (default 10) directory=/home/zulip/deployments/current/ [program:zulip-events-signups] -command=python /home/zulip/deployments/current/manage.py process_queue signups +command=python2.7 /home/zulip/deployments/current/manage.py process_queue signups priority=400 ; the relative start priority (default 999) autostart=true ; start at supervisord start (default: true) autorestart=true ; whether/when to restart (default: unexpected) @@ -113,7 +113,7 @@ stdout_logfile_backups=10 ; # of stdout logfile backups (default 10) directory=/home/zulip/deployments/current/ [program:zulip-events-confirmation-emails] -command=python /home/zulip/deployments/current/manage.py process_queue invites +command=python2.7 /home/zulip/deployments/current/manage.py process_queue invites priority=500 ; the relative start priority (default 999) autostart=true ; start at supervisord start (default: true) autorestart=true ; whether/when to restart (default: unexpected) @@ -127,7 +127,7 @@ stdout_logfile_backups=10 ; # of stdout logfile backups (default 10) directory=/home/zulip/deployments/current/ [program:zulip-events-missedmessage_reminders] -command=python /home/zulip/deployments/current/manage.py process_queue missedmessage_emails +command=python2.7 /home/zulip/deployments/current/manage.py process_queue missedmessage_emails priority=600 ; the relative start priority (default 999) autostart=true ; start at supervisord start (default: true) autorestart=true ; whether/when to restart (default: unexpected) @@ -141,7 +141,7 @@ stdout_logfile_backups=10 ; # of stdout logfile backups (default 10) directory=/home/zulip/deployments/current/ [program:zulip-events-missedmessage_mobile_notifications] -command=python /home/zulip/deployments/current/manage.py process_queue missedmessage_mobile_notifications +command=python2.7 /home/zulip/deployments/current/manage.py process_queue missedmessage_mobile_notifications priority=600 ; the relative start priority (default 999) autostart=true ; start at supervisord start (default: true) autorestart=true ; whether/when to restart (default: unexpected) @@ -155,7 +155,7 @@ stdout_logfile_backups=10 ; # of stdout logfile backups (default 10) directory=/home/zulip/deployments/current/ [program:zulip-events-slowqueries] -command=python /home/zulip/deployments/current/manage.py process_queue slow_queries +command=python2.7 /home/zulip/deployments/current/manage.py process_queue slow_queries priority=600 ; the relative start priority (default 999) autostart=true ; start at supervisord start (default: true) autorestart=true ; whether/when to restart (default: unexpected) @@ -169,7 +169,7 @@ stdout_logfile_backups=10 ; # of stdout logfile backups (default 10) directory=/home/zulip/deployments/current/ [program:zulip-events-message_sender] -command=python /home/zulip/deployments/current/manage.py process_queue message_sender %(process_num)s +command=python2.7 /home/zulip/deployments/current/manage.py process_queue message_sender %(process_num)s process_name=%(program_name)s-%(process_num)s priority=350 ; the relative start priority (default 999) autostart=true ; start at supervisord start (default: true) @@ -185,7 +185,7 @@ directory=/home/zulip/deployments/current/ numprocs=5 [program:zulip-events-feedback_messages] -command=python /home/zulip/deployments/current/manage.py process_queue feedback_messages +command=python2.7 /home/zulip/deployments/current/manage.py process_queue feedback_messages priority=600 ; the relative start priority (default 999) autostart=true ; start at supervisord start (default: true) autorestart=true ; whether/when to restart (default: unexpected) @@ -199,7 +199,7 @@ stdout_logfile_backups=10 ; # of stdout logfile backups (default 10) directory=/home/zulip/deployments/current/ [program:zulip-events-error_reports] -command=python /home/zulip/deployments/current/manage.py process_queue error_reports +command=python2.7 /home/zulip/deployments/current/manage.py process_queue error_reports priority=600 ; the relative start priority (default 999) autostart=true ; start at supervisord start (default: true) autorestart=true ; whether/when to restart (default: unexpected) @@ -213,7 +213,7 @@ stdout_logfile_backups=10 ; # of stdout logfile backups (default 10) directory=/home/zulip/deployments/current/ [program:zulip-events-digest_emails] -command=python /home/zulip/deployments/current/manage.py process_queue digest_emails +command=python2.7 /home/zulip/deployments/current/manage.py process_queue digest_emails priority=600 ; the relative start priority (default 999) autostart=true ; start at supervisord start (default: true) autorestart=true ; whether/when to restart (default: unexpected) @@ -227,7 +227,7 @@ stdout_logfile_backups=10 ; # of stdout logfile backups (default 10) directory=/home/zulip/deployments/current/ [program:zulip-events-email_mirror] -command=python /home/zulip/deployments/current/manage.py process_queue email_mirror +command=python2.7 /home/zulip/deployments/current/manage.py process_queue email_mirror priority=600 ; the relative start priority (default 999) autostart=true ; start at supervisord start (default: true) autorestart=true ; whether/when to restart (default: unexpected) @@ -241,7 +241,7 @@ stdout_logfile_backups=10 ; # of stdout logfile backups (default 10) directory=/home/zulip/deployments/current/ [program:zulip-deliver-enqueued-emails] -command=python /home/zulip/deployments/current/manage.py deliver_email +command=python2.7 /home/zulip/deployments/current/manage.py deliver_email priority=600 ; the relative start priority (default 999) autostart=true ; start at supervisord start (default: true) autorestart=true ; whether/when to restart (default: unexpected) diff --git a/puppet/zulip_internal/files/apache/sites/graphite b/puppet/zulip_internal/files/apache/sites/graphite index 61eb1ce3a2..314042c45a 100644 --- a/puppet/zulip_internal/files/apache/sites/graphite +++ b/puppet/zulip_internal/files/apache/sites/graphite @@ -32,7 +32,7 @@ Listen 444 SetHandler None - Alias /media/ "/usr/lib/pymodules/python2.7/django/contrib/admin/media/" + Alias /media/ "/usr/lib/pymodules/python2/django/contrib/admin/media/" SetHandler None diff --git a/puppet/zulip_internal/files/cron.d/active-user-stats b/puppet/zulip_internal/files/cron.d/active-user-stats index f403c64f49..946b93f8de 100644 --- a/puppet/zulip_internal/files/cron.d/active-user-stats +++ b/puppet/zulip_internal/files/cron.d/active-user-stats @@ -1,3 +1,3 @@ MAILTO=root -*/10 * * * * zulip cd /home/zulip/deployments/current && python manage.py active_user_stats +*/10 * * * * zulip cd /home/zulip/deployments/current && python2.7 manage.py active_user_stats diff --git a/puppet/zulip_internal/files/cron.d/check-apns-tokens b/puppet/zulip_internal/files/cron.d/check-apns-tokens index c6875d5baf..fffbbadfd7 100644 --- a/puppet/zulip_internal/files/cron.d/check-apns-tokens +++ b/puppet/zulip_internal/files/cron.d/check-apns-tokens @@ -1,4 +1,4 @@ MAILTO=root # Remove any stale apple device tokens from our list -0 3 * * * zulip cd /home/zulip/deployments/current && python manage.py check_apns_tokens +0 3 * * * zulip cd /home/zulip/deployments/current && python2.7 manage.py check_apns_tokens diff --git a/puppet/zulip_internal/files/cron.d/clearsessions b/puppet/zulip_internal/files/cron.d/clearsessions index e46dc75f00..df6292ea3d 100644 --- a/puppet/zulip_internal/files/cron.d/clearsessions +++ b/puppet/zulip_internal/files/cron.d/clearsessions @@ -1,4 +1,4 @@ MAILTO=root # Clear all expired Django sessions at 10:22 PM every day. -22 22 * * * zulip cd /home/zulip/deployments/current && python manage.py clearsessions +22 22 * * * zulip cd /home/zulip/deployments/current && python2.7 manage.py clearsessions diff --git a/puppet/zulip_internal/files/cron.d/send-digest-emails b/puppet/zulip_internal/files/cron.d/send-digest-emails index 4e31edc800..ed86294324 100644 --- a/puppet/zulip_internal/files/cron.d/send-digest-emails +++ b/puppet/zulip_internal/files/cron.d/send-digest-emails @@ -1,4 +1,4 @@ MAILTO=root # Send digest emails once a day. Time is in UTC. -0 18 * * * zulip cd /home/zulip/deployments/current && python manage.py enqueue_digest_emails +0 18 * * * zulip cd /home/zulip/deployments/current && python2.7 manage.py enqueue_digest_emails diff --git a/puppet/zulip_internal/files/nagios_plugins/check_fts_update_log b/puppet/zulip_internal/files/nagios_plugins/check_fts_update_log index 98ff4fe92a..98bb19fba0 100755 --- a/puppet/zulip_internal/files/nagios_plugins/check_fts_update_log +++ b/puppet/zulip_internal/files/nagios_plugins/check_fts_update_log @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python2.7 """ Nagios plugin to check the length of the FTS update log. diff --git a/puppet/zulip_internal/files/nagios_plugins/check_personal_zephyr_mirrors b/puppet/zulip_internal/files/nagios_plugins/check_personal_zephyr_mirrors index 10a25d003e..cf71099b59 100755 --- a/puppet/zulip_internal/files/nagios_plugins/check_personal_zephyr_mirrors +++ b/puppet/zulip_internal/files/nagios_plugins/check_personal_zephyr_mirrors @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2.7 """ Nagios plugin to check that Zephyr personals mirrors are forwarding. diff --git a/puppet/zulip_internal/files/nagios_plugins/check_pg_replication_lag b/puppet/zulip_internal/files/nagios_plugins/check_pg_replication_lag index 19749e3143..1dacdce814 100755 --- a/puppet/zulip_internal/files/nagios_plugins/check_pg_replication_lag +++ b/puppet/zulip_internal/files/nagios_plugins/check_pg_replication_lag @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python2.7 """ Nagios plugin to check the difference between the primary and diff --git a/puppet/zulip_internal/files/nagios_plugins/check_postgres_backup b/puppet/zulip_internal/files/nagios_plugins/check_postgres_backup index 655b83155d..e653e60e90 100755 --- a/puppet/zulip_internal/files/nagios_plugins/check_postgres_backup +++ b/puppet/zulip_internal/files/nagios_plugins/check_postgres_backup @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python2.7 import dateutil.parser import pytz diff --git a/puppet/zulip_internal/files/nagios_plugins/check_rabbitmq_consumers b/puppet/zulip_internal/files/nagios_plugins/check_rabbitmq_consumers index 711126ca29..f698fec367 100755 --- a/puppet/zulip_internal/files/nagios_plugins/check_rabbitmq_consumers +++ b/puppet/zulip_internal/files/nagios_plugins/check_rabbitmq_consumers @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2.7 """ Nagios plugin to check that the rabbitmq has the correct number of consumers diff --git a/puppet/zulip_internal/files/nagios_plugins/check_rabbitmq_queues b/puppet/zulip_internal/files/nagios_plugins/check_rabbitmq_queues index 5ea47e3b16..5fc052015e 100755 --- a/puppet/zulip_internal/files/nagios_plugins/check_rabbitmq_queues +++ b/puppet/zulip_internal/files/nagios_plugins/check_rabbitmq_queues @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2.7 """ Nagios plugin to check that the rabbitmq queues are not overflowing as a result diff --git a/puppet/zulip_internal/files/nagios_plugins/check_send_receive_time b/puppet/zulip_internal/files/nagios_plugins/check_send_receive_time index 8e794efaad..5bbc8fa6cc 100755 --- a/puppet/zulip_internal/files/nagios_plugins/check_send_receive_time +++ b/puppet/zulip_internal/files/nagios_plugins/check_send_receive_time @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2.7 """ Script to provide information about send-receive times. diff --git a/puppet/zulip_internal/files/nagios_plugins/check_user_zephyr_mirror_liveness b/puppet/zulip_internal/files/nagios_plugins/check_user_zephyr_mirror_liveness index c335a097c9..df649c5e9e 100755 --- a/puppet/zulip_internal/files/nagios_plugins/check_user_zephyr_mirror_liveness +++ b/puppet/zulip_internal/files/nagios_plugins/check_user_zephyr_mirror_liveness @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2.7 """ Nagios plugin to check that our MIT users' Zephyr mirrors are running. diff --git a/puppet/zulip_internal/files/nagios_plugins/check_zephyr_mirror b/puppet/zulip_internal/files/nagios_plugins/check_zephyr_mirror index 04ae24be3d..6a8f45016d 100755 --- a/puppet/zulip_internal/files/nagios_plugins/check_zephyr_mirror +++ b/puppet/zulip_internal/files/nagios_plugins/check_zephyr_mirror @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2.7 """ Nagios plugin to check that Zephyr mirror forwarding is running. diff --git a/puppet/zulip_internal/files/postgresql/pg_backup_and_purge.py b/puppet/zulip_internal/files/postgresql/pg_backup_and_purge.py index 9e0541ec17..fb6dc11539 100644 --- a/puppet/zulip_internal/files/postgresql/pg_backup_and_purge.py +++ b/puppet/zulip_internal/files/postgresql/pg_backup_and_purge.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python2.7 import subprocess import sys diff --git a/puppet/zulip_internal/files/supervisor/conf.d/stats.conf b/puppet/zulip_internal/files/supervisor/conf.d/stats.conf index 6f041bfcbd..02fe67110f 100644 --- a/puppet/zulip_internal/files/supervisor/conf.d/stats.conf +++ b/puppet/zulip_internal/files/supervisor/conf.d/stats.conf @@ -3,7 +3,7 @@ [program:zulip-carbon-cache] -command=python /opt/graphite/bin/carbon-cache.py --debug start +command=python2.7 /opt/graphite/bin/carbon-cache.py --debug start priority=200 ; the relative start priority (default 999) autostart=true ; start at supervisord start (default: true) autorestart=true ; whether/when to restart (default: unexpected) @@ -15,7 +15,7 @@ stdout_logfile=/var/log/zulip/carbon-cache.log ; stdout log path, NONE f directory=/home/zulip/ [program:zulip-carbon-aggregator] -command=python /opt/graphite/bin/carbon-aggregator.py --debug start +command=python2.7 /opt/graphite/bin/carbon-aggregator.py --debug start priority=200 ; the relative start priority (default 999) autostart=true ; start at supervisord start (default: true) autorestart=true ; whether/when to restart (default: unexpected) diff --git a/puppet/zulip_internal/files/trac/cgi-bin/trac.cgi b/puppet/zulip_internal/files/trac/cgi-bin/trac.cgi index d3f8b019a2..e3df4e0d95 100644 --- a/puppet/zulip_internal/files/trac/cgi-bin/trac.cgi +++ b/puppet/zulip_internal/files/trac/cgi-bin/trac.cgi @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python2.7 # -*- coding: utf-8 -*- # # Copyright (C) 2003-2009 Edgewall Software diff --git a/puppet/zulip_internal/files/trac/cgi-bin/trac.fcgi b/puppet/zulip_internal/files/trac/cgi-bin/trac.fcgi index bc05d72923..627f5cdf3a 100644 --- a/puppet/zulip_internal/files/trac/cgi-bin/trac.fcgi +++ b/puppet/zulip_internal/files/trac/cgi-bin/trac.fcgi @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python2.7 # -*- coding: utf-8 -*- # # Copyright (C) 2003-2009 Edgewall Software diff --git a/puppet/zulip_internal/files/trac/cgi-bin/trac.wsgi b/puppet/zulip_internal/files/trac/cgi-bin/trac.wsgi index 8cad97314e..408f6e0262 100644 --- a/puppet/zulip_internal/files/trac/cgi-bin/trac.wsgi +++ b/puppet/zulip_internal/files/trac/cgi-bin/trac.wsgi @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python2.7 # -*- coding: utf-8 -*- # # Copyright (C)2008-2009 Edgewall Software diff --git a/puppet/zulip_internal/files/zulip-ec2-configure-interfaces b/puppet/zulip_internal/files/zulip-ec2-configure-interfaces index 18e0e8fc8e..497bc4e2f1 100755 --- a/puppet/zulip_internal/files/zulip-ec2-configure-interfaces +++ b/puppet/zulip_internal/files/zulip-ec2-configure-interfaces @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python2.7 # -*- coding: utf-8 -*- # # Copyright © 2013 Zulip, Inc. diff --git a/scripts/lib/unpack-zulip b/scripts/lib/unpack-zulip index 31365c1316..6ce0d88f34 100755 --- a/scripts/lib/unpack-zulip +++ b/scripts/lib/unpack-zulip @@ -1,4 +1,4 @@ -#!/usr/bin/python -u +#!/usr/bin/env python2.7 -u import os import sys import subprocess diff --git a/scripts/lib/upgrade-zulip b/scripts/lib/upgrade-zulip index 4b6ae26122..674171af89 100755 --- a/scripts/lib/upgrade-zulip +++ b/scripts/lib/upgrade-zulip @@ -1,4 +1,4 @@ -#!/usr/bin/python -u +#!/usr/bin/env python2.7 -u import os import sys import subprocess diff --git a/scripts/lib/upgrade-zulip-stage-2 b/scripts/lib/upgrade-zulip-stage-2 index 4061ba9900..07854e3f5a 100755 --- a/scripts/lib/upgrade-zulip-stage-2 +++ b/scripts/lib/upgrade-zulip-stage-2 @@ -1,4 +1,4 @@ -#!/usr/bin/python -u +#!/usr/bin/env python2.7 -u import subprocess import os import sys diff --git a/scripts/purge-old-deployments b/scripts/purge-old-deployments index 2e2413b72f..305d80673c 100755 --- a/scripts/purge-old-deployments +++ b/scripts/purge-old-deployments @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python2.7 import sys import os import logging diff --git a/scripts/restart-server b/scripts/restart-server index 589cbb0274..7dd2f89fd7 100755 --- a/scripts/restart-server +++ b/scripts/restart-server @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2.7 import os import sys import pwd @@ -20,10 +20,10 @@ if pwd.getpwuid(os.getuid())[0] != "zulip": sys.exit(1) # Send a statsd event on restarting the server -subprocess.check_call(["python", "./manage.py", "send_stats", "incr", "events.server_restart", str(int(time.time()))]) +subprocess.check_call(["python2.7", "./manage.py", "send_stats", "incr", "events.server_restart", str(int(time.time()))]) logging.info("Filling memcached caches") -subprocess.check_call(["python", "./manage.py", "fill_memcached_caches"]) +subprocess.check_call(["python2.7", "./manage.py", "fill_memcached_caches"]) # Restart the FastCGI and related processes via supervisorctl. logging.info("Stopping workers") diff --git a/scripts/setup/generate_secrets.py b/scripts/setup/generate_secrets.py index 8e2d3e31ae..12ff9b1d4b 100755 --- a/scripts/setup/generate_secrets.py +++ b/scripts/setup/generate_secrets.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2.7 # This tools generates local_settings_generated.py using the template import sys, os, os.path diff --git a/scripts/setup/initialize-database b/scripts/setup/initialize-database index 04451538a1..d33d62bd11 100755 --- a/scripts/setup/initialize-database +++ b/scripts/setup/initialize-database @@ -3,12 +3,12 @@ # Change to root directory of the checkout that we're running from cd "$(dirname "$0")/../.." -python manage.py checkconfig +python2.7 manage.py checkconfig -python manage.py migrate --noinput -python manage.py createcachetable third_party_api_results +python2.7 manage.py migrate --noinput +python2.7 manage.py createcachetable third_party_api_results -if ! python manage.py initialize_voyager_db; then +if ! python2.7 manage.py initialize_voyager_db; then set +x echo echo -e "\033[32mPopulating default database failed." diff --git a/scripts/zulip-puppet-apply b/scripts/zulip-puppet-apply index c948d384fa..a9c3240341 100755 --- a/scripts/zulip-puppet-apply +++ b/scripts/zulip-puppet-apply @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python2.7 import sys import subprocess diff --git a/templates/zerver/api.html b/templates/zerver/api.html index ae35caa3b4..9a3807d403 100644 --- a/templates/zerver/api.html +++ b/templates/zerver/api.html @@ -65,7 +65,7 @@ to pull out the resulting HTML :)
-
#!/usr/bin/env python
+
#!/usr/bin/env python2.7
 
 import zulip
 import sys
diff --git a/tools/check-templates b/tools/check-templates
index 417aeaf7fb..e24953949f 100755
--- a/tools/check-templates
+++ b/tools/check-templates
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python2.7
 import os
 import sys
 import subprocess
diff --git a/tools/compile-handlebars-templates b/tools/compile-handlebars-templates
index b92ccfefd8..544bf729fc 100755
--- a/tools/compile-handlebars-templates
+++ b/tools/compile-handlebars-templates
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python2.7
 from __future__ import absolute_import
 
 import os
diff --git a/tools/deprecated/finbot/money.py b/tools/deprecated/finbot/money.py
index cdfc6291ff..36755984a6 100755
--- a/tools/deprecated/finbot/money.py
+++ b/tools/deprecated/finbot/money.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/env python2.7
 import datetime
 import monthdelta
 
diff --git a/tools/deprecated/generate-activity-metrics.py b/tools/deprecated/generate-activity-metrics.py
index 6a3f58bff8..d9b9d02dc0 100755
--- a/tools/deprecated/generate-activity-metrics.py
+++ b/tools/deprecated/generate-activity-metrics.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python2.7
 #
 # Generates % delta activity metrics from graphite/statsd data
 #
diff --git a/tools/deprecated/iframe-bot/show-last-messages b/tools/deprecated/iframe-bot/show-last-messages
index 84a3a788f6..55e0e62935 100755
--- a/tools/deprecated/iframe-bot/show-last-messages
+++ b/tools/deprecated/iframe-bot/show-last-messages
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python2.7
 # -*- coding: utf-8 -*-
 
 # Copyright © 2013 Zulip, Inc.
diff --git a/tools/deprecated/inject-messages/inject-messages b/tools/deprecated/inject-messages/inject-messages
index 010b052728..05c4c270ad 100755
--- a/tools/deprecated/inject-messages/inject-messages
+++ b/tools/deprecated/inject-messages/inject-messages
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python2.7
 #
 # This is tool for injecting messages during a usability study.  It's
 # likely useless for other applications.
diff --git a/tools/deprecated/review b/tools/deprecated/review
index 35231562a2..0b87077828 100755
--- a/tools/deprecated/review
+++ b/tools/deprecated/review
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python2.7
 # encoding: utf-8
 #
 # Copyright (C) 2010 Ksplice, Inc.
diff --git a/tools/emoji_dump/emoji_dump.py b/tools/emoji_dump/emoji_dump.py
index 6fea852fc4..9d5d58ce3a 100755
--- a/tools/emoji_dump/emoji_dump.py
+++ b/tools/emoji_dump/emoji_dump.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python2.7
 import os
 import shutil
 import subprocess
diff --git a/tools/get-handlebar-vars b/tools/get-handlebar-vars
index a409b40b8b..74490afe15 100755
--- a/tools/get-handlebar-vars
+++ b/tools/get-handlebar-vars
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python2.7
 import sys
 import re
 import json
diff --git a/tools/lint-all b/tools/lint-all
index 09b403ae6a..a8dc54cb6e 100755
--- a/tools/lint-all
+++ b/tools/lint-all
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python2.7
 import os
 import re
 import sys
diff --git a/tools/minify-js b/tools/minify-js
index d3f56d0ff6..6e8d4c094d 100755
--- a/tools/minify-js
+++ b/tools/minify-js
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python2.7
 
 # Minifies JavaScripts, creating source maps
 
diff --git a/tools/post-receive b/tools/post-receive
index a7b85e3d20..40117f2455 100755
--- a/tools/post-receive
+++ b/tools/post-receive
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python2.7
 #
 # Zulip's post-receive hook.  There is a symlink
 #   from /home/git/repositories/eng/zulip.git/hooks/post-receive
diff --git a/tools/print-all/print-all b/tools/print-all/print-all
index 9ed65de923..d5c2496bb3 100755
--- a/tools/print-all/print-all
+++ b/tools/print-all/print-all
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python2.7
 import sh
 import os
 import re
diff --git a/tools/python-proxy b/tools/python-proxy
index ddfb258c14..90ccf9271f 100755
--- a/tools/python-proxy
+++ b/tools/python-proxy
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python2.7
 # -*- coding: cp1252 -*-
 # 
 #
diff --git a/tools/run-dev-queue-processors b/tools/run-dev-queue-processors
index db01ce5798..4172ff3d33 100755
--- a/tools/run-dev-queue-processors
+++ b/tools/run-dev-queue-processors
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python2.7
 
 # This script is only meant to be run from run-dev.py, which sets up the
 # environment correctly and passes the correct arguments for manage.py.  It is a
diff --git a/tools/run-dev.py b/tools/run-dev.py
index 4a1c46d51f..5dce56d0ac 100755
--- a/tools/run-dev.py
+++ b/tools/run-dev.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python2.7
 import optparse
 import subprocess
 import signal
diff --git a/tools/send_github_payloads.py b/tools/send_github_payloads.py
index de8a194412..335acced2c 100755
--- a/tools/send_github_payloads.py
+++ b/tools/send_github_payloads.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/env python2.7
 import sys
 import os
 import simplejson
diff --git a/tools/show-profile-results.py b/tools/show-profile-results.py
index 9fac0ae404..d8504ede8d 100755
--- a/tools/show-profile-results.py
+++ b/tools/show-profile-results.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python2.7
 import sys
 import pstats
 
diff --git a/tools/test-backend b/tools/test-backend
index 017b024ef2..bbb324ccb9 100755
--- a/tools/test-backend
+++ b/tools/test-backend
@@ -12,4 +12,4 @@ esac
 cd "$(dirname "$0")"/..
 ./tools/generate-fixtures
 # "-u" uses unbuffered IO, which is important when wrapping it in subprocess
-/usr/bin/env python -u ./manage.py test "$target" --settings=zproject.test_settings "$@"
+/usr/bin/env python2.7 -u ./manage.py test "$target" --settings=zproject.test_settings "$@"
diff --git a/tools/test_user_agent_parsing.py b/tools/test_user_agent_parsing.py
index 01bddb6c68..5226ab256c 100755
--- a/tools/test_user_agent_parsing.py
+++ b/tools/test_user_agent_parsing.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/env python2.7
 import re
 from collections import defaultdict
 import os
diff --git a/tools/update-deployment b/tools/update-deployment
index b29f3611f1..d5c7e941a0 100755
--- a/tools/update-deployment
+++ b/tools/update-deployment
@@ -1,4 +1,4 @@
-#!/usr/bin/python -u
+#!/usr/bin/env python2.7 -u
 import os
 import sys
 import subprocess
diff --git a/tools/update-prod-static b/tools/update-prod-static
index f4f31ebae1..ec4a58ccff 100755
--- a/tools/update-prod-static
+++ b/tools/update-prod-static
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python2.7
 
 # Updates static files for production.
 
diff --git a/tools/zulip-export/zulip-export b/tools/zulip-export/zulip-export
index afa377920d..d08cb24ffd 100755
--- a/tools/zulip-export/zulip-export
+++ b/tools/zulip-export/zulip-export
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python2.7
 # -*- coding: utf-8 -*-
 
 # Copyright © 2014 Dropbox, Inc.
diff --git a/zerver/lib/bugdown/fenced_code.py b/zerver/lib/bugdown/fenced_code.py
index 9411e53009..f5a682d41e 100644
--- a/zerver/lib/bugdown/fenced_code.py
+++ b/zerver/lib/bugdown/fenced_code.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python2.7
 
 """
 Fenced Code Extension for Python Markdown
diff --git a/zerver/lib/ccache.py b/zerver/lib/ccache.py
index 9d9f193f5c..f78af05a10 100644
--- a/zerver/lib/ccache.py
+++ b/zerver/lib/ccache.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/env python2.7
 # This file is adapted from samples/shellinabox/ssh-krb-wrapper in
 # https://github.com/davidben/webathena, which has the following
 # license:
diff --git a/zerver/management/commands/create_realm.py b/zerver/management/commands/create_realm.py
index 0e743bb2ea..9920eb3f05 100644
--- a/zerver/management/commands/create_realm.py
+++ b/zerver/management/commands/create_realm.py
@@ -15,7 +15,7 @@ import sys
 class Command(BaseCommand):
     help = """Create a realm for the specified domain.
 
-Usage: python manage.py create_realm --domain=foo.com --name='Foo, Inc.'"""
+Usage: python2.7 manage.py create_realm --domain=foo.com --name='Foo, Inc.'"""
 
     option_list = BaseCommand.option_list + (
         make_option('-o', '--open-realm',
@@ -56,12 +56,12 @@ Usage: python manage.py create_realm --domain=foo.com --name='Foo, Inc.'"""
     def handle(self, *args, **options):
         if options["domain"] is None or options["name"] is None:
             print >>sys.stderr, "\033[1;31mPlease provide both a domain and name.\033[0m\n"
-            self.print_help("python manage.py", "create_realm")
+            self.print_help("python2.7 manage.py", "create_realm")
             exit(1)
 
         if options["open_realm"] and options["deployment_id"] is not None:
             print >>sys.stderr, "\033[1;31mExternal deployments cannot be open realms.\033[0m\n"
-            self.print_help("python manage.py", "create_realm")
+            self.print_help("python2.7 manage.py", "create_realm")
             exit(1)
         if options["deployment_id"] is not None and settings.VOYAGER:
             print >>sys.stderr, "\033[1;31mExternal deployments are not supported on voyager deployments.\033[0m\n"
diff --git a/zerver/management/commands/deliver_email.py b/zerver/management/commands/deliver_email.py
index 6ab2bcb80c..d73da07e55 100755
--- a/zerver/management/commands/deliver_email.py
+++ b/zerver/management/commands/deliver_email.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/env python2.7
 
 """
 Deliver email messages that have been queued by various things
diff --git a/zerver/management/commands/email-mirror.py b/zerver/management/commands/email-mirror.py
index 39affe1919..0e5365abc5 100755
--- a/zerver/management/commands/email-mirror.py
+++ b/zerver/management/commands/email-mirror.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/env python2.7
 
 """
 Forward messages sent to the configured email gateway to Zulip.
@@ -29,7 +29,7 @@ This script can be used via two mechanisms:
      environment variable.
 
      In Postfix, you can express that via an /etc/aliases entry like this:
-         |/usr/bin/python /home/zulip/deployments/current/manage.py email-mirror
+         |/usr/bin/env python2.7 /home/zulip/deployments/current/manage.py email-mirror
 """
 
 
diff --git a/zerver/management/commands/import_dump.py b/zerver/management/commands/import_dump.py
index 87cf1ade44..6961561c38 100644
--- a/zerver/management/commands/import_dump.py
+++ b/zerver/management/commands/import_dump.py
@@ -22,7 +22,7 @@ class Command(BaseCommand):
 This command should be used only on a newly created, empty Zulip instance to
 import a database dump from one or more JSON files.
 
-Usage: python manage.py import_dump [--destroy-rebuild-database] [--chunk-size=%s]  [...]""" % DEFAULT_CHUNK_SIZE
+Usage: python2.7 manage.py import_dump [--destroy-rebuild-database] [--chunk-size=%s]  [...]""" % DEFAULT_CHUNK_SIZE
 
     option_list = BaseCommand.option_list + (
         make_option('--destroy-rebuild-database',
diff --git a/zerver/management/commands/print_email_delivery_backlog.py b/zerver/management/commands/print_email_delivery_backlog.py
index 4e8cbf6c2a..7f64d830d8 100755
--- a/zerver/management/commands/print_email_delivery_backlog.py
+++ b/zerver/management/commands/print_email_delivery_backlog.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/env python2.7
 
 """
 Shows backlog count of ScheduledJobs of type Email
@@ -20,7 +20,7 @@ class Command(BaseCommand):
 This is run as part of the nagios health check for the deliver_email command.
 Please note that this is only relevant to the SMTP-based email delivery (no Mandrill).
 
-Usage: python manage.py print_email_delivery_backlog
+Usage: python2.7 manage.py print_email_delivery_backlog
 """
 
     def handle(self, *args, **options):
diff --git a/zerver/management/commands/realm_emoji.py b/zerver/management/commands/realm_emoji.py
index b50f82348b..0619d468d2 100644
--- a/zerver/management/commands/realm_emoji.py
+++ b/zerver/management/commands/realm_emoji.py
@@ -8,9 +8,9 @@ import sys
 class Command(BaseCommand):
     help = """Manage emoji for the specified realm
 
-Example: python manage.py realm_emoji --realm=zulip.com --op=add robotheart  https://humbug-user-avatars.s3.amazonaws.com/95ffa70fe0e7aea3c052ba91b38a28d8779f5705
-Example: python manage.py realm_emoji --realm=zulip.com --op=remove robotheart
-Example: python manage.py realm_emoji --realm=zulip.com --op=show
+Example: python2.7 manage.py realm_emoji --realm=zulip.com --op=add robotheart  https://humbug-user-avatars.s3.amazonaws.com/95ffa70fe0e7aea3c052ba91b38a28d8779f5705
+Example: python2.7 manage.py realm_emoji --realm=zulip.com --op=remove robotheart
+Example: python2.7 manage.py realm_emoji --realm=zulip.com --op=show
 """
 
     def add_arguments(self, parser):
@@ -38,13 +38,13 @@ Example: python manage.py realm_emoji --realm=zulip.com --op=show
 
         name = options['name']
         if name is None:
-            self.print_help("python manage.py", "realm_emoji")
+            self.print_help("python2.7 manage.py", "realm_emoji")
             sys.exit(1)
 
         if options["op"] == "add":
             img_url = options['img_url']
             if img_url is None:
-                self.print_help("python manage.py", "realm_emoji")
+                self.print_help("python2.7 manage.py", "realm_emoji")
                 sys.exit(1)
             do_add_realm_emoji(realm, name, img_url)
             sys.exit(0)
@@ -52,5 +52,5 @@ Example: python manage.py realm_emoji --realm=zulip.com --op=show
             do_remove_realm_emoji(realm, name)
             sys.exit(0)
         else:
-            self.print_help("python manage.py", "realm_emoji")
+            self.print_help("python2.7 manage.py", "realm_emoji")
             sys.exit(1)
diff --git a/zerver/management/commands/realm_filters.py b/zerver/management/commands/realm_filters.py
index 9971cf8596..c34191a592 100644
--- a/zerver/management/commands/realm_filters.py
+++ b/zerver/management/commands/realm_filters.py
@@ -15,9 +15,9 @@ NOTE: Regexes must be simple enough that they can be easily translated to JavaSc
       * Named groups will be converted to numbered groups automatically
       * Inline-regex flags will be stripped, and where possible translated to RegExp-wide flags
 
-Example: python manage.py realm_filters --realm=zulip.com --op=add '#(?P[0-9]{2,8})' 'https://trac.humbughq.com/ticket/%(id)s'
-Example: python manage.py realm_filters --realm=zulip.com --op=remove '#(?P[0-9]{2,8})'
-Example: python manage.py realm_filters --realm=zulip.com --op=show
+Example: python2.7 manage.py realm_filters --realm=zulip.com --op=add '#(?P[0-9]{2,8})' 'https://trac.humbughq.com/ticket/%(id)s'
+Example: python2.7 manage.py realm_filters --realm=zulip.com --op=remove '#(?P[0-9]{2,8})'
+Example: python2.7 manage.py realm_filters --realm=zulip.com --op=show
 """
 
     def add_arguments(self, parser):
@@ -44,13 +44,13 @@ Example: python manage.py realm_filters --realm=zulip.com --op=show
 
         pattern = options['pattern']
         if not pattern:
-            self.print_help("python manage.py", "realm_filters")
+            self.print_help("python2.7 manage.py", "realm_filters")
             sys.exit(1)
 
         if options["op"] == "add":
             url_format_string = options['url_format_string']
             if not url_format_string:
-                self.print_help("python manage.py", "realm_filters")
+                self.print_help("python2.7 manage.py", "realm_filters")
                 sys.exit(1)
             do_add_realm_filter(realm, pattern, url_format_string)
             sys.exit(0)
@@ -58,5 +58,5 @@ Example: python manage.py realm_filters --realm=zulip.com --op=show
             do_remove_realm_filter(realm, pattern)
             sys.exit(0)
         else:
-            self.print_help("python manage.py", "realm_filters")
+            self.print_help("python2.7 manage.py", "realm_filters")
             sys.exit(1)
diff --git a/zerver/management/commands/remove_users_from_stream.py b/zerver/management/commands/remove_users_from_stream.py
index abe0d08dc2..564de8e558 100644
--- a/zerver/management/commands/remove_users_from_stream.py
+++ b/zerver/management/commands/remove_users_from_stream.py
@@ -34,7 +34,7 @@ class Command(BaseCommand):
     def handle(self, **options):
         if options["domain"] is None or options["stream"] is None or \
                 (options["users"] is None and options["all_users"] is None):
-            self.print_help("python manage.py", "remove_users_from_stream")
+            self.print_help("python2.7 manage.py", "remove_users_from_stream")
             exit(1)
 
         realm = get_realm(options["domain"])
diff --git a/zerver/management/commands/set_default_streams.py b/zerver/management/commands/set_default_streams.py
index 9287028033..a1321d1068 100644
--- a/zerver/management/commands/set_default_streams.py
+++ b/zerver/management/commands/set_default_streams.py
@@ -18,9 +18,9 @@ streams.
 
 For example:
 
-python manage.py set_default_streams --domain=foo.com --streams=foo,bar,baz
-python manage.py set_default_streams --domain=foo.com --streams="foo,bar,baz with space"
-python manage.py set_default_streams --domain=foo.com --streams=
+python2.7 manage.py set_default_streams --domain=foo.com --streams=foo,bar,baz
+python2.7 manage.py set_default_streams --domain=foo.com --streams="foo,bar,baz with space"
+python2.7 manage.py set_default_streams --domain=foo.com --streams=
 """
 
     option_list = BaseCommand.option_list + (
diff --git a/zerver/tests/frontend/casperjs/bin/casperjs b/zerver/tests/frontend/casperjs/bin/casperjs
index 16c1be57ef..e914cd6f85 100755
--- a/zerver/tests/frontend/casperjs/bin/casperjs
+++ b/zerver/tests/frontend/casperjs/bin/casperjs
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python2.7
 
 import json
 import os
diff --git a/zerver/tests/frontend/run b/zerver/tests/frontend/run
index bd5b023af2..60f05da7ff 100755
--- a/zerver/tests/frontend/run
+++ b/zerver/tests/frontend/run
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python2.7
 import subprocess
 import requests
 import optparse
diff --git a/zilencer/management/commands/create_deployment.py b/zilencer/management/commands/create_deployment.py
index 16f54c7164..acb40467f5 100644
--- a/zilencer/management/commands/create_deployment.py
+++ b/zilencer/management/commands/create_deployment.py
@@ -32,7 +32,7 @@ class Command(BaseCommand):
     def handle(self, *args, **options):
         if None in (options["api"], options["web"], options["domain"]):
             print >>sys.stderr, "\033[1;31mYou must provide a domain, an API URL, and a web URL.\033[0m\n"
-            self.print_help("python manage.py", "create_realm")
+            self.print_help("python2.7 manage.py", "create_realm")
             exit(1)
 
         if not options["no_realm"]:
diff --git a/zilencer/management/commands/render_old_messages.py b/zilencer/management/commands/render_old_messages.py
index 183500d57a..10b6785eeb 100644
--- a/zilencer/management/commands/render_old_messages.py
+++ b/zilencer/management/commands/render_old_messages.py
@@ -9,7 +9,7 @@ import time
 class Command(BaseCommand):
     help = """Render all historical messages that haven't been rendered yet.
 
-Usage: python manage.py render_old_messages"""
+Usage: python2.7 manage.py render_old_messages"""
 
     def handle(self, *args, **options):
         total_rendered = 0
diff --git a/zulip_tools.py b/zulip_tools.py
index 18fe694851..7e9a42d470 100755
--- a/zulip_tools.py
+++ b/zulip_tools.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/env python2.7
 import os
 import sys
 import datetime