Files
EvoScientist-Multi/EvoScientist/channels/signal/probe.py
T
X-iZhang c5a4d559a2 Refactor test cases for improved readability and consistency
- Added blank lines for better separation of test cases in multiple test files.
- Reformatted event handling in tests for clarity and consistency.
- Ensured consistent use of multi-line formatting for dictionary arguments in event handling.
- Improved assertions and test descriptions for better understanding.
- Updated test cases across various modules including test_stream_state, test_stream_utils, test_summarization, test_thread_selector, test_tool_error_handler, test_tui_widgets, test_ui_runtime, and test_wechat_channel.
2026-03-15 21:12:51 +00:00

44 lines
1.1 KiB
Python

"""Signal credential validation."""
import logging
logger = logging.getLogger(__name__)
async def validate_signal(
phone_number: str,
cli_path: str = "signal-cli",
rpc_port: int = 7583,
) -> tuple[bool, str]:
"""Validate Signal setup by checking signal-cli availability.
Returns:
Tuple of (is_valid, message).
"""
import asyncio
import subprocess
if not phone_number:
return False, "phone_number is required"
# Check signal-cli binary
loop = asyncio.get_event_loop()
def _check():
try:
result = subprocess.run(
[cli_path, "--version"],
capture_output=True,
text=True,
timeout=5,
)
if result.returncode == 0:
return True, f"signal-cli {result.stdout.strip()}"
return False, "signal-cli returned error"
except FileNotFoundError:
return False, f"signal-cli not found at '{cli_path}'"
except Exception as e:
return False, f"Error: {e}"
return await loop.run_in_executor(None, _check)