update threads
This commit is contained in:
@@ -1,8 +1,7 @@
|
|||||||
import sqlite3
|
import sqlite3
|
||||||
import time
|
import time
|
||||||
|
|
||||||
from icecream import ic
|
from PyQt6.QtCore import QThread, pyqtSignal as Signal
|
||||||
from PySide6.QtCore import QThread, Signal
|
|
||||||
|
|
||||||
from src.backend.database import Database
|
from src.backend.database import Database
|
||||||
from src.logic.log import MyLogger
|
from src.logic.log import MyLogger
|
||||||
@@ -26,7 +25,6 @@ class BookGrabber(QThread):
|
|||||||
self.mode = mode
|
self.mode = mode
|
||||||
self.book_id = None
|
self.book_id = None
|
||||||
self.state = (self.app_id, self.prof_id, self.mode, self.data)
|
self.state = (self.app_id, self.prof_id, self.mode, self.data)
|
||||||
ic(self.state)
|
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
|
|
||||||
# def resetValues(self):
|
# def resetValues(self):
|
||||||
@@ -64,8 +62,8 @@ class BookGrabber(QThread):
|
|||||||
for rds_item in rds.items:
|
for rds_item in rds.items:
|
||||||
sign = rds_item.superlocation
|
sign = rds_item.superlocation
|
||||||
loc = rds_item.location
|
loc = rds_item.location
|
||||||
ic(sign, loc)
|
#ic(sign, loc)
|
||||||
ic(rds_item)
|
#ic(rds_item)
|
||||||
if self.app_id in sign or self.app_id in loc:
|
if self.app_id in sign or self.app_id in loc:
|
||||||
state = 1
|
state = 1
|
||||||
break
|
break
|
||||||
|
|||||||
@@ -2,10 +2,10 @@ import os
|
|||||||
import sqlite3
|
import sqlite3
|
||||||
import time
|
import time
|
||||||
|
|
||||||
from icecream import ic
|
#from icecream import ic
|
||||||
from omegaconf import OmegaConf
|
from omegaconf import OmegaConf
|
||||||
from PySide6 import QtWidgets
|
from PyQt6 import QtWidgets
|
||||||
from PySide6.QtCore import QThread, Signal
|
from PyQt6.QtCore import QThread, pyqtSignal as Signal
|
||||||
|
|
||||||
from src.backend.database import Database
|
from src.backend.database import Database
|
||||||
from src.logic.log import MyLogger
|
from src.logic.log import MyLogger
|
||||||
@@ -58,7 +58,7 @@ class MockAvailCheck:
|
|||||||
for item in rds.items:
|
for item in rds.items:
|
||||||
sign = item.superlocation
|
sign = item.superlocation
|
||||||
loc = item.location
|
loc = item.location
|
||||||
ic(item.location, item.superlocation)
|
#ic(item.location, item.superlocation)
|
||||||
if self.appnumber in sign or self.appnumber in loc:
|
if self.appnumber in sign or self.appnumber in loc:
|
||||||
state = 1
|
state = 1
|
||||||
book_id = None
|
book_id = None
|
||||||
@@ -209,5 +209,6 @@ class MailThread(QThread):
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import time
|
import time
|
||||||
|
|
||||||
from icecream import ic
|
#from icecream import ic
|
||||||
from PySide6.QtCore import QThread, Signal
|
from PyQt6.QtCore import QThread, pyqtSignal as Signal
|
||||||
|
|
||||||
from src.backend.database import Database
|
from src.backend.database import Database
|
||||||
from src.logic.log import MyLogger
|
from src.logic.log import MyLogger
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import time
|
import time
|
||||||
|
|
||||||
from icecream import ic
|
#from icecream import ic
|
||||||
from PySide6.QtCore import QThread, Signal
|
from PyQt6.QtCore import QThread, pyqtSignal as Signal
|
||||||
|
|
||||||
from src.backend.database import Database
|
from src.backend.database import Database
|
||||||
from src.logic.log import MyLogger
|
from src.logic.log import MyLogger
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ from src.logic.log import MyLogger
|
|||||||
from src.transformers import RDS_AVAIL_DATA
|
from src.transformers import RDS_AVAIL_DATA
|
||||||
from src.logic.webrequest import BibTextTransformer, WebRequest
|
from src.logic.webrequest import BibTextTransformer, WebRequest
|
||||||
import sqlite3
|
import sqlite3
|
||||||
from icecream import ic
|
#from icecream import ic
|
||||||
|
|
||||||
|
|
||||||
class BookGrabber(QThread):
|
class BookGrabber(QThread):
|
||||||
@@ -68,8 +68,8 @@ class BookGrabber(QThread):
|
|||||||
for rds_item in rds.items:
|
for rds_item in rds.items:
|
||||||
sign = rds_item.superlocation
|
sign = rds_item.superlocation
|
||||||
loc = rds_item.location
|
loc = rds_item.location
|
||||||
ic(sign, loc)
|
#ic(sign, loc)
|
||||||
ic(rds_item)
|
#ic(rds_item)
|
||||||
if self.app_id in sign or self.app_id in loc:
|
if self.app_id in sign or self.app_id in loc:
|
||||||
state = 1
|
state = 1
|
||||||
break
|
break
|
||||||
@@ -245,7 +245,7 @@ class MockAvailCheck:
|
|||||||
for item in rds.items:
|
for item in rds.items:
|
||||||
sign = item.superlocation
|
sign = item.superlocation
|
||||||
loc = item.location
|
loc = item.location
|
||||||
ic(item.location, item.superlocation)
|
#ic(item.location, item.superlocation)
|
||||||
if self.appnumber in sign or self.appnumber in loc:
|
if self.appnumber in sign or self.appnumber in loc:
|
||||||
state = 1
|
state = 1
|
||||||
book_id = None
|
book_id = None
|
||||||
|
|||||||
@@ -12,9 +12,9 @@ from pathlib import Path
|
|||||||
from icecream import ic
|
from icecream import ic
|
||||||
from natsort import natsorted
|
from natsort import natsorted
|
||||||
from omegaconf import OmegaConf
|
from omegaconf import OmegaConf
|
||||||
from PySide6 import QtCore, QtGui, QtWidgets
|
from PyQt6 import QtCore, QtGui, QtWidgets
|
||||||
from PySide6.QtCore import QDate, QThread, Signal
|
from PyQt6.QtCore import QDate, QThread
|
||||||
from PySide6.QtGui import QColor, QRegularExpressionValidator
|
from PyQt6.QtGui import QColor, QRegularExpressionValidator
|
||||||
|
|
||||||
# from src.logic.webrequest import BibTextTransformer, WebRequest
|
# from src.logic.webrequest import BibTextTransformer, WebRequest
|
||||||
# from src.utils import documentationview
|
# from src.utils import documentationview
|
||||||
@@ -26,9 +26,8 @@ from src.backend.semester import generateSemesterByDate
|
|||||||
from src.logic import AvailChecker, BookGrabber, c_sort
|
from src.logic import AvailChecker, BookGrabber, c_sort
|
||||||
from src.logic.constants import APP_NRS, PROF_TITLES
|
from src.logic.constants import APP_NRS, PROF_TITLES
|
||||||
from src.logic.csvparser import csv_to_list
|
from src.logic.csvparser import csv_to_list
|
||||||
from src.logic.dataclass import ApparatData, BookData, MailData, Subjects
|
from src.logic.dataclass import ApparatData, BookData
|
||||||
from src.logic.log import MyLogger
|
from src.logic.log import MyLogger
|
||||||
from src.logic.threads import MailThread
|
|
||||||
from src.logic.wordparser import word_docx_to_csv
|
from src.logic.wordparser import word_docx_to_csv
|
||||||
from src.ui import ( # Mail_Dialog,
|
from src.ui import ( # Mail_Dialog,
|
||||||
App_Ext_Dialog,
|
App_Ext_Dialog,
|
||||||
@@ -45,143 +44,10 @@ from src.ui import ( # Mail_Dialog,
|
|||||||
reminder_ui,
|
reminder_ui,
|
||||||
settings_ui,
|
settings_ui,
|
||||||
)
|
)
|
||||||
from src.ui.dialogs.Ui_mail_preview import Ui_eMailPreview as Ui_Dialog
|
|
||||||
|
|
||||||
config = OmegaConf.load("config.yaml")
|
config = OmegaConf.load("config.yaml")
|
||||||
|
|
||||||
|
|
||||||
# class Mail_Dialog(QtWidgets.QDialog, Ui_Dialog):
|
|
||||||
# def __init__(
|
|
||||||
# self,
|
|
||||||
# app_id,
|
|
||||||
# app_name,
|
|
||||||
# app_subject,
|
|
||||||
# prof_name,
|
|
||||||
# prof_mail,
|
|
||||||
# parent=None,
|
|
||||||
# default_mail="Information zum Semesterapparat {AppNr} - {AppName}.eml",
|
|
||||||
# ):
|
|
||||||
# super().__init__(parent)
|
|
||||||
# self.setupUi(
|
|
||||||
# self,
|
|
||||||
# # app_id,
|
|
||||||
# # app_name,
|
|
||||||
# # app_subject,
|
|
||||||
# # prof_name,
|
|
||||||
# )
|
|
||||||
# self.appid = app_id
|
|
||||||
# self.appname = app_name
|
|
||||||
# self.subject = app_subject
|
|
||||||
# self.profname = prof_name
|
|
||||||
# self.mail_data = ""
|
|
||||||
# self.prof_mail = prof_mail
|
|
||||||
# self.comboBox.currentIndexChanged.connect(self.set_mail)
|
|
||||||
# self.prof_name.setText(prof_name)
|
|
||||||
# self.mail_name.setText(self.prof_mail)
|
|
||||||
# # self.load_mail_templates()
|
|
||||||
# # if default_mail is not None:
|
|
||||||
# # # get the nearest match to the default mail
|
|
||||||
# # for i in range(self.comboBox.count()):
|
|
||||||
# # if default_mail in self.comboBox.itemText(i):
|
|
||||||
# # default_mail = self.comboBox.itemText(i)
|
|
||||||
# # break
|
|
||||||
# # self.comboBox.setCurrentText(default_mail)
|
|
||||||
|
|
||||||
# self.gender_female.clicked.connect(self.set_mail)
|
|
||||||
# self.gender_male.clicked.connect(self.set_mail)
|
|
||||||
# self.gender_non.clicked.connect(self.set_mail)
|
|
||||||
# self.buttonBox.accepted.connect(self.createAndSendMail)
|
|
||||||
# print(self.appid, self.appname, self.subject, self.profname, self.prof_mail)
|
|
||||||
# # self.send_button.clicked.connect(self.save_mail)
|
|
||||||
|
|
||||||
# # def set_data(self, data: dict):
|
|
||||||
# # print(data)
|
|
||||||
# # self.prof_name.setText(data["prof_name"])
|
|
||||||
# # self.mail_name.setText(data["mail_name"])
|
|
||||||
# # # assign data["general"] to self.data
|
|
||||||
# # self.data = data["general"]
|
|
||||||
|
|
||||||
# def load_mail_templates(self):
|
|
||||||
# print("loading mail templates")
|
|
||||||
# mail_templates = os.listdir("mail_vorlagen")
|
|
||||||
# for template in mail_templates:
|
|
||||||
# self.comboBox.addItem(template)
|
|
||||||
|
|
||||||
# def add_data(self, app_id, app_name, subject, prof_name, prof_mail):
|
|
||||||
# self.appid = app_id
|
|
||||||
# self.appname = app_name
|
|
||||||
# self.subject = subject
|
|
||||||
# self.profname = prof_name
|
|
||||||
# self.prof_mail = prof_mail
|
|
||||||
# self.prof_name.setText(prof_name)
|
|
||||||
# self.mail_name.setText(prof_mail)
|
|
||||||
# self.load_mail_templates()
|
|
||||||
|
|
||||||
# def get_greeting(self):
|
|
||||||
# if self.gender_male.isChecked():
|
|
||||||
# return "Sehr geehrter Herr"
|
|
||||||
# elif self.gender_female.isChecked():
|
|
||||||
# return "Sehr geehrte Frau"
|
|
||||||
# elif self.gender_non.isChecked():
|
|
||||||
# return "Guten Tag"
|
|
||||||
|
|
||||||
# def set_mail(self):
|
|
||||||
# email_template = self.comboBox.currentText()
|
|
||||||
# if email_template == "":
|
|
||||||
# return
|
|
||||||
# with open(f"mail_vorlagen/{email_template}", "r", encoding="utf-8") as f:
|
|
||||||
# mail_template = f.read()
|
|
||||||
# email_header = email_template.split(".eml")[0]
|
|
||||||
# if "{AppNr}" in email_template:
|
|
||||||
# email_header = email_template.split(".eml")[0]
|
|
||||||
# email_header = email_header.format(AppNr=self.appid, AppName=self.appname)
|
|
||||||
# self.mail_header.setText(email_header)
|
|
||||||
# self.mail_data = mail_template.split("<html>")[0]
|
|
||||||
# mail_html = mail_template.split("<html>")[1]
|
|
||||||
# mail_html = "<html>" + mail_html
|
|
||||||
# Appname = self.appname
|
|
||||||
# mail_html = mail_html.format(
|
|
||||||
# Profname=self.prof_name.text().split(" ")[-1],
|
|
||||||
# Appname=Appname,
|
|
||||||
# AppNr=self.appid,
|
|
||||||
# AppSubject=self.subject,
|
|
||||||
# greeting=self.get_greeting(),
|
|
||||||
# )
|
|
||||||
|
|
||||||
# self.mail_body.setHtml(mail_html)
|
|
||||||
|
|
||||||
# def createAndSendMail(self):
|
|
||||||
# import smtplib
|
|
||||||
# import ssl
|
|
||||||
# from email.mime.multipart import MIMEMultipart
|
|
||||||
# from email.mime.text import MIMEText
|
|
||||||
|
|
||||||
# smtp_server = config["mail"]["smtp_server"]
|
|
||||||
# port: int = config["mail"]["port"]
|
|
||||||
# sender_email = config["mail"]["sender"]
|
|
||||||
# password = config["mail"]["password"]
|
|
||||||
# message = MIMEMultipart()
|
|
||||||
# message["From"] = sender_email
|
|
||||||
# message["To"] = self.prof_mail
|
|
||||||
# message["Subject"] = self.mail_header.text()
|
|
||||||
# mail_body = self.mail_body.toHtml()
|
|
||||||
# message.attach(MIMEText(mail_body, "html"))
|
|
||||||
# mail = message.as_string()
|
|
||||||
|
|
||||||
# server = smtplib.SMTP_SSL(smtp_server, port)
|
|
||||||
# # server.starttls()
|
|
||||||
# # server.auth(mechanism="PLAIN")
|
|
||||||
# if config["mail"]["use_user_name"] == 1:
|
|
||||||
# print(config["mail"]["user_name"])
|
|
||||||
# server.login(config["mail"]["user_name"], password)
|
|
||||||
# else:
|
|
||||||
# server.login(sender_email, password)
|
|
||||||
# server.sendmail(sender_email, self.prof_mail, mail)
|
|
||||||
# print("Mail sent")
|
|
||||||
# # end active process
|
|
||||||
# server.quit()
|
|
||||||
|
|
||||||
|
|
||||||
class Medien(medienadder_ui):
|
class Medien(medienadder_ui):
|
||||||
def __init__(self) -> None:
|
def __init__(self) -> None:
|
||||||
self.logger = MyLogger("Medien")
|
self.logger = MyLogger("Medien")
|
||||||
@@ -197,25 +63,7 @@ class Medien(medienadder_ui):
|
|||||||
return self.comboBox.currentText()
|
return self.comboBox.currentText()
|
||||||
|
|
||||||
|
|
||||||
# class Setup(SetupWizard):
|
|
||||||
# def __init__(self, MainWindow):
|
|
||||||
# super().__init__()
|
|
||||||
# self.setupUi(MainWindow)
|
|
||||||
# self.settings = Settings()
|
|
||||||
# self.setWindowTitle("Semesterapparatsmanagement Setup")
|
|
||||||
# self.btn_save_path_select.clicked.connect(self.select_save_path)
|
|
||||||
# # self.setWindowIcon(QtGui.QIcon("ui\icon.png"))
|
|
||||||
|
|
||||||
|
|
||||||
# def select_save_path(self) -> None:
|
|
||||||
# # open a dialog to select a save path
|
|
||||||
# dialog = QtWidgets.QFileDialog()
|
|
||||||
# dialog.setFileMode(QtWidgets.QFileDialog.FileMode.Directory)
|
|
||||||
# dialog.setOption(QtWidgets.QFileDialog.Option.ShowDirsOnly)
|
|
||||||
# dialog.exec()
|
|
||||||
# self.settings.save_path = dialog.selectedFiles()[0]
|
|
||||||
# self.save_path.setText(self.settings.save_path)
|
|
||||||
# self.settings.save_settings()
|
|
||||||
class MyComboBox(QtWidgets.QComboBox):
|
class MyComboBox(QtWidgets.QComboBox):
|
||||||
|
|
||||||
def __init__(self, parent=None):
|
def __init__(self, parent=None):
|
||||||
@@ -474,7 +322,7 @@ class Ui(Ui_Semesterapparat):
|
|||||||
"title": title if title != "" else None,
|
"title": title if title != "" else None,
|
||||||
}
|
}
|
||||||
params = {key: value for key, value in params.items() if value is not None}
|
params = {key: value for key, value in params.items() if value is not None}
|
||||||
ic(params)
|
#ic(params)
|
||||||
retdata = self.db.searchBook(params)
|
retdata = self.db.searchBook(params)
|
||||||
if retdata is None:
|
if retdata is None:
|
||||||
return
|
return
|
||||||
@@ -530,7 +378,7 @@ class Ui(Ui_Semesterapparat):
|
|||||||
password = self.user_create_frame_password.text()
|
password = self.user_create_frame_password.text()
|
||||||
role = self.user_frame_userrole.currentText()
|
role = self.user_frame_userrole.currentText()
|
||||||
if self.db.checkUsername(username):
|
if self.db.checkUsername(username):
|
||||||
ic("username already exists")
|
#ic("username already exists")
|
||||||
# self.user_create_frame_error.setText("Der Nutzername ist bereits vergeben")#TODO: implement error message
|
# self.user_create_frame_error.setText("Der Nutzername ist bereits vergeben")#TODO: implement error message
|
||||||
return
|
return
|
||||||
userdata = AdminCommands().create_password(password)
|
userdata = AdminCommands().create_password(password)
|
||||||
@@ -554,8 +402,8 @@ class Ui(Ui_Semesterapparat):
|
|||||||
)
|
)
|
||||||
self.user_delete_confirm.setChecked(False)
|
self.user_delete_confirm.setChecked(False)
|
||||||
else:
|
else:
|
||||||
# self.user_delete_err_message.setText("Bitte bestätigen Sie die Löschung des Nutzers") # TODO: implement error message
|
self.user_delete_err_message.setText("Bitte bestätigen Sie die Löschung des Nutzers") # TODO: implement error message
|
||||||
ic("please confirm the deletion of the user")
|
#ic("please confirm the deletion of the user")
|
||||||
|
|
||||||
def update_user_data(self):
|
def update_user_data(self):
|
||||||
username = self.user_edit_frame_user_select.currentText()
|
username = self.user_edit_frame_user_select.currentText()
|
||||||
@@ -600,8 +448,8 @@ class Ui(Ui_Semesterapparat):
|
|||||||
olddata = self.db.getFacultyMember(
|
olddata = self.db.getFacultyMember(
|
||||||
self.edit_faculty_member_select_member.currentText()
|
self.edit_faculty_member_select_member.currentText()
|
||||||
)
|
)
|
||||||
|
ic(olddata)
|
||||||
data = olddata[0]
|
data = olddata
|
||||||
oldlname = data[2]
|
oldlname = data[2]
|
||||||
oldfname = data[1]
|
oldfname = data[1]
|
||||||
# take data except first and last entry
|
# take data except first and last entry
|
||||||
@@ -626,8 +474,8 @@ class Ui(Ui_Semesterapparat):
|
|||||||
.strip()
|
.strip()
|
||||||
)
|
)
|
||||||
fullname = __gen_fullname(fname, lname, data)
|
fullname = __gen_fullname(fname, lname, data)
|
||||||
mail = self.user_faculty_member_new_telnr.text()
|
telnr = self.user_faculty_member_new_telnr.text()
|
||||||
telnr = self.user_faculty_member_new_mail.text()
|
mail = self.user_faculty_member_new_mail.text()
|
||||||
new_data = {
|
new_data = {
|
||||||
"titel": titel,
|
"titel": titel,
|
||||||
"fname": fname,
|
"fname": fname,
|
||||||
@@ -994,7 +842,7 @@ class Ui(Ui_Semesterapparat):
|
|||||||
|
|
||||||
def populate_frame(self, appdata: ApparatData):
|
def populate_frame(self, appdata: ApparatData):
|
||||||
# populate the frame with the data from the database
|
# populate the frame with the data from the database
|
||||||
ic(appdata)
|
#ic(appdata)
|
||||||
self.drpdwn_app_nr.setCurrentText(str(appdata.appnr))
|
self.drpdwn_app_nr.setCurrentText(str(appdata.appnr))
|
||||||
self.prof_title.setText(appdata.prof_title)
|
self.prof_title.setText(appdata.prof_title)
|
||||||
prof_name = appdata.profname.split(" ")
|
prof_name = appdata.profname.split(" ")
|
||||||
@@ -1204,7 +1052,7 @@ class Ui(Ui_Semesterapparat):
|
|||||||
return
|
return
|
||||||
selected_prof = self.drpdwn_prof_name.currentText()
|
selected_prof = self.drpdwn_prof_name.currentText()
|
||||||
data = self.db.getProfData(selected_prof)
|
data = self.db.getProfData(selected_prof)
|
||||||
ic(data)
|
#ic(data)
|
||||||
prof_title = data[2]
|
prof_title = data[2]
|
||||||
if prof_title == "None":
|
if prof_title == "None":
|
||||||
prof_title = "Kein Titel"
|
prof_title = "Kein Titel"
|
||||||
@@ -1739,7 +1587,7 @@ class Ui(Ui_Semesterapparat):
|
|||||||
]
|
]
|
||||||
|
|
||||||
signatures = [i for i in signatures if i != ""]
|
signatures = [i for i in signatures if i != ""]
|
||||||
ic(signatures)
|
#ic(signatures)
|
||||||
print("starting thread")
|
print("starting thread")
|
||||||
self.autoGrabber = BookGrabber(
|
self.autoGrabber = BookGrabber(
|
||||||
mode="ARRAY", app_id=app_id, prof_id=prof_id, data=signatures
|
mode="ARRAY", app_id=app_id, prof_id=prof_id, data=signatures
|
||||||
@@ -1870,7 +1718,7 @@ class Ui(Ui_Semesterapparat):
|
|||||||
self.old_apparats = self.apparats
|
self.old_apparats = self.apparats
|
||||||
|
|
||||||
def insert_apparat_into_table(self, apparat):
|
def insert_apparat_into_table(self, apparat):
|
||||||
ic(apparat)
|
#ic(apparat)
|
||||||
|
|
||||||
def __dauer_check(apparat):
|
def __dauer_check(apparat):
|
||||||
return "Ja" if apparat[7] == 1 else "Nein"
|
return "Ja" if apparat[7] == 1 else "Nein"
|
||||||
@@ -2269,5 +2117,6 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user