Cornea/src/app.py

49 lines
1.3 KiB
Python
Raw Normal View History

2023-03-28 02:21:28 +00:00
# Python imports
2023-04-30 16:59:20 +00:00
import signal
2023-03-28 02:21:28 +00:00
import os
# Lib imports
# Application imports
2023-04-30 16:59:20 +00:00
from utils.debugging import debug_signal_handler
2023-03-28 02:21:28 +00:00
from utils.ipc_server import IPCServer
from core.window import Window
2023-04-17 04:57:12 +00:00
2023-03-28 02:21:28 +00:00
class AppLaunchException(Exception):
...
class Application(IPCServer):
2023-04-30 16:59:20 +00:00
""" docstring for Application. """
2023-03-28 02:21:28 +00:00
def __init__(self, args, unknownargs):
super(Application, self).__init__()
2023-04-30 16:59:20 +00:00
2023-03-28 02:21:28 +00:00
if not settings.is_trace_debug():
try:
self.create_ipc_listener()
except Exception:
...
if not self.is_ipc_alive:
for arg in unknownargs + [args.new_tab,]:
2023-04-17 04:57:12 +00:00
if os.path.isfile(arg):
2023-03-28 02:21:28 +00:00
message = f"FILE|{arg}"
self.send_ipc_message(message)
raise AppLaunchException(f"{app_name} IPC Server Exists: Will send path(s) to it and close...")
2023-04-30 16:59:20 +00:00
try:
# kill -SIGUSR2 <pid> from Linux/Unix or SIGBREAK signal from Windows
signal.signal(
vars(signal).get("SIGBREAK") or vars(signal).get("SIGUSR1"),
debug_signal_handler
)
except ValueError:
# Typically: ValueError: signal only works in main thread
...
2023-03-28 02:21:28 +00:00
Window(args, unknownargs)