Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions BlocksScreen/BlocksScreen.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@
import sys
import typing

import logger
from lib.panels.mainWindow import MainWindow
from logger import setup_logging
from PyQt6 import QtCore, QtGui, QtWidgets

_logger = logging.getLogger(name="logs/BlocksScreen.log")
QtGui.QGuiApplication.setAttribute(
QtCore.Qt.ApplicationAttribute.AA_SynthesizeMouseForUnhandledTouchEvents,
True,
Expand All @@ -22,13 +21,6 @@
RESET = "\033[0m"


def setup_app_loggers():
"""Setup logger"""
_ = logger.create_logger(name="logs/BlocksScreen.log", level=logging.DEBUG)
_logger = logging.getLogger(name="logs/BlocksScreen.log")
_logger.info("============ BlocksScreen Initializing ============")


def show_splash(window: typing.Optional[QtWidgets.QWidget] = None):
"""Show splash screen on app initialization"""
logo = QtGui.QPixmap("BlocksScreen/BlocksScreen/lib/ui/resources/logoblocks.png")
Expand All @@ -39,7 +31,16 @@ def show_splash(window: typing.Optional[QtWidgets.QWidget] = None):


if __name__ == "__main__":
setup_app_loggers()
setup_logging(
filename="logs/BlocksScreen.log",
level=logging.DEBUG, # File gets DEBUG+
console_output=True, # Print to terminal
console_level=logging.DEBUG, # Console gets DEBUG+
capture_stderr=True, # Capture X11 errors
capture_stdout=False, # Don't capture print()
)
_logger = logging.getLogger(__name__)
_logger.info("============ BlocksScreen Initializing ============")
BlocksScreen = QtWidgets.QApplication([])
BlocksScreen.setApplicationName("BlocksScreen")
BlocksScreen.setApplicationDisplayName("BlocksScreen")
Expand Down
2 changes: 1 addition & 1 deletion BlocksScreen/lib/moonrakerComm.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from lib.utils.RepeatedTimer import RepeatedTimer
from PyQt6 import QtCore, QtWidgets

_logger = logging.getLogger(name="logs/BlocksScreen.log")
_logger = logging.getLogger(__name__)


class OneShotTokenError(Exception):
Expand Down
2 changes: 1 addition & 1 deletion BlocksScreen/lib/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from PyQt6 import QtCore
from sdbus_async import networkmanager as dbusNm

logger = logging.getLogger("logs/BlocksScreen.log")
logger = logging.getLogger(__name__)


class NetworkManagerRescanError(Exception):
Expand Down
28 changes: 12 additions & 16 deletions BlocksScreen/lib/panels/mainWindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,15 @@
from lib.moonrakerComm import MoonWebSocket
from lib.panels.controlTab import ControlTab
from lib.panels.filamentTab import FilamentTab
from lib.panels.networkWindow import NetworkControlWindow
from lib.panels.printTab import PrintTab
from lib.panels.utilitiesTab import UtilitiesTab
from lib.panels.widgets.basePopup import BasePopup
from lib.panels.widgets.connectionPage import ConnectionPage
from lib.panels.widgets.loadWidget import LoadingOverlayWidget
from lib.panels.widgets.popupDialogWidget import Popup
from lib.panels.widgets.updatePage import UpdatePage
from lib.printer import Printer
from lib.ui.mainWindow_ui import Ui_MainWindow # With header
from lib.panels.widgets.updatePage import UpdatePage
from lib.panels.widgets.basePopup import BasePopup
from lib.panels.widgets.loadWidget import LoadingOverlayWidget

# from lib.ui.mainWindow_v2_ui import Ui_MainWindow # No header
from lib.ui.resources.background_resources_rc import *
Expand All @@ -28,10 +27,11 @@
from lib.ui.resources.main_menu_resources_rc import *
from lib.ui.resources.system_resources_rc import *
from lib.ui.resources.top_bar_resources_rc import *
from logger import LogManager
from PyQt6 import QtCore, QtGui, QtWidgets
from screensaver import ScreenSaver

_logger = logging.getLogger(name="logs/BlocksScreen.log")
_logger = logging.getLogger(__name__)


def api_handler(func):
Expand Down Expand Up @@ -93,7 +93,7 @@ def __init__(self):
self.filamentPanel = FilamentTab(self.ui.filamentTab, self.printer, self.ws)
self.controlPanel = ControlTab(self.ui.controlTab, self.ws, self.printer)
self.utilitiesPanel = UtilitiesTab(self.ui.utilitiesTab, self.ws, self.printer)
self.networkPanel = NetworkControlWindow(self)
# self.networkPanel = NetworkControlWindow(self)
self.bo_ws_startup.connect(slot=self.bo_start_websocket_connection)
self.ws.connecting_signal.connect(self.conn_window.on_websocket_connecting)
self.ws.connected_signal.connect(
Expand Down Expand Up @@ -153,7 +153,7 @@ def __init__(self):
self.printer.extruder_update.connect(self.on_extruder_update)
self.printer.heater_bed_update.connect(self.on_heater_bed_update)
self.ui.main_content_widget.currentChanged.connect(slot=self.reset_tab_indexes)
self.call_network_panel.connect(self.networkPanel.show_network_panel)
# self.call_network_panel.connect(self.networkPanel.show_network_panel)
self.conn_window.wifi_button_clicked.connect(self.call_network_panel.emit)
self.ui.wifi_button.clicked.connect(self.call_network_panel.emit)
self.handle_error_response.connect(
Expand Down Expand Up @@ -352,7 +352,7 @@ def reset_tab_indexes(self):
self.filamentPanel.setCurrentIndex(0)
self.controlPanel.setCurrentIndex(0)
self.utilitiesPanel.setCurrentIndex(0)
self.networkPanel.setCurrentIndex(0)
# self.networkPanel.setCurrentIndex(0)

def current_panel_index(self) -> int:
"""Helper function to get the index of the current page in the current tab
Expand Down Expand Up @@ -687,14 +687,10 @@ def set_header_nozzle_diameter(self, diam: str):

def closeEvent(self, a0: typing.Optional[QtGui.QCloseEvent]) -> None:
"""Handles GUI closing"""
_loggers = [
logging.getLogger(name) for name in logging.root.manager.loggerDict
] # Get available logger handlers
for logger in _loggers: # noqa: F402
if hasattr(logger, "cancel"):
_callback = getattr(logger, "cancel")
if callable(_callback):
_callback()

# Shutdown logger (closes files, stops threads, restores streams)
LogManager.shutdown()

self.ws.wb_disconnect()
self.close()
if a0 is None:
Expand Down
2 changes: 1 addition & 1 deletion BlocksScreen/lib/panels/networkWindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from lib.utils.list_button import ListCustomButton
from PyQt6 import QtCore, QtGui, QtWidgets

logger = logging.getLogger("logs/BlocksScreen.log")
logger = logging.getLogger(__name__)


class BuildNetworkList(QtCore.QThread):
Expand Down
2 changes: 1 addition & 1 deletion BlocksScreen/lib/panels/printTab.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from lib.utils.display_button import DisplayButton
from PyQt6 import QtCore, QtGui, QtWidgets

logger = logging.getLogger(name="logs/BlocksScreen.log")
logger = logging.getLogger(__name__)


class PrintTab(QtWidgets.QStackedWidget):
Expand Down
5 changes: 2 additions & 3 deletions BlocksScreen/lib/panels/widgets/filesPage.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@
import helper_methods
from lib.utils.blocks_Scrollbar import CustomScrollBar
from lib.utils.icon_button import IconButton
from PyQt6 import QtCore, QtGui, QtWidgets

from lib.utils.list_model import EntryDelegate, EntryListModel, ListItem
from PyQt6 import QtCore, QtGui, QtWidgets

logger = logging.getLogger("logs/BlocksScreen.log")
logger = logging.getLogger(__name__)


class FilesPage(QtWidgets.QWidget):
Expand Down
2 changes: 1 addition & 1 deletion BlocksScreen/lib/panels/widgets/jobStatusPage.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from lib.utils.display_button import DisplayButton
from PyQt6 import QtCore, QtGui, QtWidgets

logger = logging.getLogger("logs/BlocksScreen.log")
logger = logging.getLogger(__name__)


class JobStatusWidget(QtWidgets.QWidget):
Expand Down
2 changes: 1 addition & 1 deletion BlocksScreen/lib/printer.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from lib.moonrakerComm import MoonWebSocket
from PyQt6 import QtCore, QtWidgets

logger = logging.getLogger(name="logs/BlocksScreen.logs")
logger = logging.getLogger(__name__)


class Printer(QtCore.QObject):
Expand Down
Loading
Loading