From dc60c175ac31088c25b3bf1188c36ed995411fc3 Mon Sep 17 00:00:00 2001 From: ThunderingWest4 Date: Tue, 19 Jul 2022 15:18:43 -0400 Subject: [PATCH 1/5] window working. multiuthreading isnt :( --- src/qtWin.ui | 175 +++++++++++++++++++++++++++++++++++++++++++++++++ src/winMain.py | 77 ++++++++++++++++++++++ 2 files changed, 252 insertions(+) create mode 100644 src/qtWin.ui create mode 100644 src/winMain.py diff --git a/src/qtWin.ui b/src/qtWin.ui new file mode 100644 index 0000000..ea5e86c --- /dev/null +++ b/src/qtWin.ui @@ -0,0 +1,175 @@ + + + Dialog + + + + 0 + 0 + 462 + 313 + + + + Dialog + + + + + 370 + 20 + 81 + 41 + + + + Add Course + + + + + + 10 + 90 + 441 + 181 + + + + true + + + + + 0 + 0 + 439 + 179 + + + + + + + + 180 + 60 + 121 + 21 + + + + Tracking Courses + + + + + + 110 + 280 + 231 + 23 + + + + Start Tracking (Will notify when slots open) + + + + + + 150 + 30 + 91 + 21 + + + + + fall + + + + + winter + + + + + spring + + + + + + + 260 + 30 + 91 + 21 + + + + + Open Seats + + + + + Open Waitlist + + + + + + + 160 + 10 + 121 + 16 + + + + Season/Term + + + + + + 270 + 10 + 101 + 16 + + + + Type of Tracking + + + + + + 10 + 30 + 113 + 20 + + + + + + + 50 + 10 + 47 + 13 + + + + CRN + + + + + + diff --git a/src/winMain.py b/src/winMain.py new file mode 100644 index 0000000..e36307f --- /dev/null +++ b/src/winMain.py @@ -0,0 +1,77 @@ +from multiprocessing.connection import wait +from PyQt5.QtWidgets import * +from PyQt5 import uic +from courses import * +import threading +# import multiprocessing +from datetime import datetime + +courses = {} +openCourse = [] +waitlistCourse = [] + +class Ui(QDialog): + def __init__(self): + super(Ui, self).__init__() # Call the inherited classes __init__ method + uic.loadUi('src\qtWin.ui', self) # Load the .ui file + + self.courseList = self.findChild(QScrollArea, 'courseList') + self.courseList.setWidget(QListWidget()) + + self.addBtn = self.findChild(QPushButton, 'addCourse') + self.addBtn.clicked.connect(self.newCourse) + + self.track = self.findChild(QPushButton, 'startTracking') + self.track.clicked.connect(self.startTrack) + + self.show() # Show the GUI + + def newCourse(self): + crn = self.findChild(QLineEdit, 'CRN').text() + sem = self.findChild(QComboBox, 'term').currentText() + + now = datetime.now() + term = "" + if sem.lower() == 'spring': + term = f'{now.year + 1}' + '02' if now.month > 4 else f'{now.year}' + '02' + else: + term = f'{now.year}' + '05' if sem.lower() == 'summer' else f'{now.year}' + '08' + + typeTrack = self.findChild(QComboBox, 'trackType').currentText() + # print(crn, sem, term, typeTrack) + crs = Course(crn, term) + courses[crs] = typeTrack + self.courseList.widget().addItem(f"{crs.name} | {sem}") + + def startTrack(self): + for c in courses.keys(): + if courses[c] == "Open Seats": + openCourse.append(c) + else: + # has to be Open Waitlist, only two options on dropdown + waitlistCourse.append(c) + + # all notifiers created + # we can now watch the sun set on a grateful universe + self.close() + + + +app = QApplication([]) +win = Ui() +win.setWindowTitle("Grouch UI") +app.exec_() +app.exit() + +openCList = CourseList(openCourse) +openWList = CourseList(waitlistCourse) + +# multiprocessing.Process(target=openCList.run_available_courses).start() +# multiprocessing.Process(target=openWList.run_waitlist_notifiers).start() +threading.Thread(target=openCList.run_available_courses).start() +threading.Thread(target=openWList.run_waitlist_notifiers).start() + +print("woooooo") + +# while True: +# pass \ No newline at end of file From 378dd1664446c20d6f1e319fb331cbc089e4cd19 Mon Sep 17 00:00:00 2001 From: aaravg04 Date: Tue, 19 Jul 2022 15:39:51 -0400 Subject: [PATCH 2/5] removed broken multithreading, now tracks correctly (i think) --- src/qtWin.ui | 24 +++++++++++++----------- src/winMain.py | 35 ++++++++++++++++++++--------------- 2 files changed, 33 insertions(+), 26 deletions(-) diff --git a/src/qtWin.ui b/src/qtWin.ui index ea5e86c..c821c15 100644 --- a/src/qtWin.ui +++ b/src/qtWin.ui @@ -100,7 +100,9 @@ - + + + - 270 + 160 10 - 101 + 121 16 - Type of Tracking + Season/Term diff --git a/src/winMain.py b/src/winMain.py index e36307f..1fe17eb 100644 --- a/src/winMain.py +++ b/src/winMain.py @@ -7,8 +7,9 @@ from datetime import datetime courses = {} -openCourse = [] -waitlistCourse = [] +# openCourse = [] +# waitlistCourse = [] +fullList = [] class Ui(QDialog): def __init__(self): @@ -37,19 +38,20 @@ def newCourse(self): else: term = f'{now.year}' + '05' if sem.lower() == 'summer' else f'{now.year}' + '08' - typeTrack = self.findChild(QComboBox, 'trackType').currentText() + # typeTrack = self.findChild(QComboBox, 'trackType').currentText() # print(crn, sem, term, typeTrack) crs = Course(crn, term) - courses[crs] = typeTrack + fullList.append(crs) + # courses[crs] = typeTrack self.courseList.widget().addItem(f"{crs.name} | {sem}") def startTrack(self): - for c in courses.keys(): - if courses[c] == "Open Seats": - openCourse.append(c) - else: - # has to be Open Waitlist, only two options on dropdown - waitlistCourse.append(c) + # for c in courses.keys(): + # if courses[c] == "Open Seats": + # openCourse.append(c) + # else: + # # has to be Open Waitlist, only two options on dropdown + # waitlistCourse.append(c) # all notifiers created # we can now watch the sun set on a grateful universe @@ -63,15 +65,18 @@ def startTrack(self): app.exec_() app.exit() -openCList = CourseList(openCourse) -openWList = CourseList(waitlistCourse) +# openCList = CourseList(openCourse) +# openWList = CourseList(waitlistCourse) # multiprocessing.Process(target=openCList.run_available_courses).start() # multiprocessing.Process(target=openWList.run_waitlist_notifiers).start() -threading.Thread(target=openCList.run_available_courses).start() -threading.Thread(target=openWList.run_waitlist_notifiers).start() +# threading.Thread(target=openCList.run_available_courses).start() +# threading.Thread(target=openWList.run_waitlist_notifiers).start() -print("woooooo") +# print("woooooo") + +# fullList = openCourse + waitlistCourse +CourseList(fullList).run_notifiers() # while True: # pass \ No newline at end of file From 366300969f7fd604161358d3cdd3a4e59f351345 Mon Sep 17 00:00:00 2001 From: aaravg04 Date: Tue, 19 Jul 2022 15:53:32 -0400 Subject: [PATCH 3/5] popup+cont if crn not found instead of crashing --- src/winMain.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/winMain.py b/src/winMain.py index 1fe17eb..1051925 100644 --- a/src/winMain.py +++ b/src/winMain.py @@ -40,10 +40,16 @@ def newCourse(self): # typeTrack = self.findChild(QComboBox, 'trackType').currentText() # print(crn, sem, term, typeTrack) - crs = Course(crn, term) - fullList.append(crs) - # courses[crs] = typeTrack - self.courseList.widget().addItem(f"{crs.name} | {sem}") + try: + crs = Course(crn, term) + fullList.append(crs) + # courses[crs] = typeTrack + self.courseList.widget().addItem(f"{crs.name} | {sem}") + except IndexError: + alrt = QMessageBox() + alrt.setWindowTitle("Error") + alrt.setText(f"CRN {crn} not found") + x = alrt.exec_() def startTrack(self): # for c in courses.keys(): From e27b121e12c38f236596e986068dea6376906132 Mon Sep 17 00:00:00 2001 From: aaravg04 Date: Sat, 23 Jul 2022 01:21:33 -0400 Subject: [PATCH 4/5] cleaned up code, added remove course capability, can now set term --- src/qtWin.ui | 100 ++++++++++++++++++++++++---------------------- src/winMain.py | 106 +++++++++++++++++++++++++++++++++---------------- 2 files changed, 124 insertions(+), 82 deletions(-) diff --git a/src/qtWin.ui b/src/qtWin.ui index c821c15..5deee06 100644 --- a/src/qtWin.ui +++ b/src/qtWin.ui @@ -7,7 +7,7 @@ 0 0 462 - 313 + 367 @@ -16,7 +16,7 @@ - 370 + 360 20 81 41 @@ -30,7 +30,7 @@ 10 - 90 + 130 441 181 @@ -52,21 +52,21 @@ - 180 - 60 + 10 + 100 121 21 - Tracking Courses + Tracking Courses: - 110 - 280 + 10 + 330 231 23 @@ -78,9 +78,9 @@ - 150 + 10 30 - 91 + 81 21 @@ -100,45 +100,10 @@ - - - 160 + 60 10 121 16 @@ -151,7 +116,7 @@ - 10 + 230 30 113 20 @@ -161,7 +126,7 @@ - 50 + 270 10 47 13 @@ -171,6 +136,45 @@ CRN + + + + 100 + 30 + 61 + 21 + + + + Set Term + + + + + + 10 + 60 + 101 + 16 + + + + Current Term: none + + + + + + 270 + 330 + 171 + 21 + + + + Remove Selected Courses + + diff --git a/src/winMain.py b/src/winMain.py index 1051925..1a896b6 100644 --- a/src/winMain.py +++ b/src/winMain.py @@ -10,61 +10,97 @@ # openCourse = [] # waitlistCourse = [] fullList = [] +fullDict = {} + +# TODO: MAKE THING SO THEY CAN REMOVE CRNs class Ui(QDialog): def __init__(self): super(Ui, self).__init__() # Call the inherited classes __init__ method uic.loadUi('src\qtWin.ui', self) # Load the .ui file + # find QScrollArea (list where courses added to) self.courseList = self.findChild(QScrollArea, 'courseList') self.courseList.setWidget(QListWidget()) + # binding button to method self.addBtn = self.findChild(QPushButton, 'addCourse') self.addBtn.clicked.connect(self.newCourse) + # binding term button to method + self.termBtn = self.findChild(QPushButton, 'setTerm') + self.termBtn.clicked.connect(self.tSet) + + # binding button to close window method, starts tracking courses self.track = self.findChild(QPushButton, 'startTracking') - self.track.clicked.connect(self.startTrack) + self.track.clicked.connect(self.close) + + self.dCourse = self.findChild(QPushButton, "delCourse") + self.dCourse.clicked.connect(self.rmvCourse) + + self.term = "" self.show() # Show the GUI def newCourse(self): - crn = self.findChild(QLineEdit, 'CRN').text() + if self.term == "": + # check if user confirmed/set a term to search for CRNs during + alrt = QMessageBox() + alrt.setWindowTitle("Error") + alrt.setText(f"Term not set (choose from dropdown and click \"Set Term\")") + x = alrt.exec_() + + else: + crn = self.findChild(QLineEdit, 'CRN').text() + + try: + # create Course item and add to list to be tracked + crs = Course(crn, self.term) + # add to dictionary for fast removal if necessary + fullDict[crn] = crs + + # add item to list in QScrollArea + self.courseList.widget().addItem(crs.name) + except IndexError: + # means something wacky happened and oscar didn't have course + alrt = QMessageBox() + alrt.setWindowTitle("Error") + alrt.setText(f"CRN {crn} not found") + x = alrt.exec_() + + def tSet(self): + # grab the term from dropdown sem = self.findChild(QComboBox, 'term').currentText() - now = datetime.now() - term = "" + + # use parsing definitely not ctrl-c ctrl-v from tracking.py to change fall/spring/summer to a oscar acceptable format if sem.lower() == 'spring': - term = f'{now.year + 1}' + '02' if now.month > 4 else f'{now.year}' + '02' + self.term = f'{now.year + 1}' + '02' if now.month > 4 else f'{now.year}' + '02' else: - term = f'{now.year}' + '05' if sem.lower() == 'summer' else f'{now.year}' + '08' - - # typeTrack = self.findChild(QComboBox, 'trackType').currentText() - # print(crn, sem, term, typeTrack) - try: - crs = Course(crn, term) - fullList.append(crs) - # courses[crs] = typeTrack - self.courseList.widget().addItem(f"{crs.name} | {sem}") - except IndexError: - alrt = QMessageBox() - alrt.setWindowTitle("Error") - alrt.setText(f"CRN {crn} not found") - x = alrt.exec_() + self.term = f'{now.year}' + '05' if sem.lower() == 'summer' else f'{now.year}' + '08' - def startTrack(self): - # for c in courses.keys(): - # if courses[c] == "Open Seats": - # openCourse.append(c) - # else: - # # has to be Open Waitlist, only two options on dropdown - # waitlistCourse.append(c) - - # all notifiers created - # we can now watch the sun set on a grateful universe - self.close() + # changing label to reflect term + self.findChild(QLabel, 'curTerm').setText(f"Current Term: {sem}") + + # small popup to confirm term set + # gets annoying after a while though + # alrt = QMessageBox() + # alrt.setWindowTitle("Term Set!") + # alrt.setText(f"Term set to {self.term} ({sem})") + # x = alrt.exec_() + + def rmvCourse(self): + # track all selected indices in QScrollArea + selected = self.courseList.widget().selectedIndexes() + # for each selection, grab data, remove CRN from fullDict (won't track) and remove from QScrollArea + for ind in selected: + inf = ind.data() + crn = inf.split(" - ")[1] + fullDict.pop(crn) + self.courseList.widget().takeItem(ind.row()) - +# generic driver code app = QApplication([]) win = Ui() win.setWindowTitle("Grouch UI") @@ -82,7 +118,9 @@ def startTrack(self): # print("woooooo") # fullList = openCourse + waitlistCourse -CourseList(fullList).run_notifiers() -# while True: -# pass \ No newline at end of file +# create CourseList of courses and run notifiers +# future goal: use multithreading or something to concurrently run waitlist and open course trackers (wasn't able to initially get working) +# so you can track waitlists of some sections (i.e. lab blocks) while checking openings of others (i.e. general lecture blocks) +fullList = [fullDict[x] for x in fullDict.keys()] +CourseList(fullList).run_notifiers() From 1b3d2dd0d8513f4e8ba09be626ddd9ee10efe958 Mon Sep 17 00:00:00 2001 From: aaravg04 Date: Sat, 23 Jul 2022 01:28:17 -0400 Subject: [PATCH 5/5] added qtpy to requirements, stopped importing useless libraries --- requirements-linux.txt | Bin 286 -> 312 bytes requirements-unix.txt | Bin 286 -> 312 bytes requirements-windows.txt | Bin 380 -> 406 bytes src/winMain.py | 4 ++-- 4 files changed, 2 insertions(+), 2 deletions(-) diff --git a/requirements-linux.txt b/requirements-linux.txt index 5f66a2de8944a14bf3eff9485c1bb0e63e0839fa..8efcb750c8186c55ee2088849a47768fbf228688 100644 GIT binary patch delta 34 kcmbQow1a7b9HUeKLnT8XLkWW^gDnu6GUzcFf=Lqw0DcMutN;K2 delta 7 OcmdnNG>>V693ub>V693ubv&f4Wm>5LnT8XLkWW^gDnu6GUzcFf=Lqw0Fes@M*si- delta 7 OcmbQn{D)~n4I=;yFapH@ diff --git a/src/winMain.py b/src/winMain.py index 1a896b6..d6f19b6 100644 --- a/src/winMain.py +++ b/src/winMain.py @@ -1,8 +1,8 @@ -from multiprocessing.connection import wait +# from multiprocessing.connection import wait from PyQt5.QtWidgets import * from PyQt5 import uic from courses import * -import threading +# import threading # import multiprocessing from datetime import datetime