py3: Switch almost all shebang lines to use `python3`.
This causes `upgrade-zulip-from-git`, as well as a no-option run of
`tools/build-release-tarball`, to produce a Zulip install running
Python 3, rather than Python 2. In particular this means that the
virtualenv we create, in which all application code runs, is Python 3.
One shebang line, on `zulip-ec2-configure-interfaces`, explicitly
keeps Python 2, and at least one external ops script, `wal-e`, also
still runs on Python 2. See discussion on the respective previous
commits that made those explicit. There may also be some other
third-party scripts we use, outside of this source tree and running
outside our virtualenv, that still run on Python 2.
2017-08-02 23:15:16 +02:00
|
|
|
#!/usr/bin/env python3
|
2017-10-01 07:06:08 +02:00
|
|
|
import argparse
|
2019-04-23 05:51:14 +02:00
|
|
|
import contextlib
|
2016-12-16 09:07:29 +01:00
|
|
|
import os
|
|
|
|
import subprocess
|
2020-06-11 00:54:34 +02:00
|
|
|
import sys
|
2019-04-23 05:51:14 +02:00
|
|
|
from typing import Iterator
|
2016-12-16 09:07:29 +01:00
|
|
|
|
2017-08-28 01:03:45 +02:00
|
|
|
ZULIP_PATH = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
2017-02-05 21:24:28 +01:00
|
|
|
|
|
|
|
# check for the venv
|
|
|
|
from lib import sanity_check
|
2020-06-11 00:54:34 +02:00
|
|
|
|
2017-02-05 21:24:28 +01:00
|
|
|
sanity_check.check_venv(__file__)
|
|
|
|
|
2017-10-01 07:06:08 +02:00
|
|
|
parser = argparse.ArgumentParser()
|
2021-02-12 08:20:45 +01:00
|
|
|
parser.add_argument("--force", action="store_true", help="Run tests despite possible problems.")
|
2021-02-12 08:19:30 +01:00
|
|
|
parser.add_argument(
|
2021-02-12 08:20:45 +01:00
|
|
|
"--skip-external-links",
|
2021-02-12 08:19:30 +01:00
|
|
|
dest="skip_external_link_check",
|
|
|
|
action="store_true",
|
2021-02-12 08:20:45 +01:00
|
|
|
help="Skip checking of external links.",
|
2021-02-12 08:19:30 +01:00
|
|
|
)
|
2017-10-01 07:06:08 +02:00
|
|
|
options = parser.parse_args()
|
2016-12-16 09:07:29 +01:00
|
|
|
|
2017-08-28 01:03:45 +02:00
|
|
|
os.chdir(ZULIP_PATH)
|
|
|
|
sys.path.insert(0, ZULIP_PATH)
|
2017-01-25 18:52:35 +01:00
|
|
|
from tools.lib.test_server import test_server_running
|
2016-12-16 09:07:29 +01:00
|
|
|
|
2021-02-12 08:20:45 +01:00
|
|
|
os.makedirs("var/help-documentation", exist_ok=True)
|
2016-12-16 09:07:29 +01:00
|
|
|
|
2021-02-12 08:20:45 +01:00
|
|
|
LOG_FILE = "var/help-documentation/server.log"
|
2017-01-25 18:52:35 +01:00
|
|
|
external_host = "localhost:9981"
|
2016-12-16 09:07:29 +01:00
|
|
|
|
2021-02-12 08:20:45 +01:00
|
|
|
extra_args = ["-a", "validate_html=set"]
|
2018-12-22 13:02:32 +01:00
|
|
|
|
|
|
|
if options.skip_external_link_check:
|
2021-02-12 08:20:45 +01:00
|
|
|
extra_args += ["-a", "skip_external=set"]
|
2018-12-22 13:02:32 +01:00
|
|
|
|
2021-02-12 08:19:30 +01:00
|
|
|
|
2019-04-23 05:51:14 +02:00
|
|
|
@contextlib.contextmanager
|
|
|
|
def vnu_servlet() -> Iterator[None]:
|
2021-02-12 08:19:30 +01:00
|
|
|
with subprocess.Popen(
|
|
|
|
[
|
2021-02-12 08:20:45 +01:00
|
|
|
"java",
|
|
|
|
"-cp",
|
2021-02-12 08:19:30 +01:00
|
|
|
os.path.join(
|
|
|
|
os.path.dirname(__file__),
|
2021-02-12 08:20:45 +01:00
|
|
|
"../node_modules/vnu-jar/build/dist/vnu.jar",
|
2021-02-12 08:19:30 +01:00
|
|
|
),
|
2021-02-12 08:20:45 +01:00
|
|
|
"-Dnu.validator.servlet.bind-address=127.0.0.1",
|
|
|
|
"nu.validator.servlet.Main",
|
|
|
|
"9988",
|
2021-02-12 08:19:30 +01:00
|
|
|
]
|
|
|
|
) as proc:
|
2019-04-23 05:51:14 +02:00
|
|
|
yield
|
|
|
|
proc.terminate()
|
|
|
|
|
2021-02-12 08:19:30 +01:00
|
|
|
|
|
|
|
with vnu_servlet(), test_server_running(options.force, external_host, log_file=LOG_FILE, dots=True):
|
|
|
|
ret_help_doc = subprocess.call(
|
2021-02-12 08:20:45 +01:00
|
|
|
["scrapy", "crawl_with_status", *extra_args, "help_documentation_crawler"],
|
|
|
|
cwd="tools/documentation_crawler",
|
2021-02-12 08:19:30 +01:00
|
|
|
)
|
|
|
|
ret_api_doc = subprocess.call(
|
2021-02-12 08:20:45 +01:00
|
|
|
["scrapy", "crawl_with_status", *extra_args, "api_documentation_crawler"],
|
|
|
|
cwd="tools/documentation_crawler",
|
2021-02-12 08:19:30 +01:00
|
|
|
)
|
|
|
|
ret_portico_doc = subprocess.call(
|
2021-02-12 08:20:45 +01:00
|
|
|
["scrapy", "crawl_with_status", *extra_args, "portico_documentation_crawler"],
|
|
|
|
cwd="tools/documentation_crawler",
|
2021-02-12 08:19:30 +01:00
|
|
|
)
|
2016-12-16 09:07:29 +01:00
|
|
|
|
2018-04-21 20:12:23 +02:00
|
|
|
if ret_help_doc != 0 or ret_api_doc != 0 or ret_portico_doc != 0:
|
2016-12-16 09:07:29 +01:00
|
|
|
print("\033[0;91m")
|
|
|
|
print("Failed")
|
|
|
|
print("\033[0m")
|
|
|
|
else:
|
|
|
|
print("\033[0;92m")
|
|
|
|
print("Passed!")
|
|
|
|
print("\033[0m")
|
|
|
|
|
|
|
|
|
2018-04-21 20:12:23 +02:00
|
|
|
sys.exit(ret_help_doc or ret_api_doc or ret_portico_doc)
|