MCPcopy Create free account
hub / github.com/PierreGode/Ragnar / serve_current_config

Method serve_current_config

utils.py:345–369  ·  view source on GitHub ↗
(self, handler)

Source from the content-addressed store, hash-verified

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)

Callers

nothing calls this directly

Calls 5

warningMethod · 0.80
errorMethod · 0.80
writeMethod · 0.45
encodeMethod · 0.45

Tested by

no test coverage detected