Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
python: Prefer --flag=option over --flag option.
Anders Kaseorgbb4fc3c4c7f9
diff --git a/scripts/lib/setup_venv.py b/scripts/lib/setup_venv.pyindex 41b60e9c350..e06c4a7510d 100644--- a/scripts/lib/setup_venv.py+++ b/scripts/lib/setup_venv.py@@ -101,8 +101,8 @@ def get_venv_dependencies(vendor: str, os_version: str) -> List[str]:def install_venv_deps(pip: str, requirements_file: str) -> None:pip_requirements = os.path.join(ZULIP_PATH, "requirements", "pip.txt")- run([pip, "install", "--force-reinstall", "--require-hashes", "--requirement", pip_requirements])- run([pip, "install", "--no-deps", "--require-hashes", "--requirement", requirements_file])+ run([pip, "install", "--force-reinstall", "--require-hashes", "-r", pip_requirements])+ run([pip, "install", "--no-deps", "--require-hashes", "-r", requirements_file])def get_index_filename(venv_path: str) -> str:return os.path.join(venv_path, 'package_index')diff --git a/scripts/lib/upgrade-zulip-stage-2 b/scripts/lib/upgrade-zulip-stage-2index 0a6bb52630c..d2e3e8e4ea7 100755--- a/scripts/lib/upgrade-zulip-stage-2+++ b/scripts/lib/upgrade-zulip-stage-2@@ -203,7 +203,7 @@ elif args.from_git:# update-prod-static with the git upgrade process. But it'll fail# safely; this seems like a worthwhile tradeoff to minimize downtime.logging.info("Building static assets...")- subprocess.check_call(["./tools/update-prod-static", "--prev-deploy",+ subprocess.check_call(["./tools/update-prod-static", "--prev-deploy=" +os.path.join(DEPLOYMENTS_DIR, 'current')],preexec_fn=su_to_zulip)logging.info("Caching zulip git version...")diff --git a/scripts/setup/restore-backup b/scripts/setup/restore-backupindex e07c7488e5a..bb6900204b3 100755--- a/scripts/setup/restore-backup+++ b/scripts/setup/restore-backup@@ -34,11 +34,10 @@ def restore_backup(tarball_file: IO[bytes]) -> None:subprocess.call(["tar",- "-C",- "/etc/zulip",+ "--directory=/etc/zulip","--strip-components=2","-xz",- "zulip-backup/settings",+ "zulip-backup/settings"],stdin=tarball_file,)@@ -105,7 +104,7 @@ def restore_backup(tarball_file: IO[bytes]) -> None:env=postgres_env,)run(["dropdb", "--if-exists", "--", db["NAME"]], cwd="/", env=postgres_env)- run(["createdb", "-O", "zulip", "-T", "template0", "--", db["NAME"]], cwd="/", env=postgres_env)+ run(["createdb", "--owner=zulip", "--template=template0", "--", db["NAME"]], cwd="/", env=postgres_env)os.setresuid(0, 0, 0)if settings.PRODUCTION:@@ -145,7 +144,7 @@ def restore_backup(tarball_file: IO[bytes]) -> None:# needs to run after zulip-puppet-apply to ensure full-text# search extensions are available and installed.os.setresuid(POSTGRES_PWENT.pw_uid, POSTGRES_PWENT.pw_uid, 0)- run(["pg_restore", "-d", db["NAME"], "--", db_dir], cwd="/", env=postgres_env)+ run(["pg_restore", "--dbname=" + db["NAME"], "--", db_dir], cwd="/", env=postgres_env)os.setresuid(0, 0, 0)run(["chown", "-R", str(uid), "--", tmp])os.setresuid(uid, uid, 0)diff --git a/scripts/zulip-puppet-apply b/scripts/zulip-puppet-applyindex d5cf797ecd2..2d6ce2c6593 100755--- a/scripts/zulip-puppet-apply+++ b/scripts/zulip-puppet-apply@@ -35,7 +35,7 @@ for pclass in re.split(r'\s*,\s*', config.get('machine', 'puppet_classes')):# We use the puppet configuration from the same Zulip checkout as this scriptscripts_path = os.path.join(BASE_DIR, "scripts")puppet_module_path = os.path.join(BASE_DIR, "puppet")-puppet_cmd = ["puppet", "apply", "--modulepath", puppet_module_path, "-e", puppet_config]+puppet_cmd = ["puppet", "apply", f"--modulepath={puppet_module_path}", "-e", puppet_config]if args.noop:puppet_cmd += ["--noop"]puppet_cmd += extra_argsdiff --git a/tools/run-dev.py b/tools/run-dev.pyindex 6a7007f865a..866e295121b 100755--- a/tools/run-dev.py+++ b/tools/run-dev.py@@ -150,8 +150,8 @@ def server_processes() -> List[List[str]]:['env', 'PGHOST=127.0.0.1', # Force password authentication using .pgpass'./puppet/zulip/files/postgresql/process_fts_updates', '--quiet'],['./manage.py', 'deliver_scheduled_messages'],- ['/srv/zulip-thumbor-venv/bin/thumbor', '-c', './zthumbor/thumbor_settings.py',- '-p', f'{thumbor_port}'],+ ['/srv/zulip-thumbor-venv/bin/thumbor', '--conf=./zthumbor/thumbor_settings.py',+ f'--port={thumbor_port}'],]# NORMAL (but slower) operation:@@ -165,7 +165,7 @@ def do_one_time_webpack_compile() -> None:subprocess.check_call(['./tools/webpack', '--quiet', '--test'])def start_webpack_watcher() -> None:- webpack_cmd = ['./tools/webpack', '--watch', '--port', str(webpack_port)]+ webpack_cmd = ['./tools/webpack', '--watch', f'--port={webpack_port}']if options.minify:webpack_cmd.append('--minify')if options.interface is None:@@ -173,9 +173,9 @@ def start_webpack_watcher() -> None:# to disable the webpack host check so that webpack will serve assets.webpack_cmd.append('--disable-host-check')if options.interface:- webpack_cmd += ["--host", options.interface]+ webpack_cmd.append(f"--host={options.interface}")else:- webpack_cmd += ["--host", "0.0.0.0"]+ webpack_cmd.append("--host=0.0.0.0")subprocess.Popen(webpack_cmd)def transform_url(protocol: str, path: str, query: str, target_port: int, target_host: str) -> str:diff --git a/tools/setup/emoji/test-emoji-name-scripts b/tools/setup/emoji/test-emoji-name-scriptsindex bfd3a773516..1aaadcd7cf3 100755--- a/tools/setup/emoji/test-emoji-name-scripts+++ b/tools/setup/emoji/test-emoji-name-scripts@@ -19,21 +19,21 @@ def generate_files(source_file: str, tmp_dir: str) -> None:input_file_path = output_file_pathoutput_file_path = os.path.join(tmp_dir, 'NAME_MAP_A')subprocess.check_call([os.path.join(TOOLS_DIR, 'setup', 'emoji', 'import_emoji_names_from_csv'),- '--input-file', input_file_path, '--output-file', output_file_path],+ f'--input-file={input_file_path}', f'--output-file={output_file_path}'],stdout=subprocess.DEVNULL)# Regenerate the CSV file from name map.input_file_path = output_file_pathoutput_file_path = os.path.join(tmp_dir, 'CSV_B')subprocess.check_call([os.path.join(TOOLS_DIR, 'setup', 'emoji', 'export_emoji_names_to_csv'),- '--input-file', input_file_path, '--output-file', output_file_path],+ f'--input-file={input_file_path}', f'--output-file={output_file_path}'],stdout=subprocess.DEVNULL)# Regenerate the name map file from the regenerated CSV file.input_file_path = output_file_pathoutput_file_path = os.path.join(tmp_dir, 'NAME_MAP_B')subprocess.check_call([os.path.join(TOOLS_DIR, 'setup', 'emoji', 'import_emoji_names_from_csv'),- '--input-file', input_file_path, '--output-file', output_file_path],+ f'--input-file={input_file_path}', f'--output-file={output_file_path}'],stdout=subprocess.DEVNULL)def print_diff(path_file1: str, path_file2: str) -> None:diff --git a/tools/update-prod-static b/tools/update-prod-staticindex c42f45a3a0e..42218d8ae4a 100755--- a/tools/update-prod-static+++ b/tools/update-prod-static@@ -52,12 +52,12 @@ run(['./manage.py', 'collectstatic', '--no-default-ignore','-v0','--noinput',- '-i', 'assets',- '-i', 'emoji-styles',- '-i', 'html',- '-i', 'js',- '-i', 'styles',- '-i', 'templates',+ '--ignore=assets',+ '--ignore=emoji-styles',+ '--ignore=html',+ '--ignore=js',+ '--ignore=styles',+ '--ignore=templates',])# Compile translation strings to generate `.mo` files.diff --git a/tools/webpack b/tools/webpackindex 26d21c19de9..9af7afb2ea3 100755--- a/tools/webpack+++ b/tools/webpack@@ -14,9 +14,9 @@ def build_for_prod_or_casper(quiet: bool) -> NoReturn:webpack_args = ['node', 'node_modules/.bin/webpack-cli','-p',- '--env', 'production']+ '--env=production']if quiet:- webpack_args += ['--display', 'errors-only']+ webpack_args.append('--display=errors-only')os.execvp(webpack_args[0], webpack_args)def build_for_dev_server(host: str, port: str, minify: bool, disable_host_check: bool) -> None:@@ -29,10 +29,10 @@ def build_for_dev_server(host: str, port: str, minify: bool, disable_host_check:webpack_args += [# webpack-cli has a bug where it ignores --watch-poll with# multi-config, and we don't need the katex-cli part anyway.- '--config-name', 'frontend',- '--allowed-hosts', ','.join([host, '.zulipdev.com', '.zulipdev.org']),- '--host', host,- '--port', port,+ '--config-name=frontend',+ '--allowed-hosts=' + ','.join([host, '.zulipdev.com', '.zulipdev.org']),+ f'--host={host}',+ f'--port={port}',# We add the hot flag using the cli because it takes care# of addition to entry points and adding the plugin# automaticallydiff --git a/zerver/lib/export.py b/zerver/lib/export.pyindex 7cbc70fe269..03fb111df85 100644--- a/zerver/lib/export.py+++ b/zerver/lib/export.py@@ -1602,11 +1602,11 @@ def launch_user_message_subprocesses(threads: int, output_dir: Path,arguments = [os.path.join(settings.DEPLOY_ROOT, "manage.py"),'export_usermessage_batch',- '--path', str(output_dir),- '--thread', str(shard_id),+ f'--path={output_dir}',+ f'--thread={shard_id}',]if consent_message_id is not None:- arguments.extend(['--consent-message-id', str(consent_message_id)])+ arguments.append(f'--consent-message-id={consent_message_id}')process = subprocess.Popen(arguments)pids[process.pid] = shard_iddiff --git a/zerver/management/commands/backup.py b/zerver/management/commands/backup.pyindex 18a259d48c9..ef78cf85337 100644--- a/zerver/management/commands/backup.py+++ b/zerver/management/commands/backup.py@@ -68,11 +68,11 @@ class Command(ZulipBaseCommand):pg_dump_command = ["pg_dump","--format=directory",- "--file", os.path.join(tmp, "zulip-backup", "database"),- "--host", settings.DATABASES["default"]["HOST"],- "--port", settings.DATABASES["default"]["PORT"],- "--username", settings.DATABASES["default"]["USER"],- "--dbname", settings.DATABASES["default"]["NAME"],+ "--file=" + os.path.join(tmp, "zulip-backup", "database"),+ "--host=" + settings.DATABASES["default"]["HOST"],+ "--port=" + settings.DATABASES["default"]["PORT"],+ "--username=" + settings.DATABASES["default"]["USER"],+ "--dbname=" + settings.DATABASES["default"]["NAME"],"--no-password",]os.environ["PGPASSWORD"] = settings.DATABASES["default"]["PASSWORD"]@@ -115,7 +115,7 @@ class Command(ZulipBaseCommand):tarball_path = options["output"]run(- ["tar", "-C", tmp, "-cPzf", tarball_path,+ ["tar", f"--directory={tmp}", "-cPzf", tarball_path,*transform_args,"--",*members]