BE: linting fixes

Signed-off-by: jokob-sk <jokob.sk@gmail.com>
This commit is contained in:
jokob-sk
2025-11-22 13:14:06 +11:00
parent f0abd500d9
commit 5c14b34a8b
104 changed files with 2163 additions and 2199 deletions

View File

@@ -1,8 +1,8 @@
#!/usr/bin/env python3
# !/usr/bin/env python3
import subprocess
import sys
import os
def run_sqlite_command(command):
# Use environment variable with fallback
db_path = os.path.join(
@@ -19,18 +19,19 @@ def run_sqlite_command(command):
print(f"Error executing command: {e}")
return None
def check_and_clean_device():
while True:
print("\nDevice Cleanup Tool")
print("1. Check/Clean by MAC address")
print("2. Check/Clean by IP address")
print("3. Exit")
choice = input("\nSelect option (1-3): ")
if choice == "1":
mac = input("Enter MAC address (format: xx:xx:xx:xx:xx:xx): ").lower()
# Check all tables for MAC
tables_checks = [
f"SELECT 'Events' as source, * FROM Events WHERE eve_MAC='{mac}'",
@@ -40,14 +41,14 @@ def check_and_clean_device():
f"SELECT 'AppEvents' as source, * FROM AppEvents WHERE ObjectPrimaryID LIKE '%{mac}%' OR ObjectSecondaryID LIKE '%{mac}%'",
f"SELECT 'Plugins_Objects' as source, * FROM Plugins_Objects WHERE Object_PrimaryID LIKE '%{mac}%'"
]
found = False
for check in tables_checks:
result = run_sqlite_command(check)
if result and result.strip():
found = True
print(f"\nFound entries:\n{result}")
if found:
confirm = input("\nWould you like to clean these entries? (y/n): ")
if confirm.lower() == 'y':
@@ -60,16 +61,16 @@ def check_and_clean_device():
f"DELETE FROM AppEvents WHERE ObjectPrimaryID LIKE '%{mac}%' OR ObjectSecondaryID LIKE '%{mac}%'",
f"DELETE FROM Plugins_Objects WHERE Object_PrimaryID LIKE '%{mac}%'"
]
for delete in deletes:
run_sqlite_command(delete)
print("Cleanup completed!")
else:
print("\nNo entries found for this MAC address")
elif choice == "2":
ip = input("Enter IP address (format: xxx.xxx.xxx.xxx): ")
# Check all tables for IP
tables_checks = [
f"SELECT 'Events' as source, * FROM Events WHERE eve_IP='{ip}'",
@@ -79,14 +80,14 @@ def check_and_clean_device():
f"SELECT 'AppEvents' as source, * FROM AppEvents WHERE ObjectSecondaryID LIKE '%{ip}%'",
f"SELECT 'Plugins_Objects' as source, * FROM Plugins_Objects WHERE Object_SecondaryID LIKE '%{ip}%'"
]
found = False
for check in tables_checks:
result = run_sqlite_command(check)
if result and result.strip():
found = True
print(f"\nFound entries:\n{result}")
if found:
confirm = input("\nWould you like to clean these entries? (y/n): ")
if confirm.lower() == 'y':
@@ -99,19 +100,20 @@ def check_and_clean_device():
f"DELETE FROM AppEvents WHERE ObjectSecondaryID LIKE '%{ip}%'",
f"DELETE FROM Plugins_Objects WHERE Object_SecondaryID LIKE '%{ip}%'"
]
for delete in deletes:
run_sqlite_command(delete)
print("Cleanup completed!")
else:
print("\nNo entries found for this IP address")
elif choice == "3":
print("\nExiting...")
break
else:
print("\nInvalid option, please try again")
if __name__ == "__main__":
check_and_clean_device()