Add isRinging query to check alarm state via API
Features: - New GraphQL query 'isRinging' returns true/false if wecker is active - Checks the wecker process via PID file (PID_FILE in common.py) DRY refactoring: - Extract PID_FILE into shared common.py module - Both wecker.py and api/schema.py import from common - DRY enforcement tests verify identity (is) not just equality Tests: - test_is_ringing_returns_false_when_not_running - test_is_ringing_returns_true_when_running - test_pid_file_defined_once_across_modules (DRY enforcement) - test_pid_file_same_shared_constant_in_api (DRY enforcement) - Cleaned up unused imports in test_single_instance.py Docs: - Updated README.md with isRinging query documentation
This commit is contained in:
@@ -6,6 +6,8 @@ import random
|
||||
import sys
|
||||
import os
|
||||
|
||||
from common import PID_FILE
|
||||
|
||||
# Configure logging
|
||||
logging.basicConfig(
|
||||
level=logging.INFO,
|
||||
@@ -13,8 +15,6 @@ logging.basicConfig(
|
||||
handlers=[logging.FileHandler("wecker.log"), logging.StreamHandler()],
|
||||
)
|
||||
|
||||
PID_FILE = "wecker.pid"
|
||||
|
||||
|
||||
def ensure_single_instance():
|
||||
"""Ensures that only one instance of the script is running."""
|
||||
|
||||
Reference in New Issue
Block a user