-
-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathrun_cli.py
More file actions
49 lines (42 loc) · 1.41 KB
/
run_cli.py
File metadata and controls
49 lines (42 loc) · 1.41 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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
RenLocalizer CLI Launcher
Cross-platform command line interface
"""
import os
import sys
from pathlib import Path
# Ensure stdout uses UTF-8
try:
if hasattr(sys.stdout, "reconfigure"):
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
if hasattr(sys.stderr, "reconfigure"):
sys.stderr.reconfigure(encoding="utf-8", errors="replace")
except Exception:
pass
def setup_environment() -> None:
"""Setup environment variables and paths."""
# Suppress noisy Qt font and debug warnings (Script 20/OpenType issues)
if "QT_LOGGING_RULES" not in os.environ:
os.environ["QT_LOGGING_RULES"] = "qt.qpa.fonts=false;qt.text.font.db=false;*.debug=false"
# Add project root to Python path
project_root = Path(__file__).parent
if str(project_root) not in sys.path:
sys.path.insert(0, str(project_root))
def main() -> int:
setup_environment()
try:
from src.cli_main import main as cli_main
return cli_main()
except ImportError as e:
print(f"Error: Could not import CLI module: {e}")
print("Ensure you are running from the project root and all dependencies are installed.")
return 1
except Exception as e:
print(f"Unexpected error: {e}")
import traceback
traceback.print_exc()
return 1
if __name__ == "__main__":
sys.exit(main())