-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathclipse-gui.py
executable file
·60 lines (48 loc) · 1.75 KB
/
clipse-gui.py
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
#!/usr/bin/env python3
import gi
import os
import sys
import logging
from pathlib import Path
# Ensure necessary GTK version
gi.require_version("Gtk", "3.0")
from gi.repository import Gtk # noqa: E402, F401
# Set up basic logging
logging.basicConfig(
level=logging.INFO,
format="\033[1;37m%(asctime)s\033[0m - \033[1;34m%(name)s\033[0m - \033[1;32m%(levelname)s\033[0m - %(message)s",
)
log = logging.getLogger(__name__)
# Ensure the package directory is importable if running directly
PACKAGE_PARENT = ".."
SCRIPT_DIR = os.path.dirname(
os.path.realpath(os.path.join(os.getcwd(), os.path.expanduser(__file__)))
)
sys.path.append(os.path.normpath(os.path.join(SCRIPT_DIR, PACKAGE_PARENT)))
try:
# Import the Gtk.Application subclass, not the controller directly
from clipse_gui.app import ClipseGuiApplication
from clipse_gui.constants import CONFIG_DIR
except ImportError as e:
log.critical(f"Error importing application modules: {e}")
log.critical(
"Please ensure the application structure is correct and all dependencies are installed."
)
sys.exit(1)
def main():
# Ensure XDG config directory exists
try:
Path(CONFIG_DIR).mkdir(parents=True, exist_ok=True)
except OSError as e:
log.error(f"Error creating config directory {CONFIG_DIR}: {e}")
# Allow running even if config dir creation fails? Might work read-only.
# sys.exit(1) # Exit if config is critical
log.info(f"Using config directory: {CONFIG_DIR}")
# Instantiate the Gtk.Application
app = ClipseGuiApplication()
# Run the application's main loop
exit_status = app.run(sys.argv)
log.info(f"Application exited with status {exit_status}.")
sys.exit(exit_status)
if __name__ == "__main__":
main()