Files
zulip/scripts/lib/unpack-zulip
Anders Kaseorg 365fe0b3d5 python: Sort imports with isort.
Fixes #2665.

Regenerated by tabbott with `lint --fix` after a rebase and change in
parameters.

Note from tabbott: In a few cases, this converts technical debt in the
form of unsorted imports into different technical debt in the form of
our largest files having very long, ugly import sequences at the
start.  I expect this change will increase pressure for us to split
those files, which isn't a bad thing.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-06-11 16:45:32 -07:00

52 lines
1.3 KiB
Python
Executable File

#!/usr/bin/env python3
import glob
import os
import shutil
import subprocess
import sys
import tempfile
os.environ["PYTHONUNBUFFERED"] = "y"
sys.path.append(os.path.join(os.path.dirname(__file__), '..', ".."))
import version
from scripts.lib.zulip_tools import (
DEPLOYMENTS_DIR,
ENDC,
FAIL,
get_deployment_version,
is_invalid_upgrade,
make_deploy_path,
overwrite_symlink,
)
if len(sys.argv) != 2:
print(FAIL + f"Usage: {sys.argv[0]} <tarball>" + ENDC)
sys.exit(1)
tarball_path = sys.argv[1]
deploy_path = make_deploy_path()
extract_path = tempfile.mkdtemp()
subprocess.check_call(["tar", "-xf", tarball_path, "-C", extract_path])
new_version = get_deployment_version(extract_path)
current_version = version.ZULIP_VERSION
if is_invalid_upgrade(current_version, new_version):
print(FAIL +
"Your current version is very old. Please first upgrade to version "
"1.4.3 and then upgrade to {}.".format(new_version) +
ENDC)
shutil.rmtree(extract_path)
sys.exit(1)
shutil.move(glob.glob(os.path.join(extract_path, "zulip-server-*"))[0], deploy_path)
os.rmdir(extract_path)
overwrite_symlink("/etc/zulip/settings.py",
os.path.join(deploy_path, "zproject/prod_settings.py"))
overwrite_symlink(deploy_path, os.path.join(DEPLOYMENTS_DIR, "next"))
print(deploy_path)
sys.exit(0)