65 lines
1.9 KiB
Python
65 lines
1.9 KiB
Python
"""ICEYOU entry point - launches the system tray application."""
|
|
|
|
import sys
|
|
import threading
|
|
import traceback
|
|
from pathlib import Path
|
|
from datetime import datetime
|
|
|
|
# Add src to path for development
|
|
sys.path.insert(0, str(Path(__file__).parent / "src"))
|
|
|
|
from iceyou.tray_app import TrayApp
|
|
|
|
|
|
def log_crash_report(exc_type, exc_value, exc_traceback, thread_name="MainThread"):
|
|
"""Write a detailed crash report to both console and a log file."""
|
|
timestamp = datetime.now().isoformat()
|
|
report = []
|
|
report.append("\n" + "=" * 80)
|
|
report.append(f"!!! ICEYOU CRASH REPORT !!!")
|
|
report.append(f"Time: {timestamp}")
|
|
report.append(f"Thread: {thread_name}")
|
|
report.append("=" * 80)
|
|
report.append("".join(traceback.format_exception(exc_type, exc_value, exc_traceback)))
|
|
report.append("=" * 80 + "\n")
|
|
|
|
crash_text = "\n".join(report)
|
|
print(crash_text)
|
|
|
|
# Also write to a persistent crash log
|
|
try:
|
|
with open("iceyou_crash.log", "a", encoding="utf-8") as f:
|
|
f.write(crash_text)
|
|
except Exception:
|
|
pass
|
|
|
|
|
|
def global_exception_handler(exc_type, exc_value, exc_traceback):
|
|
if issubclass(exc_type, KeyboardInterrupt):
|
|
sys.__excepthook__(exc_type, exc_value, exc_traceback)
|
|
return
|
|
log_crash_report(exc_type, exc_value, exc_traceback)
|
|
|
|
|
|
def thread_exception_handler(args):
|
|
log_crash_report(args.exc_type, args.exc_value, args.exc_traceback, thread_name=args.thread.name)
|
|
|
|
|
|
# Install handlers
|
|
sys.excepthook = global_exception_handler
|
|
threading.excepthook = thread_exception_handler
|
|
|
|
|
|
def main():
|
|
print("Starting ICEYOU Personal Monitor...")
|
|
print("A system tray icon will appear. Right-click for options.")
|
|
try:
|
|
app = TrayApp()
|
|
app.run()
|
|
except Exception as e:
|
|
log_crash_report(type(e), e, e.__traceback__)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main() |