add plugin registry
This commit is contained in:
80
raven/ravenlog.py
Normal file
80
raven/ravenlog.py
Normal file
@@ -0,0 +1,80 @@
|
||||
import ctypes
|
||||
import logging
|
||||
import signal
|
||||
import sys
|
||||
from inspect import isclass
|
||||
from importlib import import_module
|
||||
from pathlib import Path
|
||||
from pkgutil import iter_modules
|
||||
|
||||
from plugins import *
|
||||
|
||||
from PyQt6 import QtCore
|
||||
from PyQt6.QtCore import QTimer
|
||||
from PyQt6.QtGui import QIcon
|
||||
from PyQt6.QtWidgets import QApplication
|
||||
|
||||
import constants
|
||||
from raven.ravenwindow import RavenWindow
|
||||
from ravenui import RavenUI
|
||||
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
log = logging.getLogger("main")
|
||||
|
||||
|
||||
def stop_signal(signum, _stackframe):
|
||||
""" Handle terminate signal """
|
||||
try:
|
||||
log.info("Terminate signal received. %s", signum)
|
||||
QtCore.QCoreApplication.quit()
|
||||
except Exception:
|
||||
log.exception("Exception occurred while terminating")
|
||||
sys.exit(1)
|
||||
sys.exit(0)
|
||||
|
||||
|
||||
def init_signal_handler():
|
||||
# workaround to make signals work in QT apps.
|
||||
# They do not work out of the box, because the main thread
|
||||
# is running in C++ code once app.exec() is executed
|
||||
# Forcing an empty lambda to be executed periodically gives
|
||||
# control back to python and allows python to react to signals
|
||||
timer = QTimer()
|
||||
timer.timeout.connect(lambda: None)
|
||||
timer.start(100)
|
||||
signal.signal(signal.SIGINT, stop_signal)
|
||||
signal.signal(signal.SIGTERM, stop_signal)
|
||||
|
||||
|
||||
def init_translator(app: QApplication):
|
||||
# translator = QTranslator()
|
||||
# if translator.load(QLocale("de"), "messages_de.ts"):
|
||||
# app.installTranslator(translator)
|
||||
pass
|
||||
|
||||
|
||||
def set_window_icon(app: QApplication):
|
||||
app.setWindowIcon(QIcon("../" + constants.raven_icon))
|
||||
|
||||
# see https://stackoverflow.com/questions/1551605/how-to-set-applications-taskbar-icon-in-windows-7/1552105#1552105
|
||||
if sys.platform == 'win32' or sys.platform == 'cygwin':
|
||||
ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID('opentext.ravenlog')
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
filterplugin = PluginRegistry.load_plugin("FilterPlugin")
|
||||
filterplugin()
|
||||
|
||||
logfileviewerplugin = PluginRegistry.load_plugin("LogFileViewerPlugin")
|
||||
logfileviewerplugin()
|
||||
|
||||
app = QApplication(sys.argv)
|
||||
set_window_icon(app)
|
||||
init_translator(app)
|
||||
init_signal_handler()
|
||||
|
||||
window = RavenWindow()
|
||||
RavenUI.window = window
|
||||
window.show()
|
||||
|
||||
app.exec()
|
||||
Reference in New Issue
Block a user