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
|
2016-06-07 11:48:48 +02:00
|
|
|
import os
|
|
|
|
import signal
|
|
|
|
import subprocess
|
2018-01-31 01:08:43 +01:00
|
|
|
import sys
|
2023-01-06 09:09:53 +01:00
|
|
|
import tempfile
|
2020-03-12 18:24:37 +01:00
|
|
|
import time
|
2018-01-01 05:25:44 +01:00
|
|
|
from typing import Tuple
|
2016-06-07 11:48:48 +02:00
|
|
|
|
2021-07-03 08:22:44 +02:00
|
|
|
sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
|
|
|
|
|
|
|
|
from tools.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__)
|
2016-06-07 11:48:48 +02:00
|
|
|
|
|
|
|
TOOLS_DIR = os.path.dirname(os.path.abspath(__file__))
|
|
|
|
|
2021-02-12 08:19:30 +01:00
|
|
|
|
2020-03-12 18:24:37 +01:00
|
|
|
def start_server(logfile_name: str) -> Tuple[bool, str]:
|
|
|
|
failure = True
|
2021-08-02 23:41:26 +02:00
|
|
|
key = "Quit the server with CONTROL-C."
|
2020-03-12 18:24:37 +01:00
|
|
|
datalog = []
|
2021-08-02 23:41:26 +02:00
|
|
|
with open(logfile_name, "rb", buffering=0) as logfile:
|
2020-03-12 18:24:37 +01:00
|
|
|
for i in range(200):
|
|
|
|
time.sleep(0.5)
|
2020-06-09 00:25:09 +02:00
|
|
|
print(f"{i}. Polling run-dev...")
|
2021-08-02 23:41:26 +02:00
|
|
|
new_data = logfile.read().decode()
|
2020-03-12 18:24:37 +01:00
|
|
|
if new_data:
|
|
|
|
datalog.append(new_data)
|
|
|
|
|
2021-02-12 08:20:45 +01:00
|
|
|
if key in "".join(datalog):
|
2020-03-12 18:24:37 +01:00
|
|
|
failure = False
|
|
|
|
break
|
|
|
|
|
2021-02-12 08:20:45 +01:00
|
|
|
return failure, "".join(datalog)
|
2016-06-07 11:48:48 +02:00
|
|
|
|
2021-02-12 08:19:30 +01:00
|
|
|
|
2021-02-12 08:20:45 +01:00
|
|
|
if __name__ == "__main__":
|
2016-06-07 11:48:48 +02:00
|
|
|
print("Testing development server start!")
|
|
|
|
|
2023-01-06 09:09:53 +01:00
|
|
|
with tempfile.NamedTemporaryFile(buffering=0) as logfile:
|
2020-03-12 18:24:37 +01:00
|
|
|
run_dev = subprocess.Popen(
|
2021-02-12 08:19:30 +01:00
|
|
|
[os.path.join(TOOLS_DIR, "run-dev.py")], stdout=logfile, stderr=subprocess.STDOUT
|
|
|
|
)
|
2023-01-06 09:09:53 +01:00
|
|
|
failure, log = start_server(logfile.name)
|
2020-03-12 18:24:37 +01:00
|
|
|
|
|
|
|
run_dev.send_signal(signal.SIGINT)
|
|
|
|
run_dev.wait()
|
2016-06-07 11:48:48 +02:00
|
|
|
|
2021-02-12 08:20:45 +01:00
|
|
|
if "Traceback" in log:
|
2016-06-07 11:48:48 +02:00
|
|
|
failure = True
|
|
|
|
|
|
|
|
if failure:
|
|
|
|
print("Development server is not working properly:")
|
2016-07-24 18:03:40 +02:00
|
|
|
print(log)
|
2016-06-07 11:48:48 +02:00
|
|
|
sys.exit(1)
|
|
|
|
else:
|
|
|
|
print("Development server is working properly.")
|
|
|
|
sys.exit(0)
|