Add bookGrabber, availChecker, and autoGrabber as instance variables
This commit is contained in:
@@ -309,6 +309,10 @@ class Ui(Ui_Semesterapparat):
|
|||||||
self.update_user.clicked.connect(self.update_user_data)
|
self.update_user.clicked.connect(self.update_user_data)
|
||||||
self.update_faculty_member.clicked.connect(self.edit_faculty_member_action)
|
self.update_faculty_member.clicked.connect(self.edit_faculty_member_action)
|
||||||
|
|
||||||
|
self.bookGrabber = None
|
||||||
|
self.availChecker = None
|
||||||
|
self.autoGrabber = None
|
||||||
|
|
||||||
def populate_appfach_dropdown(self):
|
def populate_appfach_dropdown(self):
|
||||||
self.app_fach.clear()
|
self.app_fach.clear()
|
||||||
self.app_fach.addItem("")
|
self.app_fach.addItem("")
|
||||||
@@ -1207,21 +1211,20 @@ class Ui(Ui_Semesterapparat):
|
|||||||
# create apparat
|
# create apparat
|
||||||
self.btn_save_apparat()
|
self.btn_save_apparat()
|
||||||
# create a thread that updates the progress label after each medium
|
# create a thread that updates the progress label after each medium
|
||||||
grabber = BookGrabber(mode=mode, app_id=app_id, prof_id=prof_id, data=data)
|
self.bookGrabber = BookGrabber(
|
||||||
|
mode=mode, app_id=app_id, prof_id=prof_id, data=data
|
||||||
|
)
|
||||||
# grabber.mode = mode
|
# grabber.mode = mode
|
||||||
# grabber.data = data
|
# grabber.data = data
|
||||||
# grabber.app_id = app_id
|
# grabber.app_id = app_id
|
||||||
# grabber.prof_id = prof_id
|
# grabber.prof_id = prof_id
|
||||||
grabber.finished.connect(grabber.deleteLater)
|
self.bookGrabber.finished.connect(self.bookGrabber.deleteLater)
|
||||||
grabber.finished.connect(self.hide_progress_label)
|
self.bookGrabber.finished.connect(self.hide_progress_label)
|
||||||
grabber.finished.connect(self.update_app_media_list)
|
self.bookGrabber.finished.connect(self.update_app_media_list)
|
||||||
grabber.updateSignal.connect(self.update_progress_label)
|
self.bookGrabber.updateSignal.connect(self.update_progress_label)
|
||||||
|
|
||||||
grabber.start()
|
self.bookGrabber.start()
|
||||||
# run grabber.deletelater
|
# run grabber.deletelater
|
||||||
grabber.stop()
|
|
||||||
grabber.wait()
|
|
||||||
grabber.quit()
|
|
||||||
|
|
||||||
# for book in data:
|
# for book in data:
|
||||||
# # self.progress_label.setText(f"Medium {ct}/{len(data)}")
|
# # self.progress_label.setText(f"Medium {ct}/{len(data)}")
|
||||||
@@ -1238,7 +1241,7 @@ class Ui(Ui_Semesterapparat):
|
|||||||
return
|
return
|
||||||
|
|
||||||
def check_availability(self):
|
def check_availability(self):
|
||||||
self.threadeds.clear()
|
# self.threadeds.clear()
|
||||||
|
|
||||||
def _update_progress(current, all_titles):
|
def _update_progress(current, all_titles):
|
||||||
self.avail_status.setText("{}/{}".format(current, all_titles))
|
self.avail_status.setText("{}/{}".format(current, all_titles))
|
||||||
@@ -1277,18 +1280,18 @@ class Ui(Ui_Semesterapparat):
|
|||||||
# thread = QThread()
|
# thread = QThread()
|
||||||
appnumber = self.active_apparat
|
appnumber = self.active_apparat
|
||||||
print(links)
|
print(links)
|
||||||
availcheck = AvailChecker(links, appnumber, books=books)
|
self.availChecker = AvailChecker(links, appnumber, books=books)
|
||||||
# availcheck.moveToThread(thread)
|
# availcheck.moveToThread(thread)
|
||||||
# availcheck.finished.connect(thread.quit)
|
# availcheck.finished.connect(thread.quit)
|
||||||
availcheck.finished.connect(availcheck.deleteLater)
|
self.availChecker.finished.connect(self.availChecker.deleteLater)
|
||||||
availcheck.finished.connect(self.update_app_media_list)
|
self.availChecker.finished.connect(self.update_app_media_list)
|
||||||
availcheck.updateProgress.connect(_update_progress)
|
self.availChecker.updateProgress.connect(_update_progress)
|
||||||
availcheck.finished.connect(_hide_progress_label)
|
self.availChecker.finished.connect(_hide_progress_label)
|
||||||
availcheck.start()
|
self.availChecker.start()
|
||||||
# kill availcheck after completion
|
# kill availcheck after completion
|
||||||
|
|
||||||
# self.threadeds.append(thread)
|
# self.threadeds.append(thread)
|
||||||
self.grabbers.append(availcheck)
|
# self.grabbers.append(availcheck)
|
||||||
|
|
||||||
def btn_cancel_active_selection(self):
|
def btn_cancel_active_selection(self):
|
||||||
# clear the rows of the table
|
# clear the rows of the table
|
||||||
@@ -1604,7 +1607,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")
|
||||||
grabber = 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
|
||||||
)
|
)
|
||||||
# grabber.mode = "ARRAY"
|
# grabber.mode = "ARRAY"
|
||||||
@@ -1616,18 +1619,14 @@ class Ui(Ui_Semesterapparat):
|
|||||||
self.progress_label.show()
|
self.progress_label.show()
|
||||||
self.line_2.show()
|
self.line_2.show()
|
||||||
# grabber.finished.connect(thread.quit)
|
# grabber.finished.connect(thread.quit)
|
||||||
grabber.finished.connect(grabber.deleteLater)
|
self.autoGrabber.finished.connect(self.autoGrabber.deleteLater)
|
||||||
grabber.finished.connect(self.hide_progress_label)
|
self.autoGrabber.finished.connect(self.hide_progress_label)
|
||||||
grabber.finished.connect(self.update_app_media_list)
|
self.autoGrabber.finished.connect(self.update_app_media_list)
|
||||||
grabber.finished.connect(self.unlock_apparate)
|
self.autoGrabber.finished.connect(self.unlock_apparate)
|
||||||
grabber.updateSignal.connect(self.update_progress_label)
|
self.autoGrabber.updateSignal.connect(self.update_progress_label)
|
||||||
# worker.finished.connect(worker.deleteLater)
|
# worker.finished.connect(worker.deleteLater)
|
||||||
|
|
||||||
grabber.start()
|
self.autoGrabber.start()
|
||||||
if grabber.is_Running is False:
|
|
||||||
grabber.quit()
|
|
||||||
grabber.wait()
|
|
||||||
grabber.deleteLater()
|
|
||||||
# self.thread = thread
|
# self.thread = thread
|
||||||
# kill grabber after completion
|
# kill grabber after completion
|
||||||
# self.grabbers.append(grabber)
|
# self.grabbers.append(grabber)
|
||||||
@@ -1692,9 +1691,9 @@ class Ui(Ui_Semesterapparat):
|
|||||||
|
|
||||||
# self.btn_load_apparat()
|
# self.btn_load_apparat()
|
||||||
|
|
||||||
__clear_fields()
|
|
||||||
if self.check_send_mail.isChecked():
|
if self.check_send_mail.isChecked():
|
||||||
self.contact_prof()
|
self.contact_prof(apparat=appd.appnr)
|
||||||
|
__clear_fields()
|
||||||
|
|
||||||
def send_mail_preview(self):
|
def send_mail_preview(self):
|
||||||
pass
|
pass
|
||||||
@@ -1942,6 +1941,7 @@ class Ui(Ui_Semesterapparat):
|
|||||||
if state == 1:
|
if state == 1:
|
||||||
self.db.deleteBook(book_id)
|
self.db.deleteBook(book_id)
|
||||||
self.update_app_media_list()
|
self.update_app_media_list()
|
||||||
|
self.contact_prof(mail="deleted")
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
# get all selected rows
|
# get all selected rows
|
||||||
@@ -1993,34 +1993,33 @@ class Ui(Ui_Semesterapparat):
|
|||||||
else:
|
else:
|
||||||
return
|
return
|
||||||
|
|
||||||
def contact_prof(self):
|
def contact_prof(self, apparat=None, mail=""):
|
||||||
if self.active_apparat == "":
|
if self.active_apparat == "":
|
||||||
self.confirm_popup("Bitte erst einen Apparat auswählen!")
|
if apparat is None:
|
||||||
return
|
self.confirm_popup("Bitte erst einen Apparat auswählen!")
|
||||||
|
return
|
||||||
dialog = QtWidgets.QDialog()
|
dialog = QtWidgets.QDialog()
|
||||||
mail_prevs = os.listdir("mail_vorlagen")
|
|
||||||
if self.app_name.text() == "":
|
active_apparat_id = (
|
||||||
mail_prevs.remove("Information zum Semesterapparat.eml")
|
self.tableWidget_apparate.item(
|
||||||
active_apparat_id = self.tableWidget_apparate.item(
|
self.tableWidget_apparate.currentRow(), 0
|
||||||
self.tableWidget_apparate.currentRow(), 0
|
).text()
|
||||||
).text()
|
if apparat is None
|
||||||
general_data = {
|
else apparat
|
||||||
"AppName": self.app_name.text(),
|
)
|
||||||
"AppSubject": self.app_fach.currentText(),
|
|
||||||
"AppNr": active_apparat_id,
|
|
||||||
}
|
|
||||||
print(active_apparat_id)
|
print(active_apparat_id)
|
||||||
profname = self.drpdwn_prof_name.currentText().replace(",", "")
|
profname = self.drpdwn_prof_name.currentText().replace(",", "").split(" ")
|
||||||
profname = profname.split(" ")
|
|
||||||
profname = f"{profname[1]} {profname[0]}"
|
profname = f"{profname[1]} {profname[0]}"
|
||||||
prof_id = self.db.getProfId(self.drpdwn_prof_name.currentText())
|
prof_id = self.db.getProfId(self.drpdwn_prof_name.currentText())
|
||||||
mail = self.db.getSpecificProfData(prof_id, ["mail"])
|
mail = self.db.getSpecificProfData(prof_id, ["mail"])
|
||||||
pass_data = {
|
pass_data = {
|
||||||
"prof_name": profname,
|
"prof_name": profname,
|
||||||
"mail_name": mail,
|
"mail_name": mail,
|
||||||
"general": general_data,
|
|
||||||
}
|
}
|
||||||
|
print(
|
||||||
|
profname,
|
||||||
|
mail,
|
||||||
|
)
|
||||||
mail_prev = Mail_Dialog(
|
mail_prev = Mail_Dialog(
|
||||||
app_id=self.active_apparat,
|
app_id=self.active_apparat,
|
||||||
data=pass_data,
|
data=pass_data,
|
||||||
@@ -2028,7 +2027,6 @@ class Ui(Ui_Semesterapparat):
|
|||||||
app_subject=self.app_fach.currentText(),
|
app_subject=self.app_fach.currentText(),
|
||||||
)
|
)
|
||||||
mail_prev.setupUi(dialog)
|
mail_prev.setupUi(dialog)
|
||||||
mail_prev.comboBox.addItems(mail_prevs)
|
|
||||||
mail_prev.set_mail()
|
mail_prev.set_mail()
|
||||||
dialog.exec()
|
dialog.exec()
|
||||||
|
|
||||||
@@ -2050,6 +2048,8 @@ class Ui(Ui_Semesterapparat):
|
|||||||
print(self.apparats)
|
print(self.apparats)
|
||||||
# remove the row from the table
|
# remove the row from the table
|
||||||
self.tableWidget_apparate.removeRow(self.tableWidget_apparate.currentRow())
|
self.tableWidget_apparate.removeRow(self.tableWidget_apparate.currentRow())
|
||||||
|
# send mail to prof
|
||||||
|
self.contact_prof(mail="deleted", apparat=selected_apparat_id)
|
||||||
# if state==QtWidgets.QDialog.DialogCode.Accepted:
|
# if state==QtWidgets.QDialog.DialogCode.Accepted:
|
||||||
# self.db.delete_apparat(selected_apparat_id)
|
# self.db.delete_apparat(selected_apparat_id)
|
||||||
# pass
|
# pass
|
||||||
|
|||||||
Reference in New Issue
Block a user