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