1import http.server 2import os 3import subprocess 4import sys 5import threading 6 7class TrivialHandler(http.server.BaseHTTPRequestHandler): 8 def do_GET(self): 9 self.send_response(501) 10 11 def log_request(self, *args, **kwargs): 12 print(self.requestline) 13 print(self.headers) 14 15httpd = http.server.HTTPServer(('', 0), TrivialHandler) 16port = httpd.socket.getsockname()[1] 17 18try: 19 t = threading.Thread(target=httpd.serve_forever).start() 20 os.environ['DEBUGINFOD_URLS'] =f'http://localhost:{port}' 21 subprocess.run(sys.argv[1:], capture_output = True) 22finally: 23 httpd.shutdown() 24