diff --git a/Dockerfile b/Dockerfile index 009d100149..3f784f0a1a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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"] diff --git a/Vagrantfile b/Vagrantfile index 66f8fc89b6..a37b658b29 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -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", diff --git a/analytics/management/commands/analyze_user_activity.py b/analytics/management/commands/analyze_user_activity.py index 316d96a8cf..a3436ede8c 100644 --- a/analytics/management/commands/analyze_user_activity.py +++ b/analytics/management/commands/analyze_user_activity.py @@ -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""" diff --git a/analytics/management/commands/client_activity.py b/analytics/management/commands/client_activity.py index 627387ff9e..85dc38880c 100644 --- a/analytics/management/commands/client_activity.py +++ b/analytics/management/commands/client_activity.py @@ -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 diff --git a/bots/irc-mirror.py b/bots/irc-mirror.py index 8f058b0777..f9af690a58 100755 --- a/bots/irc-mirror.py +++ b/bots/irc-mirror.py @@ -104,11 +104,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 = """./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 +./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/zmirror_private.conf.template b/bots/zmirror_private.conf.template index dc31a0f422..f01b749680 100644 --- a/bots/zmirror_private.conf.template +++ b/bots/zmirror_private.conf.template @@ -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) diff --git a/contrib_bots/lib/readme.md b/contrib_bots/lib/readme.md index 1840f7725b..5cf1e023cd 100644 --- a/contrib_bots/lib/readme.md +++ b/contrib_bots/lib/readme.md @@ -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 diff --git a/contrib_bots/run.py b/contrib_bots/run.py old mode 100644 new mode 100755 index a8a649ba78..214c2eb322 --- a/contrib_bots/run.py +++ b/contrib_bots/run.py @@ -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 + ./run.py - 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, diff --git a/docs/code-style.md b/docs/code-style.md index 479bf6e312..7bd1bc3af1 100644 --- a/docs/code-style.md +++ b/docs/code-style.md @@ -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) diff --git a/docs/dev-env-first-time-contributors.md b/docs/dev-env-first-time-contributors.md index ce467bd5f9..3f590462be 100644 --- a/docs/dev-env-first-time-contributors.md +++ b/docs/dev-env-first-time-contributors.md @@ -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 diff --git a/docs/install-generic-unix-dev.md b/docs/install-generic-unix-dev.md index 1e7cfda601..a29d2baeab 100644 --- a/docs/install-generic-unix-dev.md +++ b/docs/install-generic-unix-dev.md @@ -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 diff --git a/docs/prod-customize.md b/docs/prod-customize.md index 1f045bd6ac..9b9ca73366 100644 --- a/docs/prod-customize.md +++ b/docs/prod-customize.md @@ -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 diff --git a/docs/translating.md b/docs/translating.md index c8f31f791d..1e9af5523b 100644 --- a/docs/translating.md +++ b/docs/translating.md @@ -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: diff --git a/puppet/zulip/files/cron.d/email-mirror b/puppet/zulip/files/cron.d/email-mirror index e1e318babd..b28aacff0a 100644 --- a/puppet/zulip/files/cron.d/email-mirror +++ b/puppet/zulip/files/cron.d/email-mirror @@ -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 diff --git a/puppet/zulip/files/cron.d/send-digest-emails b/puppet/zulip/files/cron.d/send-digest-emails index 4e31edc800..a3cfe373d1 100644 --- a/puppet/zulip/files/cron.d/send-digest-emails +++ b/puppet/zulip/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 && ./manage.py enqueue_digest_emails diff --git a/puppet/zulip/files/supervisor/conf.d/zulip.conf b/puppet/zulip/files/supervisor/conf.d/zulip.conf index 82397f0d59..459bf63906 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=/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) diff --git a/puppet/zulip_ops/files/cron.d/active-user-stats b/puppet/zulip_ops/files/cron.d/active-user-stats index f403c64f49..4f95d0e7c7 100644 --- a/puppet/zulip_ops/files/cron.d/active-user-stats +++ b/puppet/zulip_ops/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 && ./manage.py active_user_stats diff --git a/puppet/zulip_ops/files/cron.d/check-apns-tokens b/puppet/zulip_ops/files/cron.d/check-apns-tokens index c6875d5baf..8932086a83 100644 --- a/puppet/zulip_ops/files/cron.d/check-apns-tokens +++ b/puppet/zulip_ops/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 && ./manage.py check_apns_tokens diff --git a/puppet/zulip_ops/files/cron.d/clearsessions b/puppet/zulip_ops/files/cron.d/clearsessions index e46dc75f00..3aebe991bc 100644 --- a/puppet/zulip_ops/files/cron.d/clearsessions +++ b/puppet/zulip_ops/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 && ./manage.py clearsessions diff --git a/puppet/zulip_ops/files/supervisor/conf.d/stats.conf b/puppet/zulip_ops/files/supervisor/conf.d/stats.conf index 6f041bfcbd..dd06e70bd4 100644 --- a/puppet/zulip_ops/files/supervisor/conf.d/stats.conf +++ b/puppet/zulip_ops/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=/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) diff --git a/puppet/zulip_ops/files/supervisor/conf.d/zmirror.conf b/puppet/zulip_ops/files/supervisor/conf.d/zmirror.conf index bbcb52a82d..9f0704b61b 100644 --- a/puppet/zulip_ops/files/supervisor/conf.d/zmirror.conf +++ b/puppet/zulip_ops/files/supervisor/conf.d/zmirror.conf @@ -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) diff --git a/scripts/restart-server b/scripts/restart-server index 52c2aef318..87fed0bb6b 100755 --- a/scripts/restart-server +++ b/scripts/restart-server @@ -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") diff --git a/scripts/setup/initialize-database b/scripts/setup/initialize-database index d8feb3cd4a..e01666268a 100755 --- a/scripts/setup/initialize-database +++ b/scripts/setup/initialize-database @@ -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." diff --git a/templates/zerver/integrations.html b/templates/zerver/integrations.html index c3adfe8332..2a7d26e4cf 100644 --- a/templates/zerver/integrations.html +++ b/templates/zerver/integrations.html @@ -190,7 +190,7 @@
  • Test your configuration by running the mirror with - python asana/zulip_asana_mirror. It will print + asana/zulip_asana_mirror. It will print some informational messages and process any recently created or completed tasks.

  • @@ -1528,7 +1528,7 @@ key = NAGIOS_BOT_API_KEY with p4 triggers and add an entry something like the following: -
    notify_zulip change-commit //depot/... "python /usr/local/share/zulip/integrations/perforce/zulip_change-commit.py %change% %changeroot%"
    +
    notify_zulip change-commit //depot/... "/usr/local/share/zulip/integrations/perforce/zulip_change-commit.py %change% %changeroot%"
  • By default, this hook will send to streams of the form diff --git a/tools/build-api-tarball b/tools/build-api-tarball index bc06402928..a93ce46872 100755 --- a/tools/build-api-tarball +++ b/tools/build-api-tarball @@ -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 diff --git a/tools/deprecated/iframe-bot/last-messages-wrapper.sh b/tools/deprecated/iframe-bot/last-messages-wrapper.sh index d03aa988a0..ee3f707bf0 100755 --- a/tools/deprecated/iframe-bot/last-messages-wrapper.sh +++ b/tools/deprecated/iframe-bot/last-messages-wrapper.sh @@ -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 diff --git a/tools/do-destroy-rebuild-database b/tools/do-destroy-rebuild-database index 14d3959d61..a056aafef4 100755 --- a/tools/do-destroy-rebuild-database +++ b/tools/do-destroy-rebuild-database @@ -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 diff --git a/tools/provision.py b/tools/provision.py index 241ceda873..ee81845c64 100755 --- a/tools/provision.py +++ b/tools/provision.py @@ -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"]) diff --git a/tools/run-dev-queue-processors b/tools/run-dev-queue-processors index 57c8614360..e939ff9e19 100755 --- a/tools/run-dev-queue-processors +++ b/tools/run-dev-queue-processors @@ -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) diff --git a/tools/run-dev.py b/tools/run-dev.py index 44718e2cf1..e23f22effd 100755 --- a/tools/run-dev.py +++ b/tools/run-dev.py @@ -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 diff --git a/tools/setup/generate-fixtures b/tools/setup/generate-fixtures index 88ccd9d793..53fb98515b 100755 --- a/tools/setup/generate-fixtures +++ b/tools/setup/generate-fixtures @@ -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 \ diff --git a/tools/setup/generate-test-credentials b/tools/setup/generate-test-credentials index f9dcedc7b9..d418deaa05 100755 --- a/tools/setup/generate-test-credentials +++ b/tools/setup/generate-test-credentials @@ -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 < 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(",")]) diff --git a/zerver/management/commands/create_realm.py b/zerver/management/commands/create_realm.py index 652ecf902b..ef8dcaeabd 100644 --- a/zerver/management/commands/create_realm.py +++ b/zerver/management/commands/create_realm.py @@ -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: diff --git a/zerver/management/commands/deliver_email.py b/zerver/management/commands/deliver_email.py index fe80e7d372..4d599028fe 100755 --- a/zerver/management/commands/deliver_email.py +++ b/zerver/management/commands/deliver_email.py @@ -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): diff --git a/zerver/management/commands/email_mirror.py b/zerver/management/commands/email_mirror.py index 39c2aa4b4e..be31462d27 100755 --- a/zerver/management/commands/email_mirror.py +++ b/zerver/management/commands/email_mirror.py @@ -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 """ diff --git a/zerver/management/commands/generate_realm_creation_link.py b/zerver/management/commands/generate_realm_creation_link.py index 634f6cc684..c6cd162582 100644 --- a/zerver/management/commands/generate_realm_creation_link.py +++ b/zerver/management/commands/generate_realm_creation_link.py @@ -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 diff --git a/zerver/management/commands/import.py b/zerver/management/commands/import.py index 6a85c3d83b..f72a656246 100644 --- a/zerver/management/commands/import.py +++ b/zerver/management/commands/import.py @@ -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] [...]""" +Usage: ./manage.py import [--destroy-rebuild-database] [--import-into-nonempty] [...]""" def add_arguments(self, parser): # type: (CommandParser) -> None diff --git a/zerver/management/commands/print_email_delivery_backlog.py b/zerver/management/commands/print_email_delivery_backlog.py index 383661ffd9..b9374bb2a0 100755 --- a/zerver/management/commands/print_email_delivery_backlog.py +++ b/zerver/management/commands/print_email_delivery_backlog.py @@ -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): diff --git a/zerver/management/commands/realm_alias.py b/zerver/management/commands/realm_alias.py index 9d3a40b313..ceb85f688b 100644 --- a/zerver/management/commands/realm_alias.py +++ b/zerver/management/commands/realm_alias.py @@ -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) diff --git a/zerver/management/commands/realm_emoji.py b/zerver/management/commands/realm_emoji.py index 26bf245f97..ef66b67574 100644 --- a/zerver/management/commands/realm_emoji.py +++ b/zerver/management/commands/realm_emoji.py @@ -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) diff --git a/zerver/management/commands/realm_filters.py b/zerver/management/commands/realm_filters.py index 2ed3b019b7..c275c9002a 100644 --- a/zerver/management/commands/realm_filters.py +++ b/zerver/management/commands/realm_filters.py @@ -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[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: ./manage.py realm_filters --realm=zulip.com --op=add '#(?P[0-9]{2,8})' 'https://trac.humbughq.com/ticket/%(id)s' +Example: ./manage.py realm_filters --realm=zulip.com --op=remove '#(?P[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) diff --git a/zerver/management/commands/remove_users_from_stream.py b/zerver/management/commands/remove_users_from_stream.py index 323dfade12..2fbd435dbc 100644 --- a/zerver/management/commands/remove_users_from_stream.py +++ b/zerver/management/commands/remove_users_from_stream.py @@ -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"]) diff --git a/zerver/management/commands/send_webhook_fixture_message.py b/zerver/management/commands/send_webhook_fixture_message.py index 7784698524..57447eb100 100644 --- a/zerver/management/commands/send_webhook_fixture_message.py +++ b/zerver/management/commands/send_webhook_fixture_message.py @@ -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']) diff --git a/zerver/management/commands/set_default_streams.py b/zerver/management/commands/set_default_streams.py index 05574bd307..c80058cf22 100644 --- a/zerver/management/commands/set_default_streams.py +++ b/zerver/management/commands/set_default_streams.py @@ -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): diff --git a/zerver/management/commands/turn_off_digests.py b/zerver/management/commands/turn_off_digests.py index e15042350a..f197aab8a2 100644 --- a/zerver/management/commands/turn_off_digests.py +++ b/zerver/management/commands/turn_off_digests.py @@ -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"]: diff --git a/zerver/tests/test_management_commands.py b/zerver/tests/test_management_commands.py index a31ac63a56..1bccc130fd 100644 --- a/zerver/tests/test_management_commands.py +++ b/zerver/tests/test_management_commands.py @@ -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): diff --git a/zilencer/management/commands/compare_messages.py b/zilencer/management/commands/compare_messages.py index f77bb6a123..61cc821464 100644 --- a/zilencer/management/commands/compare_messages.py +++ b/zilencer/management/commands/compare_messages.py @@ -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 <--amount> + Usage: ./manage.py render_messages <--amount> """ def add_arguments(self, parser): diff --git a/zilencer/management/commands/create_deployment.py b/zilencer/management/commands/create_deployment.py index e631364a85..4a5a28f072 100644 --- a/zilencer/management/commands/create_deployment.py +++ b/zilencer/management/commands/create_deployment.py @@ -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"]: diff --git a/zilencer/management/commands/render_messages.py b/zilencer/management/commands/render_messages.py index 5c404e7aa8..0f1c4a067f 100644 --- a/zilencer/management/commands/render_messages.py +++ b/zilencer/management/commands/render_messages.py @@ -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 [--amount=10000] + Usage: ./manage.py render_messages [--amount=10000] """ def add_arguments(self, parser):