mirror of
https://github.com/zulip/zulip.git
synced 2025-11-03 05:23:35 +00:00
python: Replace list literal concatenation with * unpacking.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
committed by
Tim Abbott
parent
a5dbab8fb0
commit
1ded51aa9d
@@ -20,9 +20,9 @@ vendor = distro_info['ID']
|
||||
os_version = distro_info['VERSION_ID']
|
||||
VENV_DEPENDENCIES = get_venv_dependencies(vendor, os_version)
|
||||
if "debian" in os_families():
|
||||
run(["apt-get", "-y", "install"] + VENV_DEPENDENCIES)
|
||||
run(["apt-get", "-y", "install", *VENV_DEPENDENCIES])
|
||||
elif "fedora" in os_families():
|
||||
run(["yum", "-y", "install"] + VENV_DEPENDENCIES)
|
||||
run(["yum", "-y", "install", *VENV_DEPENDENCIES])
|
||||
else:
|
||||
print("Unsupported platform: {}".format(distro_info['ID']))
|
||||
sys.exit(1)
|
||||
|
||||
@@ -21,9 +21,9 @@ args = parser.parse_args()
|
||||
# install dependencies for setting up the virtualenv
|
||||
distro_info = parse_os_release()
|
||||
if "debian" in os_families():
|
||||
run(["apt-get", "-y", "install"] + THUMBOR_VENV_DEPENDENCIES)
|
||||
run(["apt-get", "-y", "install", *THUMBOR_VENV_DEPENDENCIES])
|
||||
elif "fedora" in os_families():
|
||||
run(["yum", "-y", "install"] + YUM_THUMBOR_VENV_DEPENDENCIES)
|
||||
run(["yum", "-y", "install", *YUM_THUMBOR_VENV_DEPENDENCIES])
|
||||
else:
|
||||
print("Unsupported platform: {}".format(distro_info['ID']))
|
||||
sys.exit(1)
|
||||
|
||||
@@ -83,7 +83,7 @@ def do_yarn_install(
|
||||
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']])
|
||||
run([YARN_BIN, "install", "--non-interactive", "--frozen-lockfile"] + yarn_args,
|
||||
run([YARN_BIN, "install", "--non-interactive", "--frozen-lockfile", *yarn_args],
|
||||
cwd=target_path)
|
||||
with open(success_stamp, 'w'):
|
||||
pass
|
||||
|
||||
@@ -59,12 +59,14 @@ COMMON_YUM_VENV_DEPENDENCIES = [
|
||||
"jq",
|
||||
]
|
||||
|
||||
REDHAT_VENV_DEPENDENCIES = COMMON_YUM_VENV_DEPENDENCIES + [
|
||||
REDHAT_VENV_DEPENDENCIES = [
|
||||
*COMMON_YUM_VENV_DEPENDENCIES,
|
||||
"python36-devel",
|
||||
"python-virtualenv",
|
||||
]
|
||||
|
||||
FEDORA_VENV_DEPENDENCIES = COMMON_YUM_VENV_DEPENDENCIES + [
|
||||
FEDORA_VENV_DEPENDENCIES = [
|
||||
*COMMON_YUM_VENV_DEPENDENCIES,
|
||||
"python3-pip",
|
||||
"virtualenv", # see https://unix.stackexchange.com/questions/27877/install-virtualenv-on-fedora-16
|
||||
]
|
||||
|
||||
@@ -65,7 +65,7 @@ try:
|
||||
# version is much better for fixing bugs in the upgrade process).
|
||||
deploy_path = deploy_path.strip()
|
||||
os.chdir(deploy_path)
|
||||
subprocess.check_call([os.path.abspath("./scripts/lib/upgrade-zulip-stage-2"), deploy_path]
|
||||
+ deploy_options)
|
||||
subprocess.check_call([os.path.abspath("./scripts/lib/upgrade-zulip-stage-2"), deploy_path,
|
||||
*deploy_options])
|
||||
finally:
|
||||
release_deployment_lock()
|
||||
|
||||
@@ -78,6 +78,6 @@ try:
|
||||
overwrite_symlink(deploy_path, os.path.join(DEPLOYMENTS_DIR, "next"))
|
||||
|
||||
subprocess.check_call([os.path.join(deploy_path, "scripts", "lib", "upgrade-zulip-stage-2"),
|
||||
deploy_path, "--from-git"] + deploy_options)
|
||||
deploy_path, "--from-git", *deploy_options])
|
||||
finally:
|
||||
release_deployment_lock()
|
||||
|
||||
@@ -104,7 +104,7 @@ def shutdown_server() -> None:
|
||||
core_server_services.append("zulip-thumbor")
|
||||
|
||||
logging.info("Stopping Zulip...")
|
||||
subprocess.check_call(["supervisorctl", "stop"] + core_server_services + worker_services,
|
||||
subprocess.check_call(["supervisorctl", "stop", *core_server_services, *worker_services],
|
||||
preexec_fn=su_to_zulip)
|
||||
IS_SERVER_UP = False
|
||||
|
||||
|
||||
@@ -460,7 +460,7 @@ def is_root() -> bool:
|
||||
def run_as_root(args: List[str], **kwargs: Any) -> None:
|
||||
sudo_args = kwargs.pop('sudo_args', [])
|
||||
if not is_root():
|
||||
args = ['sudo'] + sudo_args + ['--'] + args
|
||||
args = ['sudo', *sudo_args, '--', *args]
|
||||
run(args, **kwargs)
|
||||
|
||||
def assert_not_running_as_root() -> None:
|
||||
|
||||
@@ -62,7 +62,7 @@ def main() -> None:
|
||||
print("Cleaning orphaned/unused caches...")
|
||||
|
||||
# Call 'clean-unused-caches' script to clean any orphaned/unused caches.
|
||||
subprocess.check_call([os.path.join(ZULIP_PATH, "scripts/lib/clean-unused-caches")] + sys.argv[1:])
|
||||
subprocess.check_call([os.path.join(ZULIP_PATH, "scripts/lib/clean-unused-caches"), *sys.argv[1:]])
|
||||
print("Done!")
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -75,10 +75,10 @@ else:
|
||||
logging.info("Stopping workers")
|
||||
subprocess.check_call(["supervisorctl", "stop", "zulip-workers:*"])
|
||||
logging.info("Stopping server core")
|
||||
subprocess.check_call(["supervisorctl", "stop"] + core_server_services)
|
||||
subprocess.check_call(["supervisorctl", "stop", *core_server_services])
|
||||
|
||||
logging.info("Starting server core")
|
||||
subprocess.check_call(["supervisorctl", "start"] + core_server_services)
|
||||
subprocess.check_call(["supervisorctl", "start", *core_server_services])
|
||||
logging.info("Starting workers")
|
||||
subprocess.check_call(["supervisorctl", "start", "zulip-workers:*"])
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@ def restore_backup(tarball_file: IO[bytes]) -> None:
|
||||
|
||||
os.mkdir(os.path.join(tmp, "zulip-backup"))
|
||||
tarball_file.seek(0, 0)
|
||||
run(["tar", "-C", tmp] + transform_args + ["-xPz"], stdin=tarball_file)
|
||||
run(["tar", "-C", tmp, *transform_args, "-xPz"], stdin=tarball_file)
|
||||
|
||||
# Now, extract the the database backup, destroy the old
|
||||
# database, and create a new, empty database.
|
||||
|
||||
@@ -50,7 +50,7 @@ if (distro_info['ID'], distro_info['VERSION_ID']) in [('ubuntu', '20.04')]:
|
||||
puppet_env["RUBYOPT"] = "-W0"
|
||||
|
||||
if not args.noop and not args.force:
|
||||
subprocess.check_call(puppet_cmd + ['--noop', '--show_diff'], env=puppet_env)
|
||||
subprocess.check_call([*puppet_cmd, '--noop', '--show_diff'], env=puppet_env)
|
||||
|
||||
do_apply = None
|
||||
while do_apply != 'y':
|
||||
@@ -60,7 +60,7 @@ if not args.noop and not args.force:
|
||||
if do_apply == '' or do_apply == 'n':
|
||||
sys.exit(0)
|
||||
|
||||
ret = subprocess.call(puppet_cmd + ['--detailed-exitcodes'], env=puppet_env)
|
||||
ret = subprocess.call([*puppet_cmd, '--detailed-exitcodes'], env=puppet_env)
|
||||
# ret = 0 => no changes, no errors
|
||||
# ret = 2 => changes, no errors
|
||||
# ret = 4 => no changes, yes errors
|
||||
|
||||
Reference in New Issue
Block a user