mirror of
https://github.com/zulip/zulip.git
synced 2025-11-05 06:23:38 +00:00
python: Normalize quotes with Black.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
committed by
Tim Abbott
parent
11741543da
commit
6e4c3e41dc
@@ -40,36 +40,36 @@ def write_updated_configs() -> None:
|
||||
sorted(ports) == expected_ports
|
||||
), f"ports ({sorted(ports)}) must be contiguous, starting with 9800"
|
||||
|
||||
with open('/etc/zulip/nginx_sharding.conf.tmp', 'w') as nginx_sharding_conf_f, open(
|
||||
'/etc/zulip/sharding.json.tmp', 'w'
|
||||
with open("/etc/zulip/nginx_sharding.conf.tmp", "w") as nginx_sharding_conf_f, open(
|
||||
"/etc/zulip/sharding.json.tmp", "w"
|
||||
) as sharding_json_f:
|
||||
|
||||
if len(ports) == 1:
|
||||
nginx_sharding_conf_f.write("set $tornado_server http://tornado;\n")
|
||||
sharding_json_f.write('{}\n')
|
||||
sharding_json_f.write("{}\n")
|
||||
return
|
||||
|
||||
nginx_sharding_conf_f.write("set $tornado_server http://tornado9800;\n")
|
||||
shard_map: Dict[str, int] = {}
|
||||
external_host = subprocess.check_output(
|
||||
[os.path.join(BASE_DIR, 'scripts/get-django-setting'), 'EXTERNAL_HOST'],
|
||||
[os.path.join(BASE_DIR, "scripts/get-django-setting"), "EXTERNAL_HOST"],
|
||||
universal_newlines=True,
|
||||
).strip()
|
||||
for port in config_file["tornado_sharding"]:
|
||||
shards = config_file["tornado_sharding"][port].strip()
|
||||
|
||||
if shards:
|
||||
for shard in shards.split(' '):
|
||||
if '.' in shard:
|
||||
for shard in shards.split(" "):
|
||||
if "." in shard:
|
||||
host = shard
|
||||
else:
|
||||
host = f"{shard}.{external_host}"
|
||||
assert host not in shard_map, f"host {host} duplicated"
|
||||
shard_map[host] = int(port)
|
||||
write_realm_nginx_config_line(nginx_sharding_conf_f, host, port)
|
||||
nginx_sharding_conf_f.write('\n')
|
||||
nginx_sharding_conf_f.write("\n")
|
||||
|
||||
sharding_json_f.write(json.dumps(shard_map) + '\n')
|
||||
sharding_json_f.write(json.dumps(shard_map) + "\n")
|
||||
|
||||
|
||||
parser = argparse.ArgumentParser(
|
||||
@@ -83,7 +83,7 @@ parser.add_argument(
|
||||
options = parser.parse_args()
|
||||
|
||||
config_file_path = "/etc/zulip"
|
||||
base_files = ['nginx_sharding.conf', 'sharding.json']
|
||||
base_files = ["nginx_sharding.conf", "sharding.json"]
|
||||
full_real_paths = [f"{config_file_path}/{filename}" for filename in base_files]
|
||||
full_new_paths = [f"{filename}.tmp" for filename in full_real_paths]
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user