mirror of
https://github.com/zulip/zulip.git
synced 2025-10-23 04:52:12 +00:00
python: Reformat with Black, except quotes.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
committed by
Tim Abbott
parent
5028c081cb
commit
11741543da
@@ -26,6 +26,7 @@ from version import PROVISION_VERSION
|
||||
VENV_PATH = "/srv/zulip-py3-venv"
|
||||
UUID_VAR_PATH = get_dev_uuid_var_path()
|
||||
|
||||
|
||||
def create_var_directories() -> None:
|
||||
# create var/coverage, var/log, etc.
|
||||
var_dir = os.path.join(ZULIP_PATH, 'var')
|
||||
@@ -41,6 +42,7 @@ def create_var_directories() -> None:
|
||||
path = os.path.join(var_dir, sub_dir)
|
||||
os.makedirs(path, exist_ok=True)
|
||||
|
||||
|
||||
def build_pygments_data_paths() -> List[str]:
|
||||
paths = [
|
||||
"tools/setup/build_pygments_data",
|
||||
@@ -48,18 +50,21 @@ def build_pygments_data_paths() -> List[str]:
|
||||
]
|
||||
return paths
|
||||
|
||||
|
||||
def build_timezones_data_paths() -> List[str]:
|
||||
paths = [
|
||||
"tools/setup/build_timezone_values",
|
||||
]
|
||||
return paths
|
||||
|
||||
|
||||
def compilemessages_paths() -> List[str]:
|
||||
paths = ['zerver/management/commands/compilemessages.py']
|
||||
paths += glob.glob('locale/*/LC_MESSAGES/*.po')
|
||||
paths += glob.glob('locale/*/translations.json')
|
||||
return paths
|
||||
|
||||
|
||||
def inline_email_css_paths() -> List[str]:
|
||||
paths = [
|
||||
"scripts/setup/inline_email_css.py",
|
||||
@@ -68,12 +73,14 @@ def inline_email_css_paths() -> List[str]:
|
||||
paths += glob.glob('templates/zerver/emails/*.source.html')
|
||||
return paths
|
||||
|
||||
|
||||
def configure_rabbitmq_paths() -> List[str]:
|
||||
paths = [
|
||||
"scripts/setup/configure-rabbitmq",
|
||||
]
|
||||
return paths
|
||||
|
||||
|
||||
def setup_shell_profile(shell_profile: str) -> None:
|
||||
shell_profile_path = os.path.expanduser(shell_profile)
|
||||
|
||||
@@ -93,12 +100,12 @@ def setup_shell_profile(shell_profile: str) -> None:
|
||||
if os.path.exists('/srv/zulip'):
|
||||
write_command('cd /srv/zulip')
|
||||
|
||||
|
||||
def setup_bash_profile() -> None:
|
||||
"""Select a bash profile file to add setup code to."""
|
||||
|
||||
BASH_PROFILES = [
|
||||
os.path.expanduser(p) for p in
|
||||
("~/.bash_profile", "~/.bash_login", "~/.profile")
|
||||
os.path.expanduser(p) for p in ("~/.bash_profile", "~/.bash_login", "~/.profile")
|
||||
]
|
||||
|
||||
def clear_old_profile() -> None:
|
||||
@@ -131,6 +138,7 @@ def setup_bash_profile() -> None:
|
||||
# no existing bash profile found; claim .bash_profile
|
||||
setup_shell_profile(BASH_PROFILES[0])
|
||||
|
||||
|
||||
def need_to_run_build_pygments_data() -> bool:
|
||||
if not os.path.exists("static/generated/pygments_data.json"):
|
||||
return True
|
||||
@@ -141,6 +149,7 @@ def need_to_run_build_pygments_data() -> bool:
|
||||
[pygments_version],
|
||||
)
|
||||
|
||||
|
||||
def need_to_run_build_timezone_data() -> bool:
|
||||
if not os.path.exists("static/generated/timezones.json"):
|
||||
return True
|
||||
@@ -151,6 +160,7 @@ def need_to_run_build_timezone_data() -> bool:
|
||||
[timezones_version],
|
||||
)
|
||||
|
||||
|
||||
def need_to_run_compilemessages() -> bool:
|
||||
if not os.path.exists('locale/language_name_map.json'):
|
||||
# User may have cleaned their git checkout.
|
||||
@@ -162,6 +172,7 @@ def need_to_run_compilemessages() -> bool:
|
||||
compilemessages_paths(),
|
||||
)
|
||||
|
||||
|
||||
def need_to_run_inline_email_css() -> bool:
|
||||
if not os.path.exists('templates/zerver/emails/compiled/'):
|
||||
return True
|
||||
@@ -171,6 +182,7 @@ def need_to_run_inline_email_css() -> bool:
|
||||
inline_email_css_paths(),
|
||||
)
|
||||
|
||||
|
||||
def need_to_run_configure_rabbitmq(settings_list: List[str]) -> bool:
|
||||
obsolete = is_digest_obsolete(
|
||||
'last_configure_rabbitmq_hash',
|
||||
@@ -183,6 +195,7 @@ def need_to_run_configure_rabbitmq(settings_list: List[str]) -> bool:
|
||||
|
||||
try:
|
||||
from zerver.lib.queue import SimpleQueueClient
|
||||
|
||||
SimpleQueueClient()
|
||||
return False
|
||||
except Exception:
|
||||
@@ -198,10 +211,12 @@ def clean_unused_caches() -> None:
|
||||
no_headings=True,
|
||||
)
|
||||
from scripts.lib import clean_emoji_cache, clean_node_cache, clean_venv_cache
|
||||
|
||||
clean_venv_cache.main(args)
|
||||
clean_node_cache.main(args)
|
||||
clean_emoji_cache.main(args)
|
||||
|
||||
|
||||
def main(options: argparse.Namespace) -> int:
|
||||
setup_bash_profile()
|
||||
setup_shell_profile('~/.zprofile')
|
||||
@@ -255,6 +270,7 @@ def main(options: argparse.Namespace) -> int:
|
||||
# Need to set up Django before using template_status
|
||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "zproject.settings")
|
||||
import django
|
||||
|
||||
django.setup()
|
||||
|
||||
from django.conf import settings
|
||||
@@ -265,8 +281,7 @@ def main(options: argparse.Namespace) -> int:
|
||||
destroy_leaked_test_databases,
|
||||
)
|
||||
|
||||
if options.is_force or need_to_run_configure_rabbitmq(
|
||||
[settings.RABBITMQ_PASSWORD]):
|
||||
if options.is_force or need_to_run_configure_rabbitmq([settings.RABBITMQ_PASSWORD]):
|
||||
run(["scripts/setup/configure-rabbitmq"])
|
||||
write_new_digest(
|
||||
'last_configure_rabbitmq_hash',
|
||||
@@ -352,17 +367,26 @@ def main(options: argparse.Namespace) -> int:
|
||||
print(OKBLUE + "Zulip development environment setup succeeded!" + ENDC)
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('--force', action='store_true', dest='is_force',
|
||||
help="Ignore all provisioning optimizations.")
|
||||
parser.add_argument(
|
||||
'--force',
|
||||
action='store_true',
|
||||
dest='is_force',
|
||||
help="Ignore all provisioning optimizations.",
|
||||
)
|
||||
|
||||
parser.add_argument('--build-release-tarball-only', action='store_true',
|
||||
dest='is_build_release_tarball_only',
|
||||
help="Provision for test suite with production settings.")
|
||||
parser.add_argument(
|
||||
'--build-release-tarball-only',
|
||||
action='store_true',
|
||||
dest='is_build_release_tarball_only',
|
||||
help="Provision for test suite with production settings.",
|
||||
)
|
||||
|
||||
parser.add_argument('--skip-dev-db-build', action='store_true',
|
||||
help="Don't run migrations on dev database.")
|
||||
parser.add_argument(
|
||||
'--skip-dev-db-build', action='store_true', help="Don't run migrations on dev database."
|
||||
)
|
||||
|
||||
options = parser.parse_args()
|
||||
sys.exit(main(options))
|
||||
|
Reference in New Issue
Block a user