62 lines
1.9 KiB
Python
62 lines
1.9 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Test script for network monitor functionality
|
|
"""
|
|
|
|
import sys
|
|
import time
|
|
from kivy.app import App
|
|
from kivy.clock import Clock
|
|
from network_monitor import NetworkMonitor
|
|
|
|
class TestMonitorApp(App):
|
|
"""Minimal Kivy app to test network monitor"""
|
|
|
|
def build(self):
|
|
"""Build the app"""
|
|
from kivy.uix.label import Label
|
|
return Label(text='Network Monitor Test Running\nCheck terminal for output')
|
|
|
|
def on_start(self):
|
|
"""Start monitoring when app starts"""
|
|
server_url = "https://digi-signage.moto-adv.com"
|
|
|
|
print("=" * 60)
|
|
print("Network Monitor Test")
|
|
print("=" * 60)
|
|
print()
|
|
print(f"Server URL: {server_url}")
|
|
print("Check interval: 0.5 minutes (30 seconds for testing)")
|
|
print("WiFi restart duration: 1 minute (for testing)")
|
|
print()
|
|
|
|
# Create monitor with short intervals for testing
|
|
self.monitor = NetworkMonitor(
|
|
server_url=server_url,
|
|
check_interval_min=0.5, # 30 seconds
|
|
check_interval_max=0.5, # 30 seconds
|
|
wifi_restart_duration=1 # 1 minute
|
|
)
|
|
|
|
# Perform immediate test
|
|
print("Performing immediate connectivity test...")
|
|
self.monitor._check_connectivity()
|
|
|
|
# Start monitoring for future checks
|
|
print("\nStarting periodic network monitoring...")
|
|
self.monitor.start_monitoring()
|
|
|
|
print("\nMonitoring is active. Press Ctrl+C to stop.")
|
|
print("Next check will occur in ~30 seconds.")
|
|
print()
|
|
|
|
def on_stop(self):
|
|
"""Stop monitoring when app stops"""
|
|
if hasattr(self, 'monitor'):
|
|
self.monitor.stop_monitoring()
|
|
print("\nNetwork monitoring stopped")
|
|
print("Test completed!")
|
|
|
|
if __name__ == '__main__':
|
|
TestMonitorApp().run()
|