Add log cleanup function (15-day deletion) and archive documentation

- Added cleanup_old_logs() function to app_v3_simplified.py
- Deletes log.txt if older than 15 days at app startup
- Sends notification to monitoring server when cleanup occurs
- Archived all legacy modules and documentation to oldcode/
- Updated device_info.txt with correct IP (192.168.1.104)
- All changes validated and tested
This commit is contained in:
RPI User
2025-12-18 17:18:14 +02:00
parent eedf3a1c69
commit c3a55a89c3
39 changed files with 2666 additions and 66 deletions

53
oldcode/device_module.py Normal file
View File

@@ -0,0 +1,53 @@
"""
Device information management
Handles hostname and IP address of the device
Uses file-based configuration for reliability
"""
import os
from config_settings import DEVICE_INFO_FILE
def get_device_info():
"""
Get device hostname and IP from configuration file
Returns tuple: (hostname, device_ip)
The hostname and IP are read from device_info.txt which should be
configured with the device's own hostname and IP address.
"""
hostname = None
device_ip = None
# Load device info from file (primary method - no socket resolution)
try:
os.makedirs(os.path.dirname(DEVICE_INFO_FILE), exist_ok=True)
with open(DEVICE_INFO_FILE, "r") as f:
lines = f.read().strip().split('\n')
if len(lines) >= 2:
hostname = lines[0].strip()
device_ip = lines[1].strip()
print(f"Device Info - Hostname: {hostname}, IP: {device_ip}")
return hostname, device_ip
else:
print(f"Warning: {DEVICE_INFO_FILE} exists but lacks valid data")
except FileNotFoundError:
print(f"Device info file not found at {DEVICE_INFO_FILE}")
except Exception as e:
print(f"Error reading device info file: {e}")
# Fallback if file doesn't exist or has issues
print("Using default device values")
hostname = "prezenta-device"
device_ip = "192.168.1.100"
# Create file with default values for future use
try:
os.makedirs(os.path.dirname(DEVICE_INFO_FILE), exist_ok=True)
with open(DEVICE_INFO_FILE, "w") as f:
f.write(f"{hostname}\n{device_ip}\n")
print(f"Created device info file with defaults: {hostname}, {device_ip}")
except Exception as e:
print(f"Warning: Could not create device info file: {e}")
return hostname, device_ip