From e469578a5586c1efbfbc8969c2199fc14caf6c6e Mon Sep 17 00:00:00 2001 From: Greg Price Date: Thu, 3 Aug 2017 14:45:22 -0700 Subject: [PATCH] py3: Fix up (almost) all script invocations to rely on shebangs. This follows up on 207cf6302 from last year to clean up cases that have apparently popped up since then. Invoking the scripts directly makes a cleaner command line in any case, and moreover is essential to how we control running a Zulip install as either Python 2 or 3 (soon, how we always ensure it runs as Python 3.) One exception: we're currently forcing `provision` in dev to run Python 3, while still running both Python 2 and Python 3 jobs in CI. We use a non-shebang invocation to do the forcing of Python 3. --- docs/migration-renumbering.md | 4 ++-- .../zulip/files/cron.d/update-analytics-counts | 2 +- tools/js-dep-visualizer.py | 3 ++- tools/provision | 18 ++++++++++-------- tools/test-all | 6 +++--- tools/travis/backend | 6 +++--- 6 files changed, 21 insertions(+), 18 deletions(-) mode change 100644 => 100755 tools/js-dep-visualizer.py diff --git a/docs/migration-renumbering.md b/docs/migration-renumbering.md index 4f37637ffb..1f81387563 100644 --- a/docs/migration-renumbering.md +++ b/docs/migration-renumbering.md @@ -85,9 +85,9 @@ semantic conflicts with the new changes from master: File "/srv/zulip-venv-cache/ad3a375e95a56d911510d7edba7e17280d227bc7/zulip-venv/local/lib/python2.7/site-packages/django/core/management/commands/migrate.py", line 105, in handle - "'python manage.py makemigrations --merge'" % name_str + "'./manage.py makemigrations --merge'" % name_str django.core.management.base.CommandError: Conflicting migrations detected (0026_topics_backfill, 0025_realm_message_content_edit_limit in zerver). -To fix them run 'python manage.py makemigrations --merge' +To fix them run './manage.py makemigrations --merge' diff --git a/puppet/zulip/files/cron.d/update-analytics-counts b/puppet/zulip/files/cron.d/update-analytics-counts index 68404c7a07..b5b9b4e4b7 100644 --- a/puppet/zulip/files/cron.d/update-analytics-counts +++ b/puppet/zulip/files/cron.d/update-analytics-counts @@ -3,5 +3,5 @@ PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin USER=zulip # Run update analytics tables every 5 minutes past the hour -5 * * * * zulip python /home/zulip/deployments/current/manage.py update_analytics_counts +5 * * * * zulip /home/zulip/deployments/current/manage.py update_analytics_counts diff --git a/tools/js-dep-visualizer.py b/tools/js-dep-visualizer.py old mode 100644 new mode 100755 index eacb909c2d..232c32a4f0 --- a/tools/js-dep-visualizer.py +++ b/tools/js-dep-visualizer.py @@ -1,5 +1,6 @@ +#!/usr/bin/env python """ -$ python ./tools/js-dep-visualizer.py +$ ./tools/js-dep-visualizer.py $ dot -Tpng var/zulip-deps.dot -o var/zulip-deps.png """ diff --git a/tools/provision b/tools/provision index babfa5bfbb..e5fdb16538 100755 --- a/tools/provision +++ b/tools/provision @@ -10,26 +10,28 @@ if [ "$EUID" -eq 0 ]; then exit 1 fi -if [ -n "$TRAVIS" ]; then - PYTHON=python -else - PYTHON=python3 -fi - #Make the script independent of the location from where it is #executed PARENT_PATH=$( cd "$(dirname "${BASH_SOURCE}")" ; pwd -P ) cd "$PARENT_PATH" mkdir -p ../var/log LOG_PATH="../var/log/provision.log" -PROVISION_PATH="lib/provision.py" echo "PROVISIONING STARTING." >> $LOG_PATH +PROVISION_PATH="./lib/provision.py" +if [ -n "$TRAVIS" ]; then + # In CI, we let PATH provide the Python version. + PROVISION_CMD=("$PROVISION_PATH") +else + # In dev, we force Python 3. + PROVISION_CMD=(python3 "$PROVISION_PATH") +fi + # PYTHONUNBUFFERED is important to ensure that tracebacks don't get # lost far above where they should be in the output. export PYTHONUNBUFFERED=1 -"$PYTHON" "$PROVISION_PATH" "$@" 2>&1 | tee -a "$LOG_PATH" +"${PROVISION_CMD[@]}" "$@" 2>&1 | tee -a "$LOG_PATH" failed=${PIPESTATUS[0]} if [ $failed = 1 ]; then diff --git a/tools/test-all b/tools/test-all index 7a0bff7ed0..f238449704 100755 --- a/tools/test-all +++ b/tools/test-all @@ -41,9 +41,9 @@ run ./tools/run-mypy # travis/backend run ./tools/lint --pep8 $FORCEARG -run python manage.py makemessages --locale en -run python -W ignore tools/check-capitalization --no-generate -run python -W ignore tools/check-frontend-i18n --no-generate +run ./manage.py makemessages --locale en +run PYTHONWARNINGS=ignore ./tools/check-capitalization --no-generate +run PYTHONWARNINGS=ignore ./tools/check-frontend-i18n --no-generate run ./tools/test-tools run ./tools/test-backend $FORCEARG run ./tools/test-migrations diff --git a/tools/travis/backend b/tools/travis/backend index 67ee5a4563..18685b81b8 100755 --- a/tools/travis/backend +++ b/tools/travis/backend @@ -6,9 +6,9 @@ set -e set -x ./tools/lint --pep8 # Include the slow and thus non-default pep8 linter check -python manage.py makemessages --locale en -python -W ignore tools/check-capitalization --no-generate -python -W ignore tools/check-frontend-i18n --no-generate +./manage.py makemessages --locale en +PYTHONWARNINGS=ignore ./tools/check-capitalization --no-generate +PYTHONWARNINGS=ignore ./tools/check-frontend-i18n --no-generate ./tools/test-tools ./tools/test-backend --coverage