-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathmain.py
More file actions
69 lines (54 loc) · 2.03 KB
/
main.py
File metadata and controls
69 lines (54 loc) · 2.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
"""
LiveRecall - Entry Point
Launch API server or system tray application
"""
import argparse
import sys
from pathlib import Path
def is_frozen() -> bool:
"""Check if running as a frozen PyInstaller app"""
return getattr(sys, "frozen", False)
def get_app_path() -> Path:
"""Get the application root path (works for both development and frozen)"""
if is_frozen():
# PyInstaller: executable is in the app bundle
return Path(sys.executable).parent
else:
# Development: main.py location
return Path(__file__).parent
def main():
"""Main entry point"""
parser = argparse.ArgumentParser(
description="LiveRecall - Screen Recall with Semantic Search",
formatter_class=argparse.RawDescriptionHelpFormatter,
epilog="""
Examples:
python main.py # Launch system tray (default)
python main.py --tray # Launch system tray
python main.py --api-only # Launch API server only
python main.py --api-only --host 0.0.0.0 --port 8000
""",
)
parser.add_argument("--tray", action="store_true", help="Launch system tray application (default)")
parser.add_argument("--api-only", action="store_true", help="Launch API server only (no tray)")
parser.add_argument("--host", default="127.0.0.1", help="API server host (default: 127.0.0.1)")
parser.add_argument("--port", type=int, default=8742, help="API server port (default: 8742)")
parser.add_argument("--reload", action="store_true", help="Enable auto-reload for development")
args = parser.parse_args()
if args.api_only:
# Launch API server only
import uvicorn
from api.main import app
uvicorn.run(
app,
host=args.host,
port=args.port,
reload=args.reload if not is_frozen() else False,
log_level="warning", # Suppress verbose access logs
)
else:
# Launch system tray (default)
from tray.app import run_tray
run_tray()
if __name__ == "__main__":
main()