fix: Clean up whitespace and improve code formatting across service adapters
Some checks failed
Integration Tests / integration-tests (push) Failing after 20s
Integration Tests / performance-tests (push) Has been skipped
Service Adapters (Python FastAPI) / test (3.11) (push) Failing after 24s
Service Adapters (Python FastAPI) / test (3.12) (push) Failing after 25s
Service Adapters (Python FastAPI) / test (3.13) (push) Failing after 25s
Service Adapters (Python FastAPI) / build (push) Has been skipped

### Summary of Changes
- Removed unnecessary whitespace and standardized formatting in multiple files, including `main.py`, `logging_middleware.py`, `general.py`, and various health checker implementations.
- Enhanced readability and maintainability of the codebase by ensuring consistent formatting practices.

### Expected Results
- Improved code clarity, making it easier for developers to read and understand the service adapters' code.
- Streamlined the codebase, facilitating future updates and maintenance.
This commit is contained in:
GSRN
2025-09-18 13:02:46 +02:00
parent 4450311e47
commit 7eaea39928
13 changed files with 217 additions and 276 deletions

View File

@@ -51,17 +51,19 @@ async def debug_logging():
logger.info("This is an INFO message from routes.general")
logger.warning("This is a WARNING message from routes.general")
logger.error("This is an ERROR message from routes.general")
# Test request logger
from services.logging_config import get_request_logger
request_logger = get_request_logger()
request_logger.info("This is a request logger message")
# Test application logger
from services.logging_config import get_application_logger
app_logger = get_application_logger()
app_logger.info("This is an application logger message")
# Get current logging configuration
root_logger = logging.getLogger()
config_info = {
@@ -74,13 +76,9 @@ async def debug_logging():
"application_logger_level": logging.getLevelName(app_logger.level),
"uvicorn_access_level": logging.getLevelName(logging.getLogger("uvicorn.access").level),
}
logger.info("Unified logging debug info requested")
return {
"message": "Unified log messages sent to console",
"config": config_info,
"note": "All logs now use the same format and handler"
}
return {"message": "Unified log messages sent to console", "config": config_info, "note": "All logs now use the same format and handler"}
@router.get(
@@ -93,27 +91,22 @@ async def debug_sensor(service_name: str):
"""Debug endpoint to inspect raw sensor data"""
from services.config import SERVICES
from services.health_checkers import factory
if service_name not in SERVICES:
return {"error": f"Service {service_name} not found"}
config = SERVICES[service_name]
if config.get("health_check_type") != "sensor":
return {"error": f"Service {service_name} is not using sensor health checking"}
try:
# Create sensor checker
checker = factory.create_checker("sensor", timeout=10.0)
# Get raw sensor data
result = await checker.check_health(service_name, config)
return {
"service_name": service_name,
"config": config,
"result": result.to_dict(),
"raw_sensor_data": result.metadata
}
return {"service_name": service_name, "config": config, "result": result.to_dict(), "raw_sensor_data": result.metadata}
except Exception as e:
logger.error(f"Error debugging sensor for {service_name}: {e}")
return {"error": str(e)}
@@ -129,10 +122,10 @@ async def debug_sensor(service_name: str):
async def get_services():
"""Get status of all configured external services (Home Assistant, Frigate, Immich, n8n)"""
logger.info("Service status endpoint called - checking all services")
# Check all services concurrently
status_results = await status_checker.check_all_services()
service_status = {}
for service_name, config in SERVICES.items():
status_info = status_results.get(service_name, {})
@@ -143,8 +136,8 @@ async def get_services():
response_time=status_info.get("response_time"),
error=status_info.get("error"),
uptime=status_info.get("uptime"),
metadata=status_info.get("metadata", {})
metadata=status_info.get("metadata", {}),
)
logger.info(f"Service status check completed - returning status for {len(service_status)} services")
return service_status