73 lines
2.4 KiB
Python
73 lines
2.4 KiB
Python
import logging
|
|
import signal
|
|
import ctypes
|
|
|
|
from PySide6 import QtCore
|
|
from PySide6.QtWidgets import QApplication
|
|
from PySide6.QtCore import QTimer
|
|
from PySide6.QtGui import QIcon
|
|
import sys
|
|
|
|
import constants
|
|
from raven.pluginregistry import PluginRegistry
|
|
|
|
import gettext
|
|
gettext.install('ravenlog', 'locale')
|
|
|
|
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)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
app = QApplication(sys.argv)
|
|
app.setWindowIcon(QIcon(constants.raven_icon)) # works only for Linux
|
|
|
|
# make icon appear in Windows
|
|
# 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':
|
|
myappid = 'opentext.ravenlog' # arbitrary string
|
|
ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(myappid)
|
|
|
|
# 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)
|
|
|
|
# init plugins
|
|
PluginRegistry.load_plugin("RavenLogPlugin")
|
|
PluginRegistry.load_plugin("OpenFilePlugin")
|
|
PluginRegistry.load_plugin("LogFilePlugin")
|
|
PluginRegistry.load_plugin("NotesPlugin")
|
|
|
|
window = PluginRegistry.execute_single("create_main_window")
|
|
window.show()
|
|
|
|
PluginRegistry.execute("after_start")
|
|
|
|
# PluginRegistry.execute("open_file",
|
|
# "/home/andi/ws/performanceDb/data/production/lt_axc_21.4_133.02_maxInstance/"
|
|
# + "lt_axc_21.4_133.02_maxInstance/app/axcng-service_i-0a69bd43d3624a5bc_172_28_"
|
|
# + "60_222_VADPERFO01AA001_2021-09-21_091717/service/service.log")
|
|
# PluginRegistry.execute("open_file",
|
|
# "testbed/example.log")
|
|
|
|
signal.signal(signal.SIGINT, stop_signal)
|
|
signal.signal(signal.SIGTERM, stop_signal)
|
|
|
|
app.exec()
|