From 7e0eeb20a3a48140e44ce02b50975c35cb89c241 Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Fri, 24 Apr 2020 13:24:11 -0700 Subject: [PATCH] update-prod-static: Stop hiding output in update-prod-static.log. Now that we've cleaned up this tool's output, there's no reason to use an awkward mechanism to hide its output; we can just print it out like a normal program. Fixes #14644; resolves #14701. --- scripts/lib/node_cache.py | 17 +++++------------ tools/build-release-tarball | 16 +--------------- tools/update-prod-static | 22 ++++++++-------------- 3 files changed, 14 insertions(+), 41 deletions(-) diff --git a/scripts/lib/node_cache.py b/scripts/lib/node_cache.py index aa673a073b..81322bf1c7 100644 --- a/scripts/lib/node_cache.py +++ b/scripts/lib/node_cache.py @@ -3,7 +3,7 @@ import hashlib import json import shutil -from typing import Optional, List, IO, Any +from typing import Optional, List from scripts.lib.zulip_tools import subprocess_text_output, run ZULIP_PATH = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) @@ -49,8 +49,6 @@ def generate_sha1sum_node_modules( def setup_node_modules( production: bool = DEFAULT_PRODUCTION, - stdout: Optional[IO[Any]] = None, - stderr: Optional[IO[Any]] = None, prefer_offline: bool = False, ) -> None: yarn_args = get_yarn_args(production=production) @@ -64,9 +62,7 @@ def setup_node_modules( if not os.path.exists(success_stamp): do_yarn_install(target_path, yarn_args, - success_stamp, - stdout=stdout, - stderr=stderr) + success_stamp) print("Using cached node modules from %s" % (cached_node_modules,)) if os.path.islink('node_modules'): @@ -78,9 +74,7 @@ def setup_node_modules( def do_yarn_install( target_path: str, yarn_args: List[str], - success_stamp: str, - stdout: Optional[IO[Any]] = None, - stderr: Optional[IO[Any]] = None, + success_stamp: str ) -> None: os.makedirs(target_path, exist_ok=True) shutil.copy('package.json', target_path) @@ -93,9 +87,8 @@ def do_yarn_install( if os.path.exists("node_modules") and not os.path.exists(cached_node_modules): shutil.copytree("node_modules/", cached_node_modules, symlinks=True) if os.environ.get('CUSTOM_CA_CERTIFICATES'): - run([YARN_BIN, "config", "set", "cafile", os.environ['CUSTOM_CA_CERTIFICATES']], - stdout=stdout, stderr=stderr) + run([YARN_BIN, "config", "set", "cafile", os.environ['CUSTOM_CA_CERTIFICATES']]) run([YARN_BIN, "install", "--non-interactive", "--frozen-lockfile"] + yarn_args, - cwd=target_path, stdout=stdout, stderr=stderr) + cwd=target_path) with open(success_stamp, 'w'): pass diff --git a/tools/build-release-tarball b/tools/build-release-tarball index 3657946f7f..6b83e64cdc 100755 --- a/tools/build-release-tarball +++ b/tools/build-release-tarball @@ -92,21 +92,7 @@ rabbitmq_password = 'not_used_here' initial_password_salt = 'not_used_here' EOF -# We do a bit of gymnastics to have update-prod-static.log be easily -# visible to the user and end up in the same directory as the final -# release tarball. -USER_PROD_STATIC_LOGPATH="$TMPDIR/update-prod-static.log" -BUILD_PROD_STATIC_LOGPATH="$TMPDIR/$prefix/var/log/update-prod-static.log" -ln -nfs "$BUILD_PROD_STATIC_LOGPATH" "$USER_PROD_STATIC_LOGPATH" - -./tools/update-prod-static $authors_not_required || ( - set +x - echo; echo -ne '\033[33mRunning update-prod-static failed. ' - echo -e "Check $TMPDIR/update-prod-static.log for more information.\\033[0m" - exit 1 -) -rm -f "$USER_PROD_STATIC_LOGPATH" -mv "$BUILD_PROD_STATIC_LOGPATH" "$USER_PROD_STATIC_LOGPATH" +./tools/update-prod-static $authors_not_required # We don't need duplicate copies of emoji with hashed paths, and they would break bugdown find prod-static/serve/generated/emoji/images/emoji/ -regex '.*\.[0-9a-f]+\.png' -delete diff --git a/tools/update-prod-static b/tools/update-prod-static index c3c592bb02..187a86899c 100755 --- a/tools/update-prod-static +++ b/tools/update-prod-static @@ -32,27 +32,23 @@ prev_deploy = args.prev_deploy os.chdir(settings.DEPLOY_ROOT) -# Redirect child processes' output to a log file (most recent run only). -os.makedirs("var/log", exist_ok=True) -fp = open('var/log/update-prod-static.log', 'w') - # Install node packages -setup_node_modules(production=True, stdout=fp, stderr=fp) +setup_node_modules(production=True) # Build emoji -run(['./tools/setup/emoji/build_emoji'], stdout=fp, stderr=fp) +run(['./tools/setup/emoji/build_emoji']) # Inline CSS in emails -run(['./scripts/setup/inline_email_css.py'], stdout=fp, stderr=fp) +run(['./scripts/setup/inline_email_css.py']) # Copy over static files from the zulip_bots package -run(['./tools/setup/generate_zulip_bots_static_files.py'], stdout=fp, stderr=fp) +run(['./tools/setup/generate_zulip_bots_static_files.py']) # Build pygment data -run(['./tools/setup/build_pygments_data'], stdout=fp, stderr=fp) +run(['./tools/setup/build_pygments_data']) # Create webpack bundle -run(['./tools/webpack', '--quiet'], stdout=fp, stderr=fp) +run(['./tools/webpack', '--quiet']) # Collect the files that we're going to serve; this creates prod-static/serve. run([ @@ -65,12 +61,10 @@ run([ '-i', 'js', '-i', 'styles', '-i', 'templates', -], stdout=fp, stderr=fp) +]) # Compile translation strings to generate `.mo` files. -run(['./manage.py', 'compilemessages', '-v0'], stdout=fp, stderr=fp) +run(['./manage.py', 'compilemessages', '-v0']) # Needed if PRODUCTION os.makedirs('prod-static', exist_ok=True) - -fp.close()