Always start python via shebang lines.

This is preparation for supporting using Python 3 in production.

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
This commit is contained in:
Anders Kaseorg 2016-11-21 19:44:16 -05:00 committed by Tim Abbott
parent 2d6525df04
commit 207cf6302b
55 changed files with 111 additions and 107 deletions

View File

@ -16,7 +16,7 @@ RUN echo 'export LC_ALL="en_US.UTF-8" LANG="en_US.UTF-8" LANGUAGE="en_US.UTF-8"'
WORKDIR /srv/zulip
CMD ["/usr/bin/python /srv/zulip/tools/provision.py","--docker"]
CMD ["/srv/zulip/tools/provision.py", "--docker"]
CMD ["source /srv/zulip-venv/bin/activate"]
CMD ["./srv/zulip/tools/start-dockers"]

2
Vagrantfile vendored
View File

@ -86,7 +86,7 @@ if [ -d "/sys/fs/selinux" ]; then
sudo mount -o remount,ro /sys/fs/selinux
fi
ln -nsf /srv/zulip ~/zulip
/usr/bin/python /srv/zulip/tools/provision.py | sudo tee -a /var/log/zulip_provision.log
/srv/zulip/tools/provision.py | sudo tee -a /var/log/zulip_provision.log
SCRIPT
config.vm.provision "shell",

View File

@ -47,7 +47,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: ./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"""

View File

@ -17,9 +17,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"""
./manage.py client_activity
./manage.py client_activity zulip.com
./manage.py client_activity jesstess@zulip.com"""
def add_arguments(self, parser):
# type: (ArgumentParser) -> None

View File

@ -104,11 +104,11 @@ class IRCBot(irc.bot.SingleServerIRCBot):
return
self.dcc_connect(address, port)
usage = """python irc-mirror.py --server=IRC_SERVER --channel=<CHANNEL> --nick-prefix=<NICK> [optional args]
usage = """./irc-mirror.py --server=IRC_SERVER --channel=<CHANNEL> --nick-prefix=<NICK> [optional args]
Example:
python irc-mirror.py --irc-server=127.0.0.1 --channel='#test' --nick-prefix=username
./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

View File

@ -1,5 +1,5 @@
[program:zmirror-USERNAME]
command=python /home/zulip/zulip/bots/zephyr_mirror_backend.py --root-path=/home/zulip/zulip --user=USERNAME --log-path=/home/zulip/logs/mirror-log-%(program_name)s --use-sessions --session-path=/home/zulip/zephyr_sessions/%(program_name)s --api-key-file=/home/zulip/api-keys/%(program_name)s --ignore-expired-tickets --nagios-path=/home/zulip/mirror_status/%(program_name)s --nagios-class=zulip-mirror-nagios
command=/home/zulip/zulip/bots/zephyr_mirror_backend.py --root-path=/home/zulip/zulip --user=USERNAME --log-path=/home/zulip/logs/mirror-log-%(program_name)s --use-sessions --session-path=/home/zulip/zephyr_sessions/%(program_name)s --api-key-file=/home/zulip/api-keys/%(program_name)s --ignore-expired-tickets --nagios-path=/home/zulip/mirror_status/%(program_name)s --nagios-class=zulip-mirror-nagios
priority=200 ; the relative start priority (default 999)
autostart=true ; start at supervisord start (default: true)
autorestart=true ; whether/when to restart (default: unexpected)

View File

@ -30,7 +30,7 @@ Here is an example of running the "follow-up" bot from
inside a Zulip repo:
cd ~/zulip/contrib_bots
python run.py lib/followup.py --config-file ~/.zuliprc-prod
./run.py lib/followup.py --config-file ~/.zuliprc-prod
Once the bot code starts running, you will see a
message explaining how to use the bot, as well as

5
contrib_bots/run.py Normal file → Executable file
View File

@ -1,3 +1,4 @@
#!/usr/bin/env python
from __future__ import print_function
import importlib
@ -71,9 +72,9 @@ def run_message_handler_for_bot(lib_module, quiet, config_file):
def run():
usage = '''
python run.py <lib file>
./run.py <lib file>
Example: python run.py lib/followup.py
Example: ./run.py lib/followup.py
(This program loads bot-related code from the
library code and then runs a message loop,

View File

@ -320,10 +320,13 @@ styles (separate lines for each selector):
- Scripts should start with `#!/usr/bin/env python` and not
`#/usr/bin/python` (the right Python may not be installed in
`/usr/bin`) or `#/usr/bin/env/python2.7` (bad for Python 3
`/usr/bin`) or `#/usr/bin/env python2.7` (bad for Python 3
compatibility). Don't put a shebang 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.)
- Scripts should be executed directly (`./script.py`), so that the
interpreter is implicitly found from the shebang line, rather than
explicitly overridden (`python script.py`).
- The first import in a file should be
`from __future__ import absolute_import`, per [PEP
328](http://docs.python.org/2/whatsnew/2.5.html#pep-328-absolute-and-relative-imports)

View File

@ -417,7 +417,7 @@ is likely because we've recently merged changes to the development
environment provisioning process that you need to apply to your
development environmnet. To update your environment, you'll need to
re-provision your vagrant machine using `vagrant provision`
(or just `python tools/provision.py` from `/srv/zulip` inside the Vagrant
(or just `tools/provision.py` from `/srv/zulip` inside the Vagrant
guest); this should be pretty fast and we're working to make it faster.
See also the documentation on the [testing

View File

@ -283,7 +283,7 @@ Now run these commands:
```
./tools/install-mypy
./tools/setup/download-zxcvbn
python ./tools/setup/emoji_dump/build_emoji
./tools/setup/emoji_dump/build_emoji
./scripts/setup/generate_secrets.py --development
if [ $(uname) = "OpenBSD" ]; then sudo cp ./puppet/zulip/files/postgresql/zulip_english.stop /var/postgresql/tsearch_data/; else sudo cp ./puppet/zulip/files/postgresql/zulip_english.stop /usr/share/postgresql/9.*/tsearch_data/; fi
./scripts/setup/configure-rabbitmq

View File

@ -65,7 +65,7 @@ themselves with joining streams on their own. You can use the
command to set default streams for users within a realm:
```
python manage.py set_default_streams --domain=example.com --streams=foo,bar,...
./manage.py set_default_streams --domain=example.com --streams=foo,bar,...
```
## Notification settings

View File

@ -54,7 +54,7 @@ The end-to-end process to get the translations working is as follows:
[frontend](#frontend-translations) translations for details on
this).
2. Create translation [resource][] files using the `python manage
2. Create translation [resource][] files using the `./manage.py
makemessages` command. This command will create, for each language,
a resource file called `translations.json` for the frontend strings
and `django.po` for the backend strings.
@ -79,7 +79,7 @@ The end-to-end process to get the translations working is as follows:
download the resource files from Transifex and replace your local
resource files with them.
6. One runs `python manage.py compilemessages` to compile the
6. One runs `./manage.py compilemessages` to compile the
translation strings so that they are will be used in the Zulip
development environment. This is run automatically during Zulip
development environment provisioning.
@ -223,7 +223,7 @@ the `count` in the context.
## Testing Translations
First of all make sure that you have compiled the translation strings
using `python manage.py compilemessages`.
using `./manage.py compilemessages`.
Django figures out the effective language by going through the
following steps:

View File

@ -1,3 +1,3 @@
MAILTO=root
* * * * * zulip cd /home/zulip/deployments/current && python manage.py email_mirror
* * * * * zulip cd /home/zulip/deployments/current && ./manage.py email_mirror

View File

@ -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 && ./manage.py enqueue_digest_emails

View File

@ -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=/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=env PYTHONUNBUFFERED=1 python /home/zulip/deployments/current/manage.py runtornado 127.0.0.1:9993
command=env PYTHONUNBUFFERED=1 /home/zulip/deployments/current/manage.py runtornado 127.0.0.1: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 --queue_name=user_activity
command=/home/zulip/deployments/current/manage.py process_queue --queue_name=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 --queue_name=user_activity_interval
command=/home/zulip/deployments/current/manage.py process_queue --queue_name=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 --queue_name=user_presence
command=/home/zulip/deployments/current/manage.py process_queue --queue_name=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 --queue_name=signups
command=/home/zulip/deployments/current/manage.py process_queue --queue_name=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 --queue_name=invites
command=/home/zulip/deployments/current/manage.py process_queue --queue_name=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 --queue_name=missedmessage_emails
command=/home/zulip/deployments/current/manage.py process_queue --queue_name=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 --queue_name=missedmessage_mobile_notifications
command=/home/zulip/deployments/current/manage.py process_queue --queue_name=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 --queue_name=slow_queries
command=/home/zulip/deployments/current/manage.py process_queue --queue_name=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 --queue_name=message_sender --worker_num=%(process_num)s
command=/home/zulip/deployments/current/manage.py process_queue --queue_name=message_sender --worker_num=%(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 --queue_name=feedback_messages
command=/home/zulip/deployments/current/manage.py process_queue --queue_name=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 --queue_name=error_reports
command=/home/zulip/deployments/current/manage.py process_queue --queue_name=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 --queue_name=digest_emails
command=/home/zulip/deployments/current/manage.py process_queue --queue_name=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 --queue_name=email_mirror
command=/home/zulip/deployments/current/manage.py process_queue --queue_name=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=/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)

View File

@ -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 && ./manage.py active_user_stats

View File

@ -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 && ./manage.py check_apns_tokens

View File

@ -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 && ./manage.py clearsessions

View File

@ -3,7 +3,7 @@
[program:zulip-carbon-cache]
command=python /opt/graphite/bin/carbon-cache.py --debug start
command=/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=/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)

View File

@ -1,5 +1,5 @@
[program:zmirror]
command=python /home/zulip/zulip/bots/zephyr_mirror.py --root-path=/home/zulip/ --user=tabbott/extra --forward-class-messages --log-path=/home/zulip/logs/mirror-log --on-startup-command="/home/zulip/zulip/bots/zmirror-renew-kerberos"
command=/home/zulip/zulip/bots/zephyr_mirror.py --root-path=/home/zulip/ --user=tabbott/extra --forward-class-messages --log-path=/home/zulip/logs/mirror-log --on-startup-command="/home/zulip/zulip/bots/zmirror-renew-kerberos"
priority=200 ; the relative start priority (default 999)
autostart=true ; start at supervisord start (default: true)
autorestart=true ; whether/when to restart (default: unexpected)
@ -11,7 +11,7 @@ stdout_logfile=/var/log/zulip/zmirror.log ; stdout log path, NONE for no
environment=HOME="/home/zulip",USER="zulip"
[program:sync-public-streams]
command=python /home/zulip/zulip/bots/sync-public-streams
command=/home/zulip/zulip/bots/sync-public-streams
priority=200 ; the relative start priority (default 999)
autostart=true ; start at supervisord start (default: true)
autorestart=true ; whether/when to restart (default: unexpected)

View File

@ -21,10 +21,10 @@ if pwd.getpwuid(os.getuid()).pw_name != "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(["./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(["./manage.py", "fill_memcached_caches"])
# Restart the FastCGI and related processes via supervisorctl.
logging.info("Stopping workers")

View File

@ -4,12 +4,12 @@ set -xe
# Change to root directory of the checkout that we're running from
cd "$(dirname "$0")/../.."
python manage.py checkconfig
./manage.py checkconfig
python manage.py migrate --noinput
python manage.py createcachetable third_party_api_results
./manage.py migrate --noinput
./manage.py createcachetable third_party_api_results
if ! python manage.py initialize_voyager_db; then
if ! ./manage.py initialize_voyager_db; then
set +x
echo
echo -e "\033[32mPopulating default database failed."

View File

@ -190,7 +190,7 @@
</li>
<li>
<p>Test your configuration by running the mirror with
<code>python asana/zulip_asana_mirror</code>. It will print
<code>asana/zulip_asana_mirror</code>. It will print
some informational messages and process any recently created
or completed tasks.</p>
</li>
@ -1528,7 +1528,7 @@ key = NAGIOS_BOT_API_KEY
with <code>p4 triggers</code> and add an entry something like the
following:
<pre>notify_zulip change-commit //depot/... "python /usr/local/share/zulip/integrations/perforce/zulip_change-commit.py %change% %changeroot%"</pre>
<pre>notify_zulip change-commit //depot/... "/usr/local/share/zulip/integrations/perforce/zulip_change-commit.py %change% %changeroot%"</pre>
</li>
<li>By default, this hook will send to streams of the form

View File

@ -4,6 +4,6 @@ set -x
cd api/
# Strip out non-send_message bindings.
perl -i.bak -ne 'print if !m/Client._register/ ||m/send_message/ ||m/get_messages/ ||m/add_subscriptions/ ||m/list_subscriptions/ ||m/remove_subscriptions/ ||m/get_streams/ ||m/get_members/ ||m/_register.*register/ ||m/get_events/ ||m/get_subscribers/' zulip/__init__.py
python setup.py sdist
./setup.py sdist
mv zulip/__init__.py.bak zulip/__init__.py
echo API tarball written to api/dist

View File

@ -11,7 +11,7 @@ COUNT=50
mkdir -p output
while true; do
if python show-last-messages --api-key="$API_KEY" --user="$BOT_EMAIL" --streams="$STREAMS" --count="$COUNT"; then
if ./show-last-messages --api-key="$API_KEY" --user="$BOT_EMAIL" --streams="$STREAMS" --count="$COUNT"; then
echo "[`date`] Success";
mv output-candidate.html output/zulip.html
touch output/zulip.html

View File

@ -11,11 +11,11 @@ EOF
sh "$(dirname "$0")/../scripts/setup/flush-memcached"
python manage.py migrate --noinput
python manage.py createcachetable third_party_api_results
python manage.py populate_db -n100 --threads=1
./manage.py migrate --noinput
./manage.py createcachetable third_party_api_results
./manage.py populate_db -n100 --threads=1
# Ensure that the local user's API key is synced from ~/.zuliprc
if [ -e ~/.zuliprc ]; then
python manage.py sync_api_key
./manage.py sync_api_key
fi

View File

@ -194,7 +194,7 @@ def main(options):
if not os.path.isdir(EMOJI_CACHE_PATH):
run(["sudo", "mkdir", EMOJI_CACHE_PATH])
run(["sudo", "chown", "%s:%s" % (user_id, user_id), EMOJI_CACHE_PATH])
run(["python", "tools/setup/emoji_dump/build_emoji"])
run(["tools/setup/emoji_dump/build_emoji"])
run(["scripts/setup/generate_secrets.py", "--development"])
if options.is_travis and not options.is_production_travis:
run(["sudo", "service", "rabbitmq-server", "restart"])
@ -221,7 +221,7 @@ def main(options):
run(["tools/do-destroy-rebuild-test-database"])
else:
print("No need to regenerate the test DB.")
run(["python", "./manage.py", "compilemessages"])
run(["./manage.py", "compilemessages"])
# Here we install nvm, node, and npm.
run(["sudo", "tools/setup/install-node"])

View File

@ -19,5 +19,5 @@ from zerver.worker.queue_processors import get_active_worker_queues
queues = get_active_worker_queues()
args = sys.argv[1:]
subprocess.Popen(['python', 'manage.py', 'process_queue', '--all'] + args,
subprocess.Popen(['./manage.py', 'process_queue', '--all'] + args,
stderr=subprocess.STDOUT)

View File

@ -123,9 +123,9 @@ os.setpgrp()
# Pass --nostatic because we configure static serving ourselves in
# zulip/urls.py.
cmds = [['./tools/compile-handlebars-templates', 'forever'],
['python', 'manage.py', 'rundjango'] +
['./manage.py', 'rundjango'] +
manage_args + ['127.0.0.1:%d' % (django_port,)],
['env', 'PYTHONUNBUFFERED=1', 'python', 'manage.py', 'runtornado'] +
['env', 'PYTHONUNBUFFERED=1', './manage.py', 'runtornado'] +
manage_args + ['127.0.0.1:%d' % (tornado_port,)],
['./tools/run-dev-queue-processors'] + manage_args,
['env', 'PGHOST=127.0.0.1', # Force password authentication using .pgpass

View File

@ -25,13 +25,13 @@ CREATE DATABASE zulip_test TEMPLATE zulip_test_base;
EOF
sh "$(dirname "$0")/../../scripts/setup/flush-memcached"
python manage.py migrate --noinput --settings=zproject.test_settings
./manage.py migrate --noinput --settings=zproject.test_settings
migration_status "var/migration-status"
# This next line can be simplified to "-n0" once we fix our app (and tests) with 0 messages.
python manage.py populate_db --settings=zproject.test_settings --test-suite -n30 \
./manage.py populate_db --settings=zproject.test_settings --test-suite -n30 \
--threads=1 --huddles=0 --personals=0 --percent-huddles=0 --percent-personals=0
python manage.py dumpdata --settings=zproject.test_settings \
./manage.py dumpdata --settings=zproject.test_settings \
zerver.UserProfile zerver.Stream zerver.Recipient \
zerver.Subscription zerver.Message zerver.Huddle zerver.Realm \
zerver.UserMessage zerver.Client \

View File

@ -7,7 +7,7 @@ email=iago@zulip.com
mkdir -p var/casper
password=$(python manage.py print_initial_password "$email" | fgrep "$email" | awk '{ print $2 }')
password=$(./manage.py print_initial_password "$email" | fgrep "$email" | awk '{ print $2 }')
cat > var/casper/test_credentials.js <<EOF
// Generated by tools/setup/generate-test-credentials
var test_credentials = {default_user: {username: '$email', password: '$password'}};

View File

@ -36,7 +36,7 @@ def test_nagios(nagios_logfile):
ZULIP_DIR = os.path.join(TOOLS_DIR, '..')
API_DIR = os.path.join(ZULIP_DIR, 'api')
os.chdir(API_DIR)
subprocess.call(['python', 'setup.py', 'install'])
subprocess.call(['./setup.py', 'install'])
PUPPET_DIR = os.path.join(ZULIP_DIR, 'puppet')
os.chdir(ZULIP_DIR)
my_env = os.environ.copy()

View File

@ -1,6 +1,6 @@
#!/bin/bash
set -e
set -x
python tools/provision.py --travis
tools/provision.py --travis
sudo mkdir -p /var/lib/nagios_state
sudo chown travis /var/lib/nagios_state

View File

@ -11,7 +11,7 @@ sudo chmod a+rX /home/travis
# to conflicts over which version of postgres should be running.
sudo apt-get remove postgresql-9.1 postgresql-client-9.1 postgresql-9.1-postgis-2.2 postgresql-contrib-9.1 postgresql-9.1-postgis-2.2-scripts postgresql-9.2 postgresql-client-9.2 postgresql-9.2-postgis-2.2 postgresql-9.2-postgis-2.2-scripts postgresql-contrib-9.2 postgresql-9.4 postgresql-9.4-postgis-2.2-scripts postgresql-client-9.4 postgresql-9.5 postgresql-9.5-postgis-2.2 postgresql-9.5-postgis-2.2-scripts postgresql-contrib-9.5 postgresql-client-9.5 -y
python tools/provision.py --travis --production-travis
tools/provision.py --travis --production-travis
cp -a tools/travis/success-http-headers.txt ~/
source tools/travis/activate-venv
if ! ./tools/build-release-tarball travis; then

View File

@ -32,12 +32,12 @@ fp = open('var/log/update-prod-static.log', 'w')
setup_node_modules(npm_args=['--production'], stdout=fp, stderr=fp)
# Compile Handlebars templates and minify JavaScript.
subprocess.check_call(['python', 'tools/minify-js']
subprocess.check_call(['./tools/minify-js']
+ (['--prev-deploy', prev_deploy] if prev_deploy else []),
stdout=fp, stderr=fp)
# Build emoji
subprocess.check_call(['python', 'tools/setup/emoji_dump/build_emoji'],
subprocess.check_call(['./tools/setup/emoji_dump/build_emoji'],
stdout=fp, stderr=fp)
# Download and include zxcvbn.js
@ -45,11 +45,11 @@ subprocess.check_call(['bash', '-ex', 'tools/setup/download-zxcvbn'],
stdout=fp, stderr=fp)
# Collect the files that we're going to serve.
subprocess.check_call(['python', './manage.py', 'collectstatic', '--noinput', '-i', 'assets'],
subprocess.check_call(['./manage.py', 'collectstatic', '--noinput', '-i', 'assets'],
stdout=fp, stderr=fp)
# Compile translation strings to generate `.mo` files.
subprocess.check_call(['python', './manage.py', 'compilemessages'],
subprocess.check_call(['./manage.py', 'compilemessages'],
stdout=fp, stderr=fp)
# Move the source maps out of the serve/ directory and into their

View File

@ -107,7 +107,7 @@ def run_test(test):
print("Actual test to be run is %s, but import failed." % (actual_test_name,))
print("Importing test module directly to generate clearer traceback:")
try:
command = ["python", "-c", "import %s" % (actual_test_name,)]
command = [sys.executable, "-c", "import %s" % (actual_test_name,)]
print("Import test command: `%s`" % (' '.join(command),))
subprocess.check_call(command)
except subprocess.CalledProcessError:

View File

@ -44,7 +44,7 @@ class Command(BaseCommand):
# type: (**Any) -> None
if options["domain"] is None or options["streams"] is None or \
(options["users"] is None and options["all_users"] is None):
self.print_help("python manage.py", "add_users_to_streams")
self.print_help("./manage.py", "add_users_to_streams")
exit(1)
stream_names = set([stream.strip() for stream in options["streams"].split(",")])

View File

@ -18,7 +18,7 @@ import sys
class Command(BaseCommand):
help = """Create a realm.
Usage: python manage.py create_realm --string_id=acme --name='Acme'"""
Usage: ./manage.py create_realm --string_id=acme --name='Acme'"""
def add_arguments(self, parser):
# type: (CommandParser) -> None
@ -84,7 +84,7 @@ Usage: python manage.py create_realm --string_id=acme --name='Acme'"""
if not name or not string_id:
print("\033[1;31mPlease provide a name and string_id.\033[0m\n", file=sys.stderr)
self.print_help("python manage.py", "create_realm")
self.print_help("./manage.py", "create_realm")
exit(1)
if options["deployment_id"] is not None and not settings.ZILENCER_ENABLED:

View File

@ -70,7 +70,7 @@ class Command(BaseCommand):
Run this command under supervisor. We use Mandrill for zulip.com; this is for SMTP email delivery.
Usage: python manage.py deliver_email
Usage: ./manage.py deliver_email
"""
def handle(self, *args, **options):

View File

@ -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/env python /home/zulip/deployments/current/manage.py email_mirror
|/home/zulip/deployments/current/manage.py email_mirror
"""

View File

@ -12,7 +12,7 @@ class Command(BaseCommand):
settings.OPEN_REALM_CREATION is enabled. The link would expire automatically after
settings.REALM_CREATION_LINK_VALIDITY_DAYS.
Usage: python manage.py generate_realm_creation_link """
Usage: ./manage.py generate_realm_creation_link """
def handle(self, *args, **options):
# type: (*Any, **Any) -> None

View File

@ -27,7 +27,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: python2.7 manage.py import [--destroy-rebuild-database] [--import-into-nonempty] <export path name> [<export path name>...]"""
Usage: ./manage.py import [--destroy-rebuild-database] [--import-into-nonempty] <export path name> [<export path name>...]"""
def add_arguments(self, parser):
# type: (CommandParser) -> None

View File

@ -22,7 +22,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: ./manage.py print_email_delivery_backlog
"""
def handle(self, *args, **options):

View File

@ -47,5 +47,5 @@ class Command(BaseCommand):
RealmAlias.objects.get(realm=realm, domain=alias).delete()
sys.exit(0)
else:
self.print_help("python manage.py", "realm_alias")
self.print_help("./manage.py", "realm_alias")
sys.exit(1)

View File

@ -14,10 +14,10 @@ import six
class Command(BaseCommand):
help = """Manage emoji for the specified realm
Example: python manage.py realm_emoji --realm=zulip.com --op=add robotheart \\
Example: ./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: ./manage.py realm_emoji --realm=zulip.com --op=remove robotheart
Example: ./manage.py realm_emoji --realm=zulip.com --op=show
"""
# Fix support for multi-line usage
@ -54,13 +54,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("./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("./manage.py", "realm_emoji")
sys.exit(1)
check_add_realm_emoji(realm, name, img_url)
sys.exit(0)
@ -68,5 +68,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("./manage.py", "realm_emoji")
sys.exit(1)

View File

@ -20,9 +20,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<id>[0-9]{2,8})' 'https://trac.humbughq.com/ticket/%(id)s'
Example: python manage.py realm_filters --realm=zulip.com --op=remove '#(?P<id>[0-9]{2,8})'
Example: python manage.py realm_filters --realm=zulip.com --op=show
Example: ./manage.py realm_filters --realm=zulip.com --op=add '#(?P<id>[0-9]{2,8})' 'https://trac.humbughq.com/ticket/%(id)s'
Example: ./manage.py realm_filters --realm=zulip.com --op=remove '#(?P<id>[0-9]{2,8})'
Example: ./manage.py realm_filters --realm=zulip.com --op=show
"""
def add_arguments(self, parser):
@ -51,13 +51,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("./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("./manage.py", "realm_filters")
sys.exit(1)
do_add_realm_filter(realm, pattern, url_format_string)
sys.exit(0)
@ -65,5 +65,5 @@ Example: python manage.py realm_filters --realm=zulip.com --op=show
do_remove_realm_filter(realm, pattern=pattern)
sys.exit(0)
else:
self.print_help("python manage.py", "realm_filters")
self.print_help("./manage.py", "realm_filters")
sys.exit(1)

View File

@ -43,7 +43,7 @@ class Command(BaseCommand):
# type: (*Any, **Any) -> None
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("./manage.py", "remove_users_from_stream")
exit(1)
realm = get_realm(options["domain"])

View File

@ -39,7 +39,7 @@ Example:
def handle(self, **options):
# type: (*Any, **str) -> None
if options['fixture'] is None or options['url'] is None:
self.print_help('python manage.py', 'send_webhook_fixture_message')
self.print_help('./manage.py', 'send_webhook_fixture_message')
exit(1)
full_fixture_path = os.path.join(settings.DEPLOY_ROOT, options['fixture'])

View File

@ -21,9 +21,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=
./manage.py set_default_streams --domain=foo.com --streams=foo,bar,baz
./manage.py set_default_streams --domain=foo.com --streams="foo,bar,baz with space"
./manage.py set_default_streams --domain=foo.com --streams=
"""
def add_arguments(self, parser):

View File

@ -29,7 +29,7 @@ class Command(BaseCommand):
def handle(self, **options):
# type: (**str) -> None
if options["domain"] is None and options["users"] is None:
self.print_help("python manage.py", "turn_off_digests")
self.print_help("./manage.py", "turn_off_digests")
exit(1)
if options["domain"]:

View File

@ -23,7 +23,7 @@ class TestSendWebhookFixtureMessage(TestCase):
with self.assertRaises(SystemExit):
call_command(self.COMMAND_NAME, url=self.url)
print_help_mock.assert_any_call('python manage.py', self.COMMAND_NAME)
print_help_mock.assert_any_call('./manage.py', self.COMMAND_NAME)
@patch('zerver.management.commands.send_webhook_fixture_message.Command.print_help')
def test_check_if_command_exits_when_url_param_is_empty(self, print_help_mock):
@ -31,7 +31,7 @@ class TestSendWebhookFixtureMessage(TestCase):
with self.assertRaises(SystemExit):
call_command(self.COMMAND_NAME, fixture=self.fixture_path)
print_help_mock.assert_any_call('python manage.py', self.COMMAND_NAME)
print_help_mock.assert_any_call('./manage.py', self.COMMAND_NAME)
@patch('zerver.management.commands.send_webhook_fixture_message.os.path.exists')
def test_check_if_command_exits_when_fixture_path_does_not_exist(self, os_path_exists_mock):

View File

@ -12,7 +12,7 @@ from django.core.management.base import BaseCommand, CommandParser
class Command(BaseCommand):
help = """
Render messages to a file.
Usage: python manage.py render_messages <destination> <--amount>
Usage: ./manage.py render_messages <destination> <--amount>
"""
def add_arguments(self, parser):

View File

@ -33,7 +33,7 @@ class Command(BaseCommand):
# type: (*Any, **Any) -> None
if None in (options["api"], options["web"], options["domain"]):
print("\033[1;31mYou must provide a domain, an API URL, and a web URL.\033[0m\n", file=sys.stderr)
self.print_help("python manage.py", "create_realm")
self.print_help("./manage.py", "create_realm")
exit(1)
if not options["no_realm"]:

View File

@ -25,7 +25,7 @@ def queryset_iterator(queryset, chunksize=5000):
class Command(BaseCommand):
help = """
Render messages to a file.
Usage: python manage.py render_messages <destination> [--amount=10000]
Usage: ./manage.py render_messages <destination> [--amount=10000]
"""
def add_arguments(self, parser):