(self, page_name, timeout=10, interval=1)
| 62 | self.webserver_username_password = (WEBSERVER_USERNAME, WEBSERVER_PASSWORD) |
| 63 | |
| 64 | def open_debug_webpage(self, page_name, timeout=10, interval=1): |
| 65 | start_time = time() |
| 66 | |
| 67 | while (time() - start_time < timeout): |
| 68 | try: |
| 69 | protocol = "http" |
| 70 | if self.webserver_certificate_file != "": |
| 71 | protocol = "https" |
| 72 | host_port = to_host_port(self.webserver_interface, self.webserver_port) |
| 73 | url = "%s://%s/%s" % (protocol, host_port, page_name) |
| 74 | cert = self.webserver_certificate_file |
| 75 | # Instead of cert use its CA cert if available. |
| 76 | file_part = cert.split("/")[-1] |
| 77 | if file_part in CERT_TO_CA_MAP: |
| 78 | cert = cert.replace(file_part, CERT_TO_CA_MAP[file_part]) |
| 79 | return requests.get(url, verify=cert, auth=self.webserver_username_password) |
| 80 | except Exception as e: |
| 81 | LOG.info("Debug webpage not yet available: %s", str(e)) |
| 82 | sleep(interval) |
| 83 | assert 0, 'Debug webpage did not become available in expected time.' |
| 84 | |
| 85 | def read_debug_webpage(self, page_name, timeout=10, interval=1): |
| 86 | return self.open_debug_webpage(page_name, timeout=timeout, interval=interval).text |
no test coverage detected