(self, handler)
| 343 | handler.end_headers() |
| 344 | |
| 345 | def serve_current_config(self, handler): |
| 346 | handler.send_response(200) |
| 347 | handler.send_header("Content-type", "application/json") |
| 348 | handler.end_headers() |
| 349 | |
| 350 | config_payload = None |
| 351 | |
| 352 | try: |
| 353 | with open(self.shared_data.shared_config_json, 'r') as f: |
| 354 | config_payload = json.load(f) |
| 355 | except FileNotFoundError: |
| 356 | self.logger.warning("Configuration file missing on disk; serving in-memory settings instead.") |
| 357 | except json.JSONDecodeError as exc: |
| 358 | self.logger.error(f"Configuration file is not valid JSON: {exc}") |
| 359 | except OSError as exc: |
| 360 | self.logger.error(f"Unable to read configuration file: {exc}") |
| 361 | |
| 362 | if not config_payload: |
| 363 | # Fall back to the live config or, as a last resort, the defaults |
| 364 | config_payload = dict(self.shared_data.config or self.shared_data.default_config) |
| 365 | else: |
| 366 | config_payload = dict(config_payload) |
| 367 | |
| 368 | config_payload = self.shared_data._normalize_config_keys(config_payload) |
| 369 | handler.wfile.write(json.dumps(config_payload).encode('utf-8')) |
| 370 | |
| 371 | def restore_default_config(self, handler): |
| 372 | handler.send_response(200) |
nothing calls this directly
no test coverage detected