Python-With-Gtk-Template/src/app.py

46 lines
1.2 KiB
Python
Raw Normal View History

2022-02-25 23:53:58 +00:00
# Python imports
import os
import time
2022-02-25 23:53:58 +00:00
# Lib imports
# Application imports
2022-09-05 23:01:39 +00:00
from utils.ipc_server import IPCServer
2022-02-25 23:53:58 +00:00
from utils.settings import Settings
from core.window import Window
2022-02-25 23:53:58 +00:00
class AppLaunchException(Exception):
2022-09-05 23:01:39 +00:00
...
2022-02-25 23:53:58 +00:00
class ControllerStartExceptiom(Exception):
2022-09-05 23:01:39 +00:00
...
2022-02-25 23:53:58 +00:00
2022-09-05 23:01:39 +00:00
class Application(IPCServer):
2022-02-25 23:53:58 +00:00
''' Create Settings and Controller classes. Bind signal to Builder. Inherit from Builtins to bind global methods and classes.'''
def __init__(self, args, unknownargs):
2022-09-05 23:01:39 +00:00
super(Application, self).__init__()
if args.debug == "true":
settings.set_debug(True)
if args.trace_debug == "true":
settings.set_trace_debug(True)
2022-02-25 23:53:58 +00:00
if not settings.is_trace_debug():
2022-09-05 23:01:39 +00:00
self.create_ipc_listener()
time.sleep(0.05)
if not self.is_ipc_alive:
2022-02-25 23:53:58 +00:00
if unknownargs:
for arg in unknownargs:
if os.path.isdir(arg):
message = f"FILE|{arg}"
2022-09-05 23:01:39 +00:00
self.send_ipc_message(message)
2022-02-25 23:53:58 +00:00
raise AppLaunchException(f"IPC Server Exists: Will send path(s) to it and close...\nNote: If no fm exists, remove /tmp/{app_name}-ipc.sock")
2022-02-25 23:53:58 +00:00
Window(args, unknownargs)