* Add reliable http:// test * REUSE.toml: Add `test/www/**` entry * Use `cwd` instead to work around old http.server in Python 3.6 * Move test to `not-windows-any` * NetBSD: Add `python3` symbolic link * Prevent test from running on woodpecker
31 lines
636 B
Python
Executable file
31 lines
636 B
Python
Executable file
#!/usr/bin/env python3
|
|
|
|
r"""
|
|
This script launches python -m http.server in a subprocess and waits until it's ready to receive
|
|
a new connection.
|
|
|
|
"""
|
|
|
|
import http.client
|
|
import subprocess
|
|
|
|
|
|
def main():
|
|
subprocess.run(
|
|
"python3 -m http.server 9000 --bind 127.0.0.1 &",
|
|
shell=True,
|
|
check=True,
|
|
cwd="www",
|
|
stdout=subprocess.DEVNULL,
|
|
stderr=subprocess.DEVNULL,
|
|
)
|
|
while True:
|
|
try:
|
|
http.client.HTTPConnection("127.0.0.1", 9000, timeout=5).connect()
|
|
except ConnectionRefusedError:
|
|
continue
|
|
break
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|