Refactor logging setup across multiple modules to use loguru with consistent configuration
- Updated logging initialization in MessageCalendar, admin_edit_prof, elsa_main, graph, iconLine, searchPage, and richtext modules to use loguru. - Changed log rotation and retention settings for log files to improve log management. - Replaced logger.debug/info calls with log.debug/info for consistency. - Fixed a typo in the searchPage UI and updated related references in the UI files. - Removed unused imports and cleaned up code for better readability.
This commit is contained in:
@@ -1,32 +1,31 @@
|
||||
__all__ = [
|
||||
"add_bookdata_ui",
|
||||
"edit_bookdata_ui",
|
||||
"login_ui",
|
||||
"BookDataUI",
|
||||
"LoginDialog",
|
||||
"Mail_Dialog",
|
||||
"MailTemplateDialog",
|
||||
"medienadder_ui",
|
||||
"parsed_titles_ui",
|
||||
"MedienAdder",
|
||||
"ParsedTitles",
|
||||
"popus_confirm",
|
||||
"reminder_ui",
|
||||
"Settings",
|
||||
"ReminderDialog",
|
||||
"About",
|
||||
"ElsaGenConfirm",
|
||||
"ElsaAddEntry",
|
||||
"ApparatExtendDialog",
|
||||
"DocumentPrintDialog",
|
||||
"Settings",
|
||||
]
|
||||
from .bookdata import BookDataUI as edit_bookdata_ui
|
||||
from .login import LoginDialog as login_ui
|
||||
from .bookdata import BookDataUI
|
||||
from .login import LoginDialog
|
||||
from .mail import Mail_Dialog
|
||||
from .mailTemplate import MailTemplateDialog
|
||||
from .medienadder import MedienAdder as medienadder_ui
|
||||
from .parsed_titles import ParsedTitles as parsed_titles_ui
|
||||
from .medienadder import MedienAdder
|
||||
from .parsed_titles import ParsedTitles
|
||||
from .popup_confirm import ConfirmDialog as popus_confirm
|
||||
from .reminder import ReminderDialog as reminder_ui
|
||||
from .reminder import ReminderDialog
|
||||
from .about import About
|
||||
from .elsa_gen_confirm import ElsaGenConfirm
|
||||
from .elsa_add_entry import ElsaAddEntry
|
||||
from .app_ext import ApparatExtendDialog
|
||||
from .docuprint import DocumentPrintDialog, launch
|
||||
from .docuprint import DocumentPrintDialog
|
||||
|
||||
from .settings import Settings
|
||||
|
||||
@@ -118,7 +118,7 @@ class ElsaAddEntry(QtWidgets.QDialog, Ui_Dialog):
|
||||
if table["type"] == "zs":
|
||||
book = zot.createBook(table["isbn"])
|
||||
res_key = zot.createJournalArticle(book, table)
|
||||
logger.debug(book)
|
||||
log.debug(book)
|
||||
a_lastname = table["section_author"].split(";")[0].strip().split(",")[0]
|
||||
a_firstname = table["section_author"].split(";")[0].strip().split(",")[1]
|
||||
author = f"{a_lastname}, {a_firstname[0]}"
|
||||
|
||||
@@ -6,18 +6,15 @@ from PyQt6 import QtCore, QtWidgets
|
||||
from src.backend.admin_console import AdminCommands
|
||||
from src.backend.database import Database
|
||||
|
||||
from .dialog_sources.Ui_login import Ui_Dialog
|
||||
from .dialog_sources.login_ui import Ui_Dialog
|
||||
import sys
|
||||
from loguru import logger as log
|
||||
import loguru
|
||||
from src import Icon
|
||||
|
||||
logger = log
|
||||
logger.remove()
|
||||
logger.add("logs/application.log", rotation="1 week", retention="1 month", enqueue=True)
|
||||
|
||||
|
||||
# logger.add(sys.stderr, format="{time} {level} {message}", level="INFO")
|
||||
logger.add(sys.stdout)
|
||||
log = loguru.logger
|
||||
log.remove()
|
||||
log.add(sys.stdout)
|
||||
log.add("logs/application.log", rotation="1 MB", retention="10 days")
|
||||
|
||||
|
||||
class LoginDialog(Ui_Dialog):
|
||||
@@ -86,7 +83,7 @@ class LoginDialog(Ui_Dialog):
|
||||
if self.db.login(username, hashed_password):
|
||||
self.lresult = 1 # Indicate successful login
|
||||
self.lusername = username
|
||||
logger.success(f"User {username} logged in.")
|
||||
log.success(f"User {username} logged in.")
|
||||
self.dialog.accept()
|
||||
|
||||
else:
|
||||
|
||||
@@ -8,21 +8,14 @@ from src import Icon, settings as config
|
||||
|
||||
from .dialog_sources.Ui_mail_preview import Ui_eMailPreview as MailPreviewDialog
|
||||
from .mailTemplate import MailTemplateDialog
|
||||
import loguru
|
||||
import sys
|
||||
from loguru import logger as log
|
||||
|
||||
logger = log
|
||||
logger.remove()
|
||||
logger.add("logs/application.log", rotation="1 week", retention="1 month", enqueue=True)
|
||||
log.add(
|
||||
"logs/mail.log",
|
||||
rotation="1 day",
|
||||
compression="zip",
|
||||
enqueue=True,
|
||||
)
|
||||
log = loguru.logger
|
||||
log.remove()
|
||||
log.add(sys.stdout)
|
||||
log.add("logs/application.log", rotation="1 MB", retention="10 days")
|
||||
|
||||
# logger.add(sys.stderr, format="{time} {level} {message}", level="INFO")
|
||||
logger.add(sys.stdout)
|
||||
|
||||
|
||||
empty_signature = """<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
||||
@@ -60,7 +53,7 @@ class Mail_Dialog(QtWidgets.QDialog, MailPreviewDialog):
|
||||
super().__init__(parent)
|
||||
self.setupUi(self)
|
||||
|
||||
logger.info("Setting up mail dialog")
|
||||
log.info("Setting up mail dialog")
|
||||
self.appid = app_id
|
||||
self.appname = app_name
|
||||
self.subject = app_subject
|
||||
@@ -92,7 +85,7 @@ class Mail_Dialog(QtWidgets.QDialog, MailPreviewDialog):
|
||||
self.btn_okay.clicked.connect(self.createAndSendMail)
|
||||
|
||||
def open_new_template(self):
|
||||
logger.info("Opening new template dialog")
|
||||
log.info("Opening new template dialog")
|
||||
# TODO: implement new mail template dialog
|
||||
dialog = MailTemplateDialog()
|
||||
dialog.updateSignal.connect(self.load_mail_templates)
|
||||
@@ -111,9 +104,9 @@ Tel.: 0761/682-778 | 07617682-545"""
|
||||
|
||||
def load_mail_templates(self):
|
||||
# print("loading mail templates")
|
||||
logger.info("Loading mail templates")
|
||||
log.info("Loading mail templates")
|
||||
mail_templates = os.listdir("mail_vorlagen")
|
||||
logger.info(f"Mail templates: {mail_templates}")
|
||||
log.info(f"Mail templates: {mail_templates}")
|
||||
self.comboBox.clear()
|
||||
for template in mail_templates:
|
||||
self.comboBox.addItem(template)
|
||||
@@ -132,10 +125,10 @@ Tel.: 0761/682-778 | 07617682-545"""
|
||||
return f"Guten Tag {name},"
|
||||
|
||||
def set_mail(self):
|
||||
logger.info("Setting mail")
|
||||
log.info("Setting mail")
|
||||
email_template = self.comboBox.currentText()
|
||||
if email_template == "":
|
||||
logger.debug("No mail template selected")
|
||||
log.debug("No mail template selected")
|
||||
return
|
||||
with open(f"mail_vorlagen/{email_template}", "r", encoding="utf-8") as f:
|
||||
mail_template = f.read()
|
||||
@@ -160,7 +153,7 @@ Tel.: 0761/682-778 | 07617682-545"""
|
||||
self.mail_body.setHtml(mail_html)
|
||||
|
||||
def createAndSendMail(self):
|
||||
logger.info("Sending mail")
|
||||
log.info("Sending mail")
|
||||
import smtplib
|
||||
from email.mime.multipart import MIMEMultipart
|
||||
from email.mime.text import MIMEText
|
||||
@@ -197,7 +190,7 @@ Tel.: 0761/682-778 | 07617682-545"""
|
||||
# print("Mail sent")
|
||||
# end active process
|
||||
server.quit()
|
||||
logger.info("Mail sent, closing connection to server and dialog")
|
||||
log.info("Mail sent, closing connection to server and dialog")
|
||||
# close the dialog
|
||||
|
||||
self.accept()
|
||||
|
||||
@@ -52,7 +52,7 @@ class MailTemplateDialog(QtWidgets.QDialog, NewMailTemplateDesignerDialog):
|
||||
self.buttonBox.button(
|
||||
QtWidgets.QDialogButtonBox.StandardButton.Cancel
|
||||
).clicked.connect(self.closeNow)
|
||||
logger.info("Mail template dialog setup complete")
|
||||
log.info("Mail template dialog setup complete")
|
||||
|
||||
def save_template(self):
|
||||
# print("save triggered")
|
||||
@@ -66,11 +66,11 @@ class MailTemplateDialog(QtWidgets.QDialog, NewMailTemplateDesignerDialog):
|
||||
dialog.setWindowIcon(Icon("save").icon)
|
||||
save = dialog.exec()
|
||||
template_name = dialog.textValue()
|
||||
logger.info("Saving template")
|
||||
log.info("Saving template")
|
||||
if template_name != "" and save == 1:
|
||||
template = template_name + ".eml"
|
||||
if template in os.listdir("mail_vorlagen"):
|
||||
logger.error("Template already exists")
|
||||
log.error("Template already exists")
|
||||
# warning dialog
|
||||
dialog = QtWidgets.QMessageBox()
|
||||
dialog.setIcon(QtWidgets.QMessageBox.Icon.Warning)
|
||||
@@ -110,7 +110,7 @@ Content-Transfer-Encoding: 8bit
|
||||
f.write(mail)
|
||||
self.updateSignal.emit()
|
||||
self.close()
|
||||
logger.success(f"Template {template} saved successfully")
|
||||
log.success(f"Template {template} saved successfully")
|
||||
else:
|
||||
# warning dialog
|
||||
dialog = QtWidgets.QMessageBox()
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
from PyQt6 import QtCore, QtGui, QtWidgets
|
||||
|
||||
from .dialog_sources.Ui_medianadder import Ui_Dialog
|
||||
from .dialog_sources.medianadder_ui import Ui_Dialog
|
||||
from src import Icon
|
||||
|
||||
|
||||
|
||||
@@ -3,15 +3,14 @@ from PyQt6 import QtWidgets
|
||||
from src.backend import AutoAdder
|
||||
|
||||
|
||||
from .dialog_sources.Ui_parsed_titles import Ui_Form
|
||||
from .dialog_sources.parsed_titles_ui import Ui_Form
|
||||
import loguru
|
||||
import sys
|
||||
|
||||
log = loguru.logger
|
||||
log.remove()
|
||||
log.add("application.log", rotation="1 week", retention="1 month")
|
||||
log.add(sys.stdout, level="INFO")
|
||||
|
||||
log.add(sys.stdout)
|
||||
log.add("logs/application.log", rotation="1 MB", retention="10 days")
|
||||
|
||||
class ParsedTitles(QtWidgets.QWidget, Ui_Form):
|
||||
def __init__(self, parent=None):
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
from PyQt6 import QtWidgets
|
||||
|
||||
from .dialog_sources.Ui_reminder import Ui_Erinnerung as Ui_Dialog
|
||||
from .dialog_sources.reminder_ui import Ui_Erinnerung as Ui_Dialog
|
||||
from src import Icon
|
||||
import datetime as date
|
||||
|
||||
|
||||
@@ -1,19 +1,15 @@
|
||||
from PyQt6 import QtCore, QtGui, QtWidgets
|
||||
from src import Icon, settings
|
||||
from .dialog_sources.Ui_settings import Ui_Dialog as _settings
|
||||
from .dialog_sources.settings_ui import Ui_Dialog as _settings
|
||||
from src.ui.widgets.iconLine import IconWidget
|
||||
import loguru
|
||||
import sys
|
||||
from loguru import logger as log
|
||||
|
||||
logger = log
|
||||
logger.remove()
|
||||
logger.add("logs/application.log", rotation="1 week", retention="1 month", enqueue=True)
|
||||
log.add(
|
||||
f"logs/settings.log",
|
||||
)
|
||||
log = loguru.logger
|
||||
log.remove()
|
||||
log.add(sys.stdout)
|
||||
log.add("logs/application.log", rotation="1 MB", retention="10 days")
|
||||
|
||||
# logger.add(sys.stderr, format="{time} {level} {message}", level="INFO")
|
||||
logger.add(sys.stdout)
|
||||
|
||||
|
||||
base = """'<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
||||
@@ -80,7 +76,7 @@ class Settings(QtWidgets.QDialog, _settings):
|
||||
self.toolBox.setItemIcon(2, Icon("mail").icon)
|
||||
self.toolBox.setItemIcon(3, Icon("icons").icon)
|
||||
|
||||
logger.info("Settings dialog opened, data loaded")
|
||||
log.info("Settings dialog opened, data loaded")
|
||||
|
||||
def load_config(self):
|
||||
self.db_name.setText(settings.database.name)
|
||||
@@ -117,7 +113,7 @@ class Settings(QtWidgets.QDialog, _settings):
|
||||
self.vertical_icons.addWidget(icon_widget)
|
||||
|
||||
def change_color(self, lineedit):
|
||||
logger.debug("Changing color for {}", lineedit.text())
|
||||
log.debug("Changing color for {}", lineedit.text())
|
||||
colorDialog = QtWidgets.QColorDialog()
|
||||
colorDialog.setSizePolicy()
|
||||
color = colorDialog.getColor()
|
||||
@@ -191,7 +187,7 @@ class Settings(QtWidgets.QDialog, _settings):
|
||||
self.save_path.setText(file_dialog.selectedFiles()[0])
|
||||
|
||||
def debug_mode(self):
|
||||
logger.debug(self.editSignature.toHtml())
|
||||
log.debug(self.editSignature.toHtml())
|
||||
|
||||
def return_data(self):
|
||||
port = self.smtp_port.text()
|
||||
|
||||
@@ -505,7 +505,7 @@
|
||||
<enum>Qt::NoFocus</enum>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Apparatsdetails</string>
|
||||
<string>SemesterApparatsdetails</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Form implementation generated from reading ui file 'c:\Users\aky547\GitHub\SemesterapparatsManager\src\ui\semesterapparat_ui.ui'
|
||||
#
|
||||
# Created by: PyQt6 UI code generator 6.8.0
|
||||
# Created by: PyQt6 UI code generator 6.9.0
|
||||
#
|
||||
# WARNING: Any manual changes made to this file will be lost when pyuic6 is
|
||||
# run again. Do not edit this file unless you know what you are doing.
|
||||
@@ -922,7 +922,7 @@ class Ui_MainWindow(object):
|
||||
item = self.tableWidget_apparat_media.horizontalHeaderItem(6)
|
||||
item.setText(_translate("MainWindow", "Link"))
|
||||
self.label.setText(_translate("MainWindow", " Medienliste"))
|
||||
self.app_group_box.setTitle(_translate("MainWindow", "Apparatsdetails"))
|
||||
self.app_group_box.setTitle(_translate("MainWindow", "SemesterApparatsdetails"))
|
||||
item = self.document_list.horizontalHeaderItem(0)
|
||||
item.setText(_translate("MainWindow", "Dokumentname"))
|
||||
item = self.document_list.horizontalHeaderItem(1)
|
||||
|
||||
@@ -32,15 +32,15 @@ from src.logic import (
|
||||
)
|
||||
from src.ui.dialogs import (
|
||||
popus_confirm,
|
||||
medienadder_ui,
|
||||
MedienAdder,
|
||||
About,
|
||||
ApparatExtendDialog,
|
||||
Mail_Dialog,
|
||||
Settings,
|
||||
edit_bookdata_ui,
|
||||
login_ui,
|
||||
parsed_titles_ui,
|
||||
reminder_ui,
|
||||
BookDataUI,
|
||||
LoginDialog,
|
||||
ParsedTitles,
|
||||
ReminderDialog,
|
||||
DocumentPrintDialog,
|
||||
)
|
||||
from src.ui.widgets import (
|
||||
@@ -55,28 +55,27 @@ from src.ui.widgets import (
|
||||
)
|
||||
|
||||
from datetime import datetime
|
||||
from loguru import logger as log
|
||||
|
||||
logger = log
|
||||
logger.remove()
|
||||
logger.add("logs/application.log", rotation="1 week", enqueue=True)
|
||||
import loguru
|
||||
|
||||
log = loguru.logger
|
||||
log.remove()
|
||||
log.add(sys.stdout)
|
||||
log.add("logs/application.log", rotation="1 MB", retention="10 days")
|
||||
|
||||
log.add(
|
||||
f"logs/{datetime.now().strftime('%Y-%m-%d')}.log",
|
||||
rotation="1 day",
|
||||
compression="zip",
|
||||
retention="1 month",
|
||||
)
|
||||
|
||||
# logger.add(sys.stderr, format="{time} {level} {message}", level="INFO")
|
||||
logger.add(sys.stdout)
|
||||
|
||||
|
||||
valid_input = (0, 0, 0, 0, 0, 0)
|
||||
|
||||
|
||||
class Ui(Ui_Semesterapparat):
|
||||
# use the Ui_MainWindow class from mainwindow.py
|
||||
def __init__(self, MainWindow, username: str) -> None: # type:ignore
|
||||
logger.info("Starting Semesterapparatsmanagement")
|
||||
log.info("Starting Semesterapparatsmanagement")
|
||||
super().__init__()
|
||||
self.active_user = username
|
||||
self.setupUi(MainWindow) # type:ignore
|
||||
@@ -116,7 +115,6 @@ class Ui(Ui_Semesterapparat):
|
||||
self.tableWidget_apparate.horizontalHeader().setSectionResizeMode( # type:ignore
|
||||
QtWidgets.QHeaderView.ResizeMode.Stretch
|
||||
)
|
||||
self.tableWidget_apparate.setSortingEnabled(True)
|
||||
self.saveandcreate.hide()
|
||||
|
||||
# Actions
|
||||
@@ -142,7 +140,7 @@ class Ui(Ui_Semesterapparat):
|
||||
self.prof_tel_nr.setValidator(
|
||||
QtGui.QRegularExpressionValidator(QtCore.QRegularExpression(r"^\d{3,14}"))
|
||||
)
|
||||
# #logger.debug(self.prof_tel_nr.maxLength())
|
||||
# #log.debug(self.prof_tel_nr.maxLength())
|
||||
self.app_fach.setValidator( # validator to allow typing in the app_fach field
|
||||
QtGui.QRegularExpressionValidator(
|
||||
QtCore.QRegularExpression(r"[a-zA-Z0-9\s\W]+")
|
||||
@@ -160,7 +158,7 @@ class Ui(Ui_Semesterapparat):
|
||||
)
|
||||
self.tableWidget_apparate.doubleClicked.connect(self.load_app_data) # type:ignore
|
||||
|
||||
# #logger.debug(f"user:{self.active_user}")
|
||||
# #log.debug(f"user:{self.active_user}")
|
||||
userrole = self.db.getRole(self.active_user)
|
||||
# hide admin interface when non-admin is logged in
|
||||
if userrole == "admin":
|
||||
@@ -239,7 +237,7 @@ class Ui(Ui_Semesterapparat):
|
||||
self.admin_action.setTitle("")
|
||||
|
||||
# Create instances to be used by the threads in the application
|
||||
self.bookGrabber = []
|
||||
self.bookGrabber: list[QThread] = []
|
||||
self.availChecker = None
|
||||
self.mail_thread = None
|
||||
self.autoGrabber = None
|
||||
@@ -260,7 +258,7 @@ class Ui(Ui_Semesterapparat):
|
||||
self.valid_check_semester.clicked.connect(self.display_valid_semester) # type:ignore
|
||||
|
||||
def create_doc(self):
|
||||
logger.debug("Creating document")
|
||||
log.debug("Creating document")
|
||||
# open DocumentPrintDialog
|
||||
dialog = DocumentPrintDialog(self.MainWindow)
|
||||
dialog.show()
|
||||
@@ -332,7 +330,7 @@ class Ui(Ui_Semesterapparat):
|
||||
self.app_fach.addItems([subject[1] for subject in self.db.getSubjects()])
|
||||
|
||||
def open_documentation(self):
|
||||
logger.info("Opening Documentation")
|
||||
log.info("Opening Documentation")
|
||||
if not self.docu.isRunning():
|
||||
self.docu.start()
|
||||
webbrowser.open("http://localhost:8000")
|
||||
@@ -357,7 +355,7 @@ class Ui(Ui_Semesterapparat):
|
||||
statistics.updateCalendar.connect(self.update_calendar)
|
||||
stats_layout.addWidget(statistics)
|
||||
|
||||
# #logger.debug("searchpage")
|
||||
# #log.debug("searchpage")
|
||||
if self.tabWidget.currentIndex() == 0: # Apparate
|
||||
# clear all entries from the table
|
||||
self.tableWidget_apparate.setRowCount(0)
|
||||
@@ -375,7 +373,7 @@ class Ui(Ui_Semesterapparat):
|
||||
widget.deleteLater()
|
||||
|
||||
elsa_layout.addWidget(ElsaDialog())
|
||||
# logger.debug("added")
|
||||
# log.debug("added")
|
||||
pass
|
||||
|
||||
def generateSemester(self, today=False):
|
||||
@@ -418,9 +416,9 @@ class Ui(Ui_Semesterapparat):
|
||||
self.prof_mail.setText(appdata.prof.mail)
|
||||
self.prof_tel_nr.setText(appdata.prof.telnr)
|
||||
self.app_name.setText(appdata.apparat.name)
|
||||
# #logger.debug("changing dropdown app_fach from '' to ", appdata.app_fach)
|
||||
# #log.debug("changing dropdown app_fach from '' to ", appdata.app_fach)
|
||||
self.app_fach.setCurrentText(appdata.apparat.subject)
|
||||
# #logger.debug("changed dropdown app_fach to ", self.app_fach.currentText())
|
||||
# #log.debug("changed dropdown app_fach to ", self.app_fach.currentText())
|
||||
self.sem_year.setText(appdata.apparat.get_semester.split(" ")[1])
|
||||
match appdata.apparat.get_semester.split(" ")[0]:
|
||||
case "SoSe":
|
||||
@@ -485,7 +483,7 @@ class Ui(Ui_Semesterapparat):
|
||||
return popup.result()
|
||||
|
||||
def thread_check(self):
|
||||
# #logger.debug("Thread started")
|
||||
# #log.debug("Thread started")
|
||||
self.prof_mail.textChanged.connect(self.validate_prof_mail)
|
||||
self.drpdwn_prof_name.editTextChanged.connect(self.validate_prof_name)
|
||||
self.prof_tel_nr.textChanged.connect(self.validate_prof_tel)
|
||||
@@ -596,7 +594,7 @@ class Ui(Ui_Semesterapparat):
|
||||
return
|
||||
selected_prof = self.drpdwn_prof_name.currentText()
|
||||
data = self.db.getProfData(selected_prof)
|
||||
# logger.debug(data)
|
||||
# log.debug(data)
|
||||
prof_title = data.title
|
||||
if prof_title == "None":
|
||||
prof_title = "Kein Titel"
|
||||
@@ -700,20 +698,20 @@ class Ui(Ui_Semesterapparat):
|
||||
|
||||
def update_progress_label(self, curr: int, total: int):
|
||||
text = f"Medium {curr}/{total}"
|
||||
logger.info(text)
|
||||
log.info(text)
|
||||
self.progress_label.setText(text)
|
||||
# update tableWidget_apparat_media
|
||||
self.update_app_media_list()
|
||||
|
||||
def hide_progress_label(self):
|
||||
logger.info("Finished adding media, hiding progress label")
|
||||
log.info("Finished adding media, hiding progress label")
|
||||
self.progress_label.hide()
|
||||
self.progress_label.setText("Bitte warten...")
|
||||
self.line_2.hide()
|
||||
self.label_info.hide()
|
||||
|
||||
def btn_add_medium(self):
|
||||
media = medienadder_ui()
|
||||
media = MedienAdder()
|
||||
media.exec()
|
||||
mode = media.mode
|
||||
data = media.data
|
||||
@@ -733,7 +731,7 @@ class Ui(Ui_Semesterapparat):
|
||||
|
||||
app_id = self.active_apparat
|
||||
prof_id = self.db.getProfId(self.profdata)
|
||||
logger.debug(prof_id)
|
||||
log.debug(prof_id)
|
||||
# check if app_id is in database
|
||||
if self.db.checkApparatExistsById(app_id) is False:
|
||||
# create apparat
|
||||
@@ -756,7 +754,7 @@ class Ui(Ui_Semesterapparat):
|
||||
|
||||
bookGrabber.start()
|
||||
while bookGrabber.isRunning():
|
||||
# #logger.debug("waiting for thread to finish")
|
||||
# #log.debug("waiting for thread to finish")
|
||||
QtWidgets.QApplication.processEvents()
|
||||
|
||||
# self.__clear_fields()
|
||||
@@ -802,7 +800,7 @@ class Ui(Ui_Semesterapparat):
|
||||
|
||||
# thread = QThread()
|
||||
appnumber = self.active_apparat
|
||||
# #logger.debug(links)
|
||||
# #log.debug(links)
|
||||
self.availChecker = AvailChecker(links, appnumber, books=books)
|
||||
# availcheck.moveToThread(thread)
|
||||
# availcheck.finished.connect(thread.quit)
|
||||
@@ -851,7 +849,7 @@ class Ui(Ui_Semesterapparat):
|
||||
app_id, prof_id, deleted
|
||||
)
|
||||
|
||||
# # #logger.debug(books)
|
||||
# # #log.debug(books)
|
||||
# take the dataclass from the tuple
|
||||
# booklist:list[BookData]=[book[0] for book in books]
|
||||
self.tableWidget_apparat_media.setRowCount(0)
|
||||
@@ -860,7 +858,7 @@ class Ui(Ui_Semesterapparat):
|
||||
book_data = book["bookdata"]
|
||||
availability = book["available"]
|
||||
# bd = BookData().from_string(book)
|
||||
# # #logger.debug(bd, type(bd))
|
||||
# # #log.debug(bd, type(bd))
|
||||
# create a new row below the last one
|
||||
self.tableWidget_apparat_media.insertRow(
|
||||
self.tableWidget_apparat_media.rowCount()
|
||||
@@ -954,11 +952,11 @@ class Ui(Ui_Semesterapparat):
|
||||
self.drpdwn_prof_name.addItem(prof)
|
||||
|
||||
def add_document(self):
|
||||
# #logger.debug("Add document")
|
||||
# #log.debug("Add document")
|
||||
picker = FilePicker()
|
||||
files = picker.pick_files()
|
||||
for file in files:
|
||||
# #logger.debug(file)
|
||||
# #log.debug(file)
|
||||
filename = file.split("/")[-1]
|
||||
filetype = filename.split(".")[-1]
|
||||
self.document_list.insertRow(0)
|
||||
@@ -1008,7 +1006,7 @@ class Ui(Ui_Semesterapparat):
|
||||
|
||||
def __open_dialog(signatures: list[str]):
|
||||
dialog = QtWidgets.QDialog()
|
||||
frame = parsed_titles_ui()
|
||||
frame = ParsedTitles()
|
||||
frame.setupUi(dialog)
|
||||
dialog.show()
|
||||
frame.signatures = signatures
|
||||
@@ -1030,7 +1028,7 @@ class Ui(Ui_Semesterapparat):
|
||||
else:
|
||||
# if file is selected, check for books in the file
|
||||
if self.document_list.currentRow() != -1:
|
||||
# #logger.debug("File selected")
|
||||
# #log.debug("File selected")
|
||||
file = self.document_list.item(
|
||||
self.document_list.currentRow(), 3
|
||||
).text()
|
||||
@@ -1084,7 +1082,7 @@ class Ui(Ui_Semesterapparat):
|
||||
bookdata=book, app_id=app_id, prof_id=prof_id
|
||||
)
|
||||
self.update_app_media_list()
|
||||
# #logger.debug(len(signatures))
|
||||
# #log.debug(len(signatures))
|
||||
|
||||
def extract_document_data(self) -> Union[list[str], SemapDocument]:
|
||||
file_type = self.document_list.item(self.document_list.currentRow(), 1).text()
|
||||
@@ -1093,7 +1091,7 @@ class Ui(Ui_Semesterapparat):
|
||||
).text()
|
||||
file_name = self.document_list.item(self.document_list.currentRow(), 0).text()
|
||||
file = file_location
|
||||
logger.info("File selected: {}, {}", file_name, file_location)
|
||||
log.info("File selected: {}, {}", file_name, file_location)
|
||||
if file_location == "Database":
|
||||
# create warning, then return
|
||||
self.db.recreateFile(file_name, self.active_apparat, filetype=file_type)
|
||||
@@ -1107,8 +1105,8 @@ class Ui(Ui_Semesterapparat):
|
||||
return signatures
|
||||
if file_type == "docx":
|
||||
data = word_to_semap(file)
|
||||
logger.info("Converted data from semap file")
|
||||
logger.debug("Got the data: {}", data)
|
||||
log.info("Converted data from semap file")
|
||||
log.debug("Got the data: {}", data)
|
||||
|
||||
return data
|
||||
|
||||
@@ -1132,17 +1130,17 @@ class Ui(Ui_Semesterapparat):
|
||||
for runner in self.bookGrabber:
|
||||
if not runner.isRunning():
|
||||
runner.deleteLater()
|
||||
# #logger.debug("Checking file")
|
||||
# #log.debug("Checking file")
|
||||
# get active app_id and prof_id
|
||||
self.tableWidget_apparate.setEnabled(False)
|
||||
self.tableWidget_apparate.setToolTip(
|
||||
"Bitte warten, bis alle Medien hinzugefügt wurden"
|
||||
)
|
||||
app_id = self.active_apparat
|
||||
logger.debug(self.profdata)
|
||||
log.debug(self.profdata)
|
||||
prof_id = self.db.getProfId(self.profdata)
|
||||
|
||||
logger.debug("Prof id: {}", prof_id)
|
||||
log.debug("Prof id: {}", prof_id)
|
||||
# check if apparat in database
|
||||
if prof_id is None:
|
||||
prof = Prof(
|
||||
@@ -1155,28 +1153,28 @@ class Ui(Ui_Semesterapparat):
|
||||
self.db.createProf(prof)
|
||||
# if app_id not in database, create apparat
|
||||
if not self.db.checkApparatExistsById(app_id):
|
||||
logger.info("Apparat does not exist, creating new apparat")
|
||||
log.info("Apparat does not exist, creating new apparat")
|
||||
# create apparat
|
||||
# #logger.debug("Creating apparat")
|
||||
# #log.debug("Creating apparat")
|
||||
if not self.btn_save_apparat(False):
|
||||
return
|
||||
|
||||
if self.document_list.rowCount() == 0:
|
||||
logger.info("No file selected")
|
||||
log.info("No file selected")
|
||||
self.tableWidget_apparate.setEnabled(True)
|
||||
self.tableWidget_apparate.setToolTip("")
|
||||
return
|
||||
else:
|
||||
# if file is selected, check for books in the file
|
||||
# #logger.debug("File selected")
|
||||
# #log.debug("File selected")
|
||||
|
||||
if prof_id is None:
|
||||
prof_id = self.db.getProfId(self.profdata)
|
||||
|
||||
# logger.debug("Prof ID is None", prof_id)
|
||||
# log.debug("Prof ID is None", prof_id)
|
||||
document = self.extract_document_data()
|
||||
if document is None:
|
||||
logger.error("Document is None")
|
||||
log.error("Document is None")
|
||||
elif isinstance(document, SemapDocument):
|
||||
signatures = document.signatures
|
||||
else:
|
||||
@@ -1287,7 +1285,7 @@ class Ui(Ui_Semesterapparat):
|
||||
pid=appd.prof.fullname,
|
||||
)
|
||||
if clear_fields:
|
||||
# #logger.debug("clearing fields")
|
||||
# #log.debug("clearing fields")
|
||||
self.__clear_fields()
|
||||
return True
|
||||
|
||||
@@ -1346,10 +1344,10 @@ class Ui(Ui_Semesterapparat):
|
||||
|
||||
for apparat in self.apparats:
|
||||
self.insert_apparat_into_table(apparat)
|
||||
logger.info("Inserted {} apparats into table".format(len(self.apparats)))
|
||||
log.info("Inserted {} apparats into table".format(len(self.apparats)))
|
||||
|
||||
def insert_apparat_into_table(self, apparat):
|
||||
# logger.debug(apparat)
|
||||
# log.debug(apparat)
|
||||
def __dauer_check(apparat):
|
||||
return "Ja" if apparat[7] == 1 else "Nein"
|
||||
|
||||
@@ -1398,7 +1396,7 @@ class Ui(Ui_Semesterapparat):
|
||||
return
|
||||
app_id = self.tableWidget_apparate.item(row, 0).text()
|
||||
pid = self.db.getProfIDByApparat(app_id)
|
||||
logger.debug(app_id, pid)
|
||||
log.debug(app_id, pid)
|
||||
delete_action.triggered.connect(lambda: self.delete_apparat(pos))
|
||||
# pass pos to contact_prof
|
||||
contact_action.triggered.connect(
|
||||
@@ -1407,14 +1405,14 @@ class Ui(Ui_Semesterapparat):
|
||||
menu.exec(self.tableWidget_apparate.mapToGlobal(position))
|
||||
|
||||
def reminder(self):
|
||||
logger.info("Opening reminder dialog")
|
||||
reminder = reminder_ui()
|
||||
log.info("Opening reminder dialog")
|
||||
reminder = ReminderDialog()
|
||||
reminder.exec()
|
||||
tableposition = self.tableWidget_apparate.currentRow()
|
||||
appnr = self.tableWidget_apparate.item(tableposition, 0).text()
|
||||
if reminder.result() == QtWidgets.QDialog.DialogCode.Accepted:
|
||||
data = reminder.return_message()
|
||||
# #logger.debug(data)
|
||||
# #log.debug(data)
|
||||
self.db.addMessage(
|
||||
data,
|
||||
self.active_user,
|
||||
@@ -1423,18 +1421,18 @@ class Ui(Ui_Semesterapparat):
|
||||
self.update_calendar(data)
|
||||
# self.db.update_bookdata(data, book_id)
|
||||
# self.db.update_bookdata(data)
|
||||
logger.info("committed message to database")
|
||||
log.info("committed message to database")
|
||||
# self.update_app_media_list()
|
||||
|
||||
def get_reminders(self):
|
||||
messages = self.db.getAllMessages()
|
||||
logger.info(f"Got {len(messages)} messages from database")
|
||||
log.info(f"Got {len(messages)} messages from database")
|
||||
self.calendarWidget.setMessages(messages)
|
||||
self.calendarWidget.updateCells()
|
||||
|
||||
def open_reminder(self):
|
||||
selected_date = self.calendarWidget.selectedDate().toString("yyyy-MM-dd")
|
||||
# # #logger.debug(selected_date)
|
||||
# # #log.debug(selected_date)
|
||||
messages = self.db.getMessages(selected_date)
|
||||
if messages == []:
|
||||
return
|
||||
@@ -1445,13 +1443,13 @@ class Ui(Ui_Semesterapparat):
|
||||
dialog.repaintSignal.connect(lambda: self.calendarWidget.reload(selected_date))
|
||||
|
||||
def open_settings(self):
|
||||
# logger.debug(settings.dict())
|
||||
# log.debug(settings.dict())
|
||||
settingsUI = Settings(self.active_user)
|
||||
settingsUI.exec()
|
||||
|
||||
if settingsUI.result() == QtWidgets.QDialog.DialogCode.Accepted:
|
||||
settingsUI.save()
|
||||
# logger.debug(settings.dict())
|
||||
# log.debug(settings.dict())
|
||||
|
||||
# self.reload()
|
||||
|
||||
@@ -1470,6 +1468,7 @@ class Ui(Ui_Semesterapparat):
|
||||
|
||||
delete_action = QtGui.QAction("Löschen")
|
||||
edit_action = QtGui.QAction("Bearbeiten")
|
||||
update_data_action = QtGui.QAction("Daten aktualisieren")
|
||||
apparat_add_action = QtGui.QAction("Zum Apparat hinzufügen")
|
||||
apparat_move_action = QtGui.QAction("In Apparat verschieben")
|
||||
apparat_copy_action = QtGui.QAction("In Apparat kopieren")
|
||||
@@ -1479,7 +1478,7 @@ class Ui(Ui_Semesterapparat):
|
||||
apparatmenu.addActions(
|
||||
[apparat_add_action, apparat_copy_action, apparat_move_action]
|
||||
)
|
||||
generalmenu.addActions([edit_action, delete_action])
|
||||
generalmenu.addActions([edit_action, delete_action, update_data_action])
|
||||
# disable apparat_add_action
|
||||
apparat_add_action.setEnabled(False)
|
||||
delete_action.triggered.connect(self.delete_medium)
|
||||
@@ -1487,8 +1486,13 @@ class Ui(Ui_Semesterapparat):
|
||||
apparat_add_action.triggered.connect(self.add_to_apparat)
|
||||
apparat_copy_action.triggered.connect(self.copy_to_apparat)
|
||||
apparat_move_action.triggered.connect(self.move_to_apparat)
|
||||
update_data_action.triggered.connect(self.update_data)
|
||||
menu.exec(self.tableWidget_apparat_media.mapToGlobal(position))
|
||||
|
||||
def update_data(self):
|
||||
# TODO: use link in table, parse data and if needed, update location / signature
|
||||
pass
|
||||
|
||||
def copy_to_apparat(self):
|
||||
selected_rows = self.tableWidget_apparat_media.selectionModel().selectedRows()
|
||||
signatures = []
|
||||
@@ -1577,7 +1581,7 @@ class Ui(Ui_Semesterapparat):
|
||||
signature=signature,
|
||||
prof_id=self.db.getProfId(self.profdata),
|
||||
)
|
||||
# logger.debug(medium.adis_idn, medium.signature)
|
||||
# log.debug(medium.adis_idn, medium.signature)
|
||||
|
||||
def edit_medium(self):
|
||||
book = self.tableWidget_apparat_media.item(
|
||||
@@ -1595,7 +1599,7 @@ class Ui(Ui_Semesterapparat):
|
||||
book,
|
||||
)
|
||||
widget = QtWidgets.QDialog()
|
||||
bookedit = edit_bookdata_ui()
|
||||
bookedit = BookDataUI()
|
||||
bookedit.setupUi(widget)
|
||||
widget.setWindowIcon(Icon("settings").icon)
|
||||
# change title of dialog
|
||||
@@ -1604,10 +1608,10 @@ class Ui(Ui_Semesterapparat):
|
||||
widget.exec()
|
||||
if widget.result() == QtWidgets.QDialog.DialogCode.Accepted:
|
||||
data = bookedit.get_data()
|
||||
# #logger.debug(data)
|
||||
# #log.debug(data)
|
||||
self.db.updateBookdata(bookdata=data, book_id=book_id)
|
||||
# self.db.update_bookdata(data)
|
||||
# #logger.debug("accepted")
|
||||
# #log.debug("accepted")
|
||||
self.update_app_media_list()
|
||||
else:
|
||||
return
|
||||
@@ -1631,7 +1635,7 @@ class Ui(Ui_Semesterapparat):
|
||||
)
|
||||
message = f'Soll das Medium "{self.tableWidget_apparat_media.item(self.tableWidget_apparat_media.currentRow(), 0).text()}" wirklich gelöscht werden?'
|
||||
state = self.confirm_popup(message, title="Löschen?")
|
||||
# #logger.debug(state)
|
||||
# #log.debug(state)
|
||||
if state == 1:
|
||||
self.db.deleteBook(book_id)
|
||||
self.update_app_media_list()
|
||||
@@ -1643,7 +1647,7 @@ class Ui(Ui_Semesterapparat):
|
||||
for r in ranges:
|
||||
for row in range(r.topRow(), r.bottomRow() + 1):
|
||||
rows.append(row)
|
||||
# #logger.debug(rows)
|
||||
# #log.debug(rows)
|
||||
message = f"Sollen die {len(rows)} Medien wirklich gelöscht werden?"
|
||||
state = self.confirm_popup(message, title="Löschen?")
|
||||
if state == 1:
|
||||
@@ -1663,12 +1667,12 @@ class Ui(Ui_Semesterapparat):
|
||||
# return data from dialog if ok is pressed
|
||||
if framework.result() == QtWidgets.QDialog.DialogCode.Accepted:
|
||||
data = framework.get_data()
|
||||
# #logger.debug(data)
|
||||
# #log.debug(data)
|
||||
# return data
|
||||
selected_apparat_id = self.tableWidget_apparate.item(
|
||||
self.tableWidget_apparate.currentRow(), 0
|
||||
).text()
|
||||
# #logger.debug(selected_apparat_id)
|
||||
# #log.debug(selected_apparat_id)
|
||||
|
||||
self.db.setNewSemesterDate(
|
||||
selected_apparat_id, data["semester"], dauerapp=data["dauerapp"]
|
||||
@@ -1679,7 +1683,7 @@ class Ui(Ui_Semesterapparat):
|
||||
return
|
||||
|
||||
def __contact_dialog(self, apparat, location: tuple | str, mail=None, pid=""):
|
||||
logger.debug(
|
||||
log.debug(
|
||||
"Got these values apparat: {}, location: {}, mail: {}, pid: {}".format(
|
||||
apparat, location, mail, pid
|
||||
)
|
||||
@@ -1722,8 +1726,8 @@ class Ui(Ui_Semesterapparat):
|
||||
self.mail_thread.show()
|
||||
|
||||
def contact_prof(self, apparat="", location="", mail="", pid=""):
|
||||
logger.debug(apparat)
|
||||
logger.debug(location)
|
||||
log.debug(apparat)
|
||||
log.debug(location)
|
||||
if self.active_apparat == "":
|
||||
if apparat is False:
|
||||
self.confirm_popup(
|
||||
@@ -1739,10 +1743,10 @@ class Ui(Ui_Semesterapparat):
|
||||
).text()
|
||||
message = f"Soll der Apparat {selected_apparat_id} wirklich gelöscht werden?"
|
||||
state = self.confirm_popup(message, title="Löschen?")
|
||||
# #logger.debug(state)
|
||||
logger.info("Result state: {}", state)
|
||||
# #log.debug(state)
|
||||
log.info("Result state: {}", state)
|
||||
if state == 1:
|
||||
logger.debug("Deleting apparat {}", selected_apparat_id)
|
||||
log.debug("Deleting apparat {}", selected_apparat_id)
|
||||
pid = self.db.getProfIDByApparat(selected_apparat_id)
|
||||
self.db.deleteApparat(selected_apparat_id, Semester().value)
|
||||
# delete the corresponding entry from self.apparats
|
||||
@@ -1751,7 +1755,7 @@ class Ui(Ui_Semesterapparat):
|
||||
self.apparats.remove(apparat)
|
||||
break
|
||||
self.old_apparats = self.apparats
|
||||
# #logger.debug(self.apparats)
|
||||
# #log.debug(self.apparats)
|
||||
# remove the row from the table
|
||||
self.tableWidget_apparate.removeRow(self.tableWidget_apparate.currentRow())
|
||||
# send mail to prof
|
||||
@@ -1759,24 +1763,24 @@ class Ui(Ui_Semesterapparat):
|
||||
|
||||
|
||||
def launch_gui():
|
||||
# #logger.debug("trying to login")
|
||||
# #logger.debug("checking if database available")
|
||||
# #log.debug("trying to login")
|
||||
# #log.debug("checking if database available")
|
||||
|
||||
logger.info("Starting login dialog")
|
||||
log.info("Starting login dialog")
|
||||
app = QtWidgets.QApplication(sys.argv)
|
||||
login_dialog = QtWidgets.QDialog()
|
||||
ui = login_ui()
|
||||
ui = LoginDialog()
|
||||
ui.setupUi(login_dialog)
|
||||
login_dialog.exec() # This will block until the dialog is closed
|
||||
|
||||
if ui.lresult == 1:
|
||||
# if login is successful, open main window
|
||||
# show login dialog
|
||||
# #logger.debug(ui.lusername)
|
||||
# #log.debug(ui.lusername)
|
||||
MainWindow = QtWidgets.QMainWindow()
|
||||
aui = Ui(MainWindow, username=ui.lusername)
|
||||
|
||||
# #logger.debug(aui.active_user)
|
||||
# #log.debug(aui.active_user)
|
||||
MainWindow.show()
|
||||
# atexit.register()
|
||||
atexit.register(tempdelete)
|
||||
@@ -1793,7 +1797,7 @@ def launch_gui():
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
# #logger.debug("This is the main window")
|
||||
# #log.debug("This is the main window")
|
||||
# app = QtWidgets.QApplication(sys.argv)
|
||||
# window = MainWindow()
|
||||
# app.exec()
|
||||
|
||||
@@ -3,17 +3,15 @@ from PyQt6.QtCore import QDate
|
||||
from PyQt6.QtGui import QColor, QPen
|
||||
from src.backend import Database
|
||||
import darkdetect
|
||||
import loguru
|
||||
import sys
|
||||
from loguru import logger as log
|
||||
|
||||
logger = log
|
||||
logger.remove()
|
||||
logger.add("logs/application.log", rotation="1 week", retention="1 month", enqueue=True)
|
||||
log = loguru.logger
|
||||
log.remove()
|
||||
log.add(sys.stdout)
|
||||
log.add("logs/application.log", rotation="1 MB", retention="10 days")
|
||||
|
||||
|
||||
# logger.add(sys.stderr, format="{time} {level} {message}", level="INFO")
|
||||
logger.add(sys.stdout)
|
||||
|
||||
color = "#ddfb00" if darkdetect.isDark() else "#2204ff"
|
||||
pen = QPen(QColor(color))
|
||||
pen.setWidth(5)
|
||||
@@ -31,7 +29,7 @@ class MessageCalendar(QtWidgets.QCalendarWidget):
|
||||
def getMessages(self):
|
||||
# Get the messages from the database
|
||||
messages = Database().getAllMessages()
|
||||
logger.debug("Got {} messages", len(messages))
|
||||
log.debug("Got {} messages", len(messages))
|
||||
self.setMessages(messages)
|
||||
|
||||
def deleteMessage(self, id):
|
||||
|
||||
@@ -3,15 +3,14 @@ from PyQt6 import QtWidgets
|
||||
|
||||
from src.logic import Prof
|
||||
from src.backend import Database
|
||||
import loguru
|
||||
import sys
|
||||
from loguru import logger as log
|
||||
|
||||
logger = log
|
||||
logger.remove()
|
||||
logger.add("logs/application.log", rotation="1 week", retention="1 month", enqueue=True)
|
||||
log = loguru.logger
|
||||
log.remove()
|
||||
log.add(sys.stdout)
|
||||
log.add("logs/application.log", rotation="1 MB", retention="10 days")
|
||||
|
||||
# logger.add(sys.stderr, format="{time} {level} {message}", level="INFO")
|
||||
logger.add(sys.stdout)
|
||||
|
||||
|
||||
class EditProf(QtWidgets.QDialog, Ui_Dialog):
|
||||
@@ -69,7 +68,7 @@ class EditProf(QtWidgets.QDialog, Ui_Dialog):
|
||||
else:
|
||||
self.faculty_member_old_telnr.setText(data.telnr)
|
||||
self.faculty_member_oldmail.setText(data.mail)
|
||||
logger.debug(data)
|
||||
log.debug(data)
|
||||
(
|
||||
self.edit_faculty_member_title.setText(data.title)
|
||||
if data.title is not None
|
||||
@@ -93,7 +92,7 @@ class EditProf(QtWidgets.QDialog, Ui_Dialog):
|
||||
olddata = self.db.getProfByName(
|
||||
self.edit_faculty_member_select_member.currentText()
|
||||
)
|
||||
logger.debug(olddata)
|
||||
log.debug(olddata)
|
||||
data = olddata
|
||||
oldlname = data.lastname
|
||||
oldfname = data.firstname
|
||||
|
||||
@@ -9,15 +9,14 @@ from src.logic import elsa_word_to_csv, Prof
|
||||
from src.ui.dialogs import ElsaAddEntry, popus_confirm
|
||||
from src.ui.widgets import FilePicker, DataGraph
|
||||
from src.backend import recreateElsaFile
|
||||
import loguru
|
||||
import sys
|
||||
from loguru import logger as log
|
||||
|
||||
log = loguru.logger
|
||||
log.remove()
|
||||
log.add(sys.stdout)
|
||||
log.add("logs/application.log", rotation="1 MB", retention="10 days")
|
||||
|
||||
logger = log
|
||||
logger.remove()
|
||||
logger.add("logs/application.log", rotation="1 week", retention="1 month", enqueue=True)
|
||||
log.add("logs/elsa_main.log", enqueue=True)
|
||||
logger.add(sys.stdout)
|
||||
|
||||
|
||||
class ElsaDialog(QtWidgets.QDialog, Ui_Dialog):
|
||||
@@ -93,7 +92,7 @@ class ElsaDialog(QtWidgets.QDialog, Ui_Dialog):
|
||||
self.newProf_title.textChanged.connect(self.checkProfData)
|
||||
|
||||
self.loadFrame()
|
||||
logger.info("Elsa Dialog loaded")
|
||||
log.info("Elsa Dialog loaded")
|
||||
# self.show()
|
||||
|
||||
def checkProfData(self):
|
||||
@@ -237,7 +236,7 @@ class ElsaDialog(QtWidgets.QDialog, Ui_Dialog):
|
||||
fullname=f"{prof.split(', ')[0]} {prof.split(', ')[1]}",
|
||||
)
|
||||
prof_id = self.db.getProfId(profdata)
|
||||
logger.debug(f"ProfData: {profdata}, id:{prof_id}")
|
||||
log.debug(f"ProfData: {profdata}, id:{prof_id}")
|
||||
|
||||
if prof_id is None:
|
||||
self.db.createProf(profdata)
|
||||
@@ -263,12 +262,12 @@ class ElsaDialog(QtWidgets.QDialog, Ui_Dialog):
|
||||
files,
|
||||
elsa_id,
|
||||
)
|
||||
logger.info("Stored {} files in the database", len(files))
|
||||
log.info("Stored {} files in the database", len(files))
|
||||
self.cancel_elsa_creation()
|
||||
self.refresh_elsa_table()
|
||||
self.elsa_prof.setCurrentText("")
|
||||
self.quote_entry.setEnabled(False)
|
||||
logger.info("Saved apparat to database, id {}", elsa_id)
|
||||
log.info("Saved apparat to database, id {}", elsa_id)
|
||||
|
||||
def refresh_elsa_table(self):
|
||||
self.elsa_table.setRowCount(0)
|
||||
@@ -288,13 +287,13 @@ class ElsaDialog(QtWidgets.QDialog, Ui_Dialog):
|
||||
|
||||
def open_elsa(self):
|
||||
prof = self.elsa_table.item(self.elsa_table.currentRow(), 0).text()
|
||||
logger.info("prof", prof)
|
||||
log.info("prof", prof)
|
||||
date = self.elsa_table.item(self.elsa_table.currentRow(), 1).text()
|
||||
semester = self.elsa_table.item(self.elsa_table.currentRow(), 2).text()
|
||||
self.elsa_update.setEnabled(True)
|
||||
self.elsa_save.setEnabled(False)
|
||||
if self.elsa_prof.currentText() == prof and date == self.elsa_date.text():
|
||||
logger.debug("Same prof, stopping")
|
||||
log.debug("Same prof, stopping")
|
||||
return
|
||||
self.create_frame_elsa.setEnabled(True)
|
||||
self.dokument_list_elsa.setRowCount(0)
|
||||
@@ -314,7 +313,7 @@ class ElsaDialog(QtWidgets.QDialog, Ui_Dialog):
|
||||
self.elsa_date.setText(date)
|
||||
self.elsa_semester.setText(semester)
|
||||
self.elsa_prof.setCurrentText(prof)
|
||||
logger.info("Elsa ID is {}", elsa_id)
|
||||
log.info("Elsa ID is {}", elsa_id)
|
||||
if elsa_id is None:
|
||||
return
|
||||
documents = self.db.getElsaFiles(elsa_id)
|
||||
@@ -411,7 +410,7 @@ class ElsaDialog(QtWidgets.QDialog, Ui_Dialog):
|
||||
self.elsa_semester.text(),
|
||||
self.elsa_date.text(),
|
||||
)
|
||||
logger.debug(
|
||||
log.debug(
|
||||
f"elsa_id: {elsa_id}, prof: {self.elsa_prof.currentText()}, semester: {self.elsa_semester.text()}, date: {self.elsa_date.text()}"
|
||||
)
|
||||
for row in data:
|
||||
@@ -445,7 +444,7 @@ class ElsaDialog(QtWidgets.QDialog, Ui_Dialog):
|
||||
try:
|
||||
self.elsa_statistics.removeTab(1)
|
||||
except:
|
||||
logger.debug("No tab to remove")
|
||||
log.debug("No tab to remove")
|
||||
self.elsa_table.setRowCount(0)
|
||||
elsa_apparats = self.db.getElsaApparats()
|
||||
# elsa_apparats = natsorted(elsa_apparats, key=lambda x: x[2], reverse=True)
|
||||
@@ -469,7 +468,7 @@ class ElsaDialog(QtWidgets.QDialog, Ui_Dialog):
|
||||
data=self.graph_data,
|
||||
label="Anzahl der Apparate",
|
||||
)
|
||||
logger.debug(self.graph_data)
|
||||
log.debug(self.graph_data)
|
||||
self.elsa_statistics_table.setRowCount(0)
|
||||
for i in range(len(self.graph_data["x"])):
|
||||
self.elsa_statistics_table.insertRow(0)
|
||||
@@ -483,7 +482,7 @@ class ElsaDialog(QtWidgets.QDialog, Ui_Dialog):
|
||||
|
||||
|
||||
def launch():
|
||||
logger.debug("Launching Elsa Dialog")
|
||||
log.debug("Launching Elsa Dialog")
|
||||
app = QtWidgets.QApplication([])
|
||||
window = ElsaDialog()
|
||||
window.show()
|
||||
|
||||
@@ -3,18 +3,13 @@ from typing import Union
|
||||
|
||||
import pyqtgraph as pg
|
||||
from PyQt6 import QtWidgets
|
||||
import loguru
|
||||
import sys
|
||||
from loguru import logger as log
|
||||
|
||||
logger = log
|
||||
logger.remove()
|
||||
logger.add("logs/application.log", rotation="1 week", retention="1 month", enqueue=True)
|
||||
log.add(
|
||||
"logs/graph.log",
|
||||
)
|
||||
|
||||
# logger.add(sys.stderr, format="{time} {level} {message}", level="INFO")
|
||||
logger.add(sys.stdout)
|
||||
log = loguru.logger
|
||||
log.remove()
|
||||
log.add(sys.stdout)
|
||||
log.add("logs/application.log", rotation="1 MB", retention="10 days")
|
||||
|
||||
|
||||
def mergedicts(d1, d2):
|
||||
@@ -43,7 +38,7 @@ class DataGraph(QtWidgets.QWidget):
|
||||
label=None,
|
||||
):
|
||||
super().__init__()
|
||||
logger.debug(
|
||||
log.debug(
|
||||
"Initialized with options: {}, {}, {}, {}".format(
|
||||
title, data, generateMissing, label
|
||||
)
|
||||
|
||||
@@ -6,7 +6,7 @@ from loguru import logger as log
|
||||
|
||||
logger = log
|
||||
logger.remove()
|
||||
logger.add("logs/application.log", rotation="1 week", enqueue=True)
|
||||
logger.add("logs/application.log", rotation="1 week", retention="1 month", enqueue=True)
|
||||
|
||||
|
||||
# logger.add(sys.stderr, format="{time} {level} {message}", level="INFO")
|
||||
@@ -29,9 +29,12 @@ class IconWidget(QtWidgets.QWidget, Ui_Dialog):
|
||||
self.icon_filename_line.setText(
|
||||
file_dialog.selectedFiles()[0].split("/")[-1]
|
||||
)
|
||||
logger.debug(
|
||||
"Icon changed to: {}", file_dialog.selectedFiles()[0].split("/")[-1]
|
||||
)
|
||||
try:
|
||||
log.debug(
|
||||
"Icon changed to: {}", file_dialog.selectedFiles()[0].split("/")[-1]
|
||||
)
|
||||
except IndexError:
|
||||
log.debug("No file selected")
|
||||
|
||||
def return_data(self):
|
||||
return self.icon_name_settings.text(), self.icon_filename_line.text()
|
||||
|
||||
@@ -4,20 +4,18 @@ from PyQt6.QtCore import pyqtSignal
|
||||
from src.backend import Database, Semester
|
||||
|
||||
from src.logic import custom_sort, Prof, sort_semesters_list
|
||||
from src.ui.dialogs import Mail_Dialog, ApparatExtendDialog, reminder_ui
|
||||
from src.ui.dialogs import Mail_Dialog, ApparatExtendDialog, ReminderDialog
|
||||
from src.ui.widgets import DataGraph, StatusWidget
|
||||
|
||||
from natsort import natsorted
|
||||
import loguru
|
||||
import sys
|
||||
from loguru import logger as log
|
||||
|
||||
logger = log
|
||||
logger.remove()
|
||||
logger.add("logs/application.log", rotation="1 week", retention="1 month", enqueue=True)
|
||||
log.add("logs/searchPage.log", enqueue=True)
|
||||
log = loguru.logger
|
||||
log.remove()
|
||||
log.add(sys.stdout)
|
||||
log.add("logs/application.log", rotation="1 MB", retention="10 days")
|
||||
|
||||
# logger.add(sys.stderr, format="{time} {level} {message}", level="INFO")
|
||||
logger.add(sys.stdout)
|
||||
|
||||
|
||||
class MyComboBox(QtWidgets.QComboBox):
|
||||
@@ -32,7 +30,7 @@ class SearchStatisticPage(QtWidgets.QDialog, Ui_Dialog):
|
||||
updateCalendar = pyqtSignal(int, list)
|
||||
|
||||
def __init__(self):
|
||||
logger.info("SearchStatisticPage started")
|
||||
log.info("SearchStatisticPage started")
|
||||
super().__init__()
|
||||
self.setupUi(self)
|
||||
self.book_search_result.horizontalHeader().setSectionResizeMode(
|
||||
@@ -111,7 +109,7 @@ class SearchStatisticPage(QtWidgets.QDialog, Ui_Dialog):
|
||||
extend.exec()
|
||||
if extend.result() == QtWidgets.QDialog.DialogCode.Accepted:
|
||||
data = extend.get_data()
|
||||
logger.debug(data)
|
||||
log.debug(data)
|
||||
app_name = self.tableWidget.item(self.tableWidget.currentRow(), 1).text()
|
||||
app_id = self.db.getApparatId(app_name)
|
||||
self.db.setNewSemesterDate(app_id, data["semester"], data["dauerapp"])
|
||||
@@ -120,8 +118,8 @@ class SearchStatisticPage(QtWidgets.QDialog, Ui_Dialog):
|
||||
self.refreshSignal.emit()
|
||||
|
||||
def reminder(self):
|
||||
logger.info("Opening reminder dialog")
|
||||
reminder = reminder_ui()
|
||||
log.info("Opening reminder dialog")
|
||||
reminder = ReminderDialog()
|
||||
reminder.exec()
|
||||
tableposition = self.tableWidget.currentRow()
|
||||
appnr = self.tableWidget.item(tableposition, 2).text()
|
||||
@@ -134,7 +132,7 @@ class SearchStatisticPage(QtWidgets.QDialog, Ui_Dialog):
|
||||
appnr,
|
||||
)
|
||||
self.updateCalendar.emit(data)
|
||||
logger.info("committed message to database")
|
||||
log.info("committed message to database")
|
||||
|
||||
def tabW2_changed(self):
|
||||
if self.tabWidget_2.currentIndex() == 0:
|
||||
@@ -151,12 +149,12 @@ class SearchStatisticPage(QtWidgets.QDialog, Ui_Dialog):
|
||||
"title": title if title != "" else None,
|
||||
}
|
||||
params = {key: value for key, value in params.items() if value is not None}
|
||||
logger.debug(params)
|
||||
log.debug(params)
|
||||
retdata = self.db.searchBook(params)
|
||||
if retdata is None:
|
||||
return
|
||||
for book in retdata:
|
||||
logger.debug(book)
|
||||
log.debug(book)
|
||||
self.book_search_result.insertRow(0)
|
||||
self.book_search_result.setItem(
|
||||
0, 0, QtWidgets.QTableWidgetItem(book[0].title)
|
||||
@@ -188,7 +186,7 @@ class SearchStatisticPage(QtWidgets.QDialog, Ui_Dialog):
|
||||
|
||||
selected_apparats.append(data)
|
||||
# delete all selected apparats
|
||||
logger.debug(selected_apparats)
|
||||
log.debug(selected_apparats)
|
||||
dialogs = []
|
||||
for i in selected_apparats:
|
||||
app_id = i["app_id"]
|
||||
@@ -248,7 +246,7 @@ class SearchStatisticPage(QtWidgets.QDialog, Ui_Dialog):
|
||||
self.box_dauerapp.setEnabled(True)
|
||||
|
||||
def populate_tab(self, table_or_graph=0):
|
||||
logger.info("populate_tab started")
|
||||
log.info("populate_tab started")
|
||||
# add default values to the dropdowns
|
||||
self.box_appnrs.clear()
|
||||
self.box_appnrs.addItem("")
|
||||
@@ -315,7 +313,7 @@ class SearchStatisticPage(QtWidgets.QDialog, Ui_Dialog):
|
||||
# place the graph into tabWidget_3
|
||||
self.tabWidget_3.addTab(graph, "Graph")
|
||||
self.tabWidget_3.setCurrentIndex(table_or_graph)
|
||||
logger.info("populate_tab finished")
|
||||
log.info("populate_tab finished")
|
||||
|
||||
def delete_selected_apparats(self):
|
||||
# get all selected apparats
|
||||
@@ -327,7 +325,7 @@ class SearchStatisticPage(QtWidgets.QDialog, Ui_Dialog):
|
||||
selected_apparat_rows.append(i)
|
||||
# delete all selected apparats
|
||||
# # #print(selected_apparats)
|
||||
logger.info(f"Deleting apparats: {selected_apparats}")
|
||||
log.info(f"Deleting apparats: {selected_apparats}")
|
||||
for apparat in selected_apparats:
|
||||
self.db.deleteApparat(apparat, self.semester)
|
||||
for row in selected_apparat_rows:
|
||||
@@ -400,7 +398,7 @@ class SearchStatisticPage(QtWidgets.QDialog, Ui_Dialog):
|
||||
sem = Semester().from_string(
|
||||
entry[8] if entry[8] is not None else entry[5]
|
||||
)
|
||||
logger.info(f"Semester: {sem}")
|
||||
log.info(f"Semester: {sem}")
|
||||
if sem.isPastSemester(Semester()):
|
||||
data.append(entry)
|
||||
else:
|
||||
|
||||
@@ -209,17 +209,7 @@
|
||||
</attribute>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3" stretch="30,70">
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout" rowminimumheight="1,1,1,1">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_25">
|
||||
<property name="text">
|
||||
<string>Signatur</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>seach_by_signature</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_26">
|
||||
<property name="text">
|
||||
@@ -240,26 +230,6 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QPushButton" name="book_search">
|
||||
<property name="text">
|
||||
<string>Suchen</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="seach_by_signature">
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::ClickFocus</enum>
|
||||
</property>
|
||||
<property name="statusTip">
|
||||
<string>Trunkierung mit * am Ende unterstützt</string>
|
||||
</property>
|
||||
<property name="clearButtonEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
@@ -273,6 +243,29 @@
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_25">
|
||||
<property name="text">
|
||||
<string>Signatur</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>search_by_signature</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="search_by_signature">
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::ClickFocus</enum>
|
||||
</property>
|
||||
<property name="statusTip">
|
||||
<string>Trunkierung mit * am Ende unterstützt</string>
|
||||
</property>
|
||||
<property name="clearButtonEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
@@ -582,9 +575,8 @@
|
||||
<tabstop>box_dauerapp</tabstop>
|
||||
<tabstop>btn_search</tabstop>
|
||||
<tabstop>book_search_result</tabstop>
|
||||
<tabstop>seach_by_signature</tabstop>
|
||||
<tabstop>search_by_signature</tabstop>
|
||||
<tabstop>search_by_title</tabstop>
|
||||
<tabstop>book_search</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections/>
|
||||
|
||||
@@ -102,9 +102,6 @@ class Ui_Dialog(object):
|
||||
self.horizontalLayout_3.setObjectName("horizontalLayout_3")
|
||||
self.gridLayout = QtWidgets.QGridLayout()
|
||||
self.gridLayout.setObjectName("gridLayout")
|
||||
self.label_25 = QtWidgets.QLabel(parent=self.tab_4)
|
||||
self.label_25.setObjectName("label_25")
|
||||
self.gridLayout.addWidget(self.label_25, 0, 0, 1, 1)
|
||||
self.label_26 = QtWidgets.QLabel(parent=self.tab_4)
|
||||
self.label_26.setObjectName("label_26")
|
||||
self.gridLayout.addWidget(self.label_26, 1, 0, 1, 1)
|
||||
@@ -113,20 +110,16 @@ class Ui_Dialog(object):
|
||||
self.search_by_title.setClearButtonEnabled(True)
|
||||
self.search_by_title.setObjectName("search_by_title")
|
||||
self.gridLayout.addWidget(self.search_by_title, 1, 1, 1, 1)
|
||||
self.book_search = QtWidgets.QPushButton(parent=self.tab_4)
|
||||
self.book_search.setObjectName("book_search")
|
||||
self.gridLayout.addWidget(self.book_search, 3, 0, 1, 1)
|
||||
self.seach_by_signature = QtWidgets.QLineEdit(parent=self.tab_4)
|
||||
self.seach_by_signature.setFocusPolicy(QtCore.Qt.FocusPolicy.ClickFocus)
|
||||
self.seach_by_signature.setClearButtonEnabled(True)
|
||||
self.seach_by_signature.setObjectName("seach_by_signature")
|
||||
self.gridLayout.addWidget(self.seach_by_signature, 0, 1, 1, 1)
|
||||
spacerItem2 = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Policy.Minimum, QtWidgets.QSizePolicy.Policy.Expanding)
|
||||
self.gridLayout.addItem(spacerItem2, 2, 0, 1, 1)
|
||||
self.gridLayout.setRowMinimumHeight(0, 1)
|
||||
self.gridLayout.setRowMinimumHeight(1, 1)
|
||||
self.gridLayout.setRowMinimumHeight(2, 1)
|
||||
self.gridLayout.setRowMinimumHeight(3, 1)
|
||||
self.label_25 = QtWidgets.QLabel(parent=self.tab_4)
|
||||
self.label_25.setObjectName("label_25")
|
||||
self.gridLayout.addWidget(self.label_25, 0, 0, 1, 1)
|
||||
self.search_by_signature = QtWidgets.QLineEdit(parent=self.tab_4)
|
||||
self.search_by_signature.setFocusPolicy(QtCore.Qt.FocusPolicy.ClickFocus)
|
||||
self.search_by_signature.setClearButtonEnabled(True)
|
||||
self.search_by_signature.setObjectName("search_by_signature")
|
||||
self.gridLayout.addWidget(self.search_by_signature, 0, 1, 1, 1)
|
||||
self.horizontalLayout_3.addLayout(self.gridLayout)
|
||||
spacerItem3 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Minimum)
|
||||
self.horizontalLayout_3.addItem(spacerItem3)
|
||||
@@ -280,8 +273,8 @@ class Ui_Dialog(object):
|
||||
self.label_17.setBuddy(self.box_semester)
|
||||
self.label_19.setBuddy(self.box_erstellsemester)
|
||||
self.label_16.setBuddy(self.box_fach)
|
||||
self.label_25.setBuddy(self.seach_by_signature)
|
||||
self.label_26.setBuddy(self.search_by_title)
|
||||
self.label_25.setBuddy(self.search_by_signature)
|
||||
|
||||
self.retranslateUi(Dialog)
|
||||
self.tabWidget_2.setCurrentIndex(0)
|
||||
@@ -296,9 +289,8 @@ class Ui_Dialog(object):
|
||||
Dialog.setTabOrder(self.box_erstellsemester, self.box_dauerapp)
|
||||
Dialog.setTabOrder(self.box_dauerapp, self.btn_search)
|
||||
Dialog.setTabOrder(self.btn_search, self.book_search_result)
|
||||
Dialog.setTabOrder(self.book_search_result, self.seach_by_signature)
|
||||
Dialog.setTabOrder(self.seach_by_signature, self.search_by_title)
|
||||
Dialog.setTabOrder(self.search_by_title, self.book_search)
|
||||
Dialog.setTabOrder(self.book_search_result, self.search_by_signature)
|
||||
Dialog.setTabOrder(self.search_by_signature, self.search_by_title)
|
||||
|
||||
def retranslateUi(self, Dialog):
|
||||
_translate = QtCore.QCoreApplication.translate
|
||||
@@ -312,10 +304,9 @@ class Ui_Dialog(object):
|
||||
self.label_16.setText(_translate("Dialog", "Fach:"))
|
||||
self.btn_search.setText(_translate("Dialog", "Suchen"))
|
||||
self.tabWidget_2.setTabText(self.tabWidget_2.indexOf(self.tab_3), _translate("Dialog", "Statistik"))
|
||||
self.label_25.setText(_translate("Dialog", "Signatur"))
|
||||
self.label_26.setText(_translate("Dialog", "Titel"))
|
||||
self.book_search.setText(_translate("Dialog", "Suchen"))
|
||||
self.seach_by_signature.setStatusTip(_translate("Dialog", "Trunkierung mit * am Ende unterstützt"))
|
||||
self.label_25.setText(_translate("Dialog", "Signatur"))
|
||||
self.search_by_signature.setStatusTip(_translate("Dialog", "Trunkierung mit * am Ende unterstützt"))
|
||||
self.tabWidget_2.setTabText(self.tabWidget_2.indexOf(self.tab_4), _translate("Dialog", "Suchen"))
|
||||
self.btn_del_select_apparats.setText(_translate("Dialog", "Ausgewählte Löschen"))
|
||||
self.btn_notify_for_deletion.setStatusTip(_translate("Dialog", "Zeigt für jeden ausgewählten Apparat eine eMail-Vorlage an"))
|
||||
|
||||
Reference in New Issue
Block a user