logging to widget works!
parent
d6bcdb9ecc
commit
841fd1cbfa
|
@ -44,16 +44,22 @@ def get_ffmpeg_version():
|
||||||
|
|
||||||
|
|
||||||
class Deployer:
|
class Deployer:
|
||||||
def __init__(self):
|
def __init__(self, logging_handler: logging.Handler = None):
|
||||||
logging.basicConfig(stream=sys.stdout, level=logging.INFO)
|
logging.basicConfig(stream=sys.stdout, level=logging.INFO)
|
||||||
self.logger = logging.getLogger()
|
self.logger = logging.getLogger()
|
||||||
|
|
||||||
|
if logging_handler is not None:
|
||||||
|
self.logger.addHandler(logging_handler)
|
||||||
|
|
||||||
self.utils_dir = "./utils"
|
self.utils_dir = "./utils"
|
||||||
self.build_dir = "./build"
|
self.build_dir = "./build"
|
||||||
self.music_dir = "./build/music"
|
self.music_dir = "./build/music"
|
||||||
self.source_dir = "./source"
|
self.source_dir = "./source"
|
||||||
self.install_dir = self.find_install_dir()
|
self.install_dir = self.find_install_dir()
|
||||||
|
|
||||||
|
def write_something(self):
|
||||||
|
self.logger.info("lalala")
|
||||||
|
|
||||||
def find_install_dir(self):
|
def find_install_dir(self):
|
||||||
self.logger.info("Trying to find Barotraumma install folder")
|
self.logger.info("Trying to find Barotraumma install folder")
|
||||||
library_folders = Path("C:\Program Files (x86)\Steam\steamapps\libraryfolders.vdf")
|
library_folders = Path("C:\Program Files (x86)\Steam\steamapps\libraryfolders.vdf")
|
||||||
|
|
|
@ -4,7 +4,6 @@ import getpass
|
||||||
import logging
|
import logging
|
||||||
import time
|
import time
|
||||||
|
|
||||||
from gui.deploy import Deployer
|
|
||||||
from tape_editor_widgets import *
|
from tape_editor_widgets import *
|
||||||
from widgets import LabelWebLink
|
from widgets import LabelWebLink
|
||||||
from deploy import Deployer, get_ffmpeg_version
|
from deploy import Deployer, get_ffmpeg_version
|
||||||
|
@ -20,7 +19,8 @@ class OptionsWidget(QWidget):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
|
||||||
self.parent = parent
|
self.parent = parent
|
||||||
self.deployer = Deployer()
|
self.logging_handler = SignalHandler()
|
||||||
|
self.deployer = Deployer(logging_handler=self.logging_handler)
|
||||||
|
|
||||||
options = [("Buffs", "Some songs affect the characters with strengthen\nand haste afflictions."),
|
options = [("Buffs", "Some songs affect the characters with strengthen\nand haste afflictions."),
|
||||||
("De-buffs", "Some songs affect the characters with psychosis \naffliction."),
|
("De-buffs", "Some songs affect the characters with psychosis \naffliction."),
|
||||||
|
@ -98,6 +98,8 @@ class OptionsWidget(QWidget):
|
||||||
# Console widget
|
# Console widget
|
||||||
self.console_widget = ConsoleWidget(self)
|
self.console_widget = ConsoleWidget(self)
|
||||||
|
|
||||||
|
self.logging_handler.emitter.log_message.connect(self.console_widget.console.appendPlainText)
|
||||||
|
|
||||||
layout = QVBoxLayout(self)
|
layout = QVBoxLayout(self)
|
||||||
layout.addWidget(self.name_gbox)
|
layout.addWidget(self.name_gbox)
|
||||||
layout.addWidget(self.tape_covers_gbox)
|
layout.addWidget(self.tape_covers_gbox)
|
||||||
|
@ -524,7 +526,9 @@ class InstallWidget(QGroupBox):
|
||||||
|
|
||||||
def download_ffmpeg_action(self):
|
def download_ffmpeg_action(self):
|
||||||
|
|
||||||
self.parent.run_process(download_ffmpeg, (self.ffmpeg_dir.directory, ))
|
self.deployer.write_something()
|
||||||
|
|
||||||
|
#self.parent.run_process(self.deployer.download_ffmpeg, ())
|
||||||
#download_ffmpeg(self.ffmpeg_dir.directory)
|
#download_ffmpeg(self.ffmpeg_dir.directory)
|
||||||
self.does_ffmpeg_exist()
|
self.does_ffmpeg_exist()
|
||||||
|
|
||||||
|
@ -569,6 +573,24 @@ class MainWindow(QMainWindow):
|
||||||
|
|
||||||
self.setCentralWidget(MainWidget())
|
self.setCentralWidget(MainWidget())
|
||||||
|
|
||||||
|
class QSignaler(QObject):
|
||||||
|
log_message = Signal(str)
|
||||||
|
|
||||||
|
|
||||||
|
class SignalHandler(logging.Handler):
|
||||||
|
"""Logging handler to emit QtSignal with log record text."""
|
||||||
|
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
super(SignalHandler, self).__init__(*args, **kwargs)
|
||||||
|
self.emitter = QSignaler()
|
||||||
|
|
||||||
|
def emit(self, logRecord):
|
||||||
|
msg = "{0}".format(logRecord.getMessage())
|
||||||
|
self.emitter.log_message.emit(msg)
|
||||||
|
# When the line below is enabled, logging is immediate/otherwise events
|
||||||
|
# on the queue will be processed when the slot has finished.
|
||||||
|
# QtGui.qApp.processEvents()
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
os.chdir("..")
|
os.chdir("..")
|
||||||
|
|
Loading…
Reference in New Issue