async def get(ctx, mp=2): if mp < 0: mp = 0 if mp > 4: mp = 4 mp -= 1 print(mp) q = query("""select * from users where id == ?""", ctx.message.author.id) if len(q) == 0: await msg(ctx, ctx.message.author) return u = q[0]['username'] p = f.decrypt(q[0]['password']).decode() d = q[0]['domain'] sv = StudentVue(u, p, d) gb = sv.get_gradebook(mp)['Gradebook']['Courses']['Course'] grades = [] for t in gb: vals = ['', '', ''] for key, value in t.items(): if key == '@Title': vals[0] = value if key == 'Marks': for i in value['Mark']: nextent = False for j in i.items(): if j[0] == '@MarkName' and j[1][:2] == 'MP': nextent = True if nextent: if j[0] == '@CalculatedScoreString': vals[1] = j[1] if j[0] == '@CalculatedScoreRaw': vals[2] = j[1] nextent = False grades.append(vals) res = "```Your Grades (quarter " + str(mp + 1) + "):\n" table = PrettyTable() table.field_names = ["Class", "Letter Grade", "Exact Grade"] for a in grades: table.add_row(a) table.align = "l" res += str(table) res += "```" await ctx.send(res)
def get_schedule(credentials): # Login to Student Vue try: sv = StudentVue(credentials[0], credentials[1], credentials[2]) except IndexError: click.echo( 'Invalid credentials. You can reset your credentials with:\n python assignment_list.py reset') sys.exit() return sv.get_schedule()
def __init__(self, stdscreen): self.screen = stdscreen curses.curs_set(0) stdscreen.scrollok(0) stdscreen.keypad(True) curses.init_pair(1, curses.COLOR_GREEN, curses.COLOR_WHITE) curses.init_pair(2, curses.COLOR_RED, curses.COLOR_WHITE) start_load(stdscreen) credentials = (os.environ['STUDENTVUE_USER'], os.environ['STUDENTVUE_PASS'], os.environ['STUDENTVUE_DOMAIN']) studentvue = StudentVue(*credentials) stop_event = threading.Event() menu_thread = threading.Thread(target=run_menu, args=(studentvue, stop_event, stdscreen)) menu_thread.setDaemon(True) menu_thread.start() marquee_thread = threading.Thread(target=run_marquee, args=(studentvue, stop_event, stdscreen)) marquee_thread.setDaemon(True) marquee_thread.start() while not stop_event.is_set(): pass
def authenticate(): try: sv = StudentVue(request.form.get('username'), request.form.get('password'), 'portal.sfusd.edu') except ValueError: return render_template('index.html', error='Incorrect Username or Password.') except Exception: return render_template('index.html', error='Unexpected Error.') session['StudentVue'] = sv return redirect(url_for('home'))
def __init__(self, username="", password="", domain=""): cf = ConfigParser() p = os.path.join(os.path.dirname(__file__), "config.ini") cf.read(p) if username == "": username = input("Student ID -> ") if password == "": password = bullet.Password("Password -> ").launch() if domain == "": if not os.path.exists(p) or cf.get("values", "domain") == "": domain = input("District Edupoint Domain -> ") if not os.path.exists(p): cf.add_section("values") cf.set("values", "domain", domain) with open(p, "w+") as configfile: cf.write(configfile) else: domain = cf.get("values", "domain") self.sv = StudentVue( username, password, domain, )
def get_assignments(credentials): assignments = get_stored_assignment_data() # Login to Student Vue try: sv = StudentVue(credentials[0], credentials[1], credentials[2]) except IndexError: click.echo( 'Invalid credentials. You might want to use:\n python assignment_list.py reset') sys.exit() try: studentvue_assignments = sv.get_assignments() except Exception: click.echo( 'Failed to get Student Vue assignments... Please see https://github.com/kajchang/StudentVue for help on ' 'this issue.') sys.exit() found_duplicate = False for sv_assignment in studentvue_assignments: setattr(sv_assignment, 'date', str(sv_assignment.date.day) + '/' + str(sv_assignment.date.month) + '/' + str(sv_assignment.date.year)) for assignment_id in assignments['Assignment ID']: if sv_assignment.assignment_id == assignment_id: found_duplicate = True if not found_duplicate: assignment_df = pd.DataFrame( { 'Assignment ID': [ sv_assignment.assignment_id], 'Class Name': [ sv_assignment.class_name], 'Due Date': [ sv_assignment.date], 'Assignment': [ sv_assignment.name], 'is_completed': ['False']}) assignments = assignments.append(assignment_df, sort=True) convert_dict = {'Assignment ID': int} assignments = assignments.astype(convert_dict) assignment_list.update_csv(assignments) return assignments
def getStudentVueData(): username = IntPrompt.ask('Enter your user id') pwd = Prompt.ask('Enter your password') domain = 'https://md-mcps-psv.edupoint.com' remember = Confirm.ask('Do you want to be remembered?') studentvue_client = StudentVue(str(username), pwd, domain) while 'RT_ERROR' in studentvue_client.get_gradebook().keys(): text = Text('Username or password is incorrect. Try again') text.stylize(style="red") console.print(text) username = IntPrompt.ask('Enter your user id') pwd = Prompt.ask('Enter your password') studentvue_client = StudentVue(str(username), pwd, domain) return studentvue_client.get_gradebook()
content[2] = underline(content[2]) gradeList.append(content) print(tabulate(gradeList, headers=headers)) def bold(word): return("\033[1m" + word + "\033[0m") def underline(word): return("\033[4" + word + "\033[0m") while True: username = input("Enter username: "******"Enter password: "******"Enter password(hidden): ") student = StudentVue(username,password,"md-mcps-psv.edupoint.com") try: temp = student.get_attendance()["RT_ERROR"]["@ERROR_MESSAGE"] print("Invalid username or password. \n") time.sleep(1) os.system("cls") except: break os.system("cls") name = student.get_student_info()['StudentInfo']["NickName"]["$"] print("Welcome",name+"!") grades = student.get_gradebook(2) while True: os.system("cls")
class SVInfo(object): def __init__(self, username="", password="", domain=""): cf = ConfigParser() p = os.path.join(os.path.dirname(__file__), "config.ini") cf.read(p) if username == "": username = input("Student ID -> ") if password == "": password = bullet.Password("Password -> ").launch() if domain == "": if not os.path.exists(p) or cf.get("values", "domain") == "": domain = input("District Edupoint Domain -> ") if not os.path.exists(p): cf.add_section("values") cf.set("values", "domain", domain) with open(p, "w+") as configfile: cf.write(configfile) else: domain = cf.get("values", "domain") self.sv = StudentVue( username, password, domain, ) def grades(self, long=False, course="all"): courses = self.sv.get_gradebook().get("Gradebook").get("Courses").get( "Course") grades = [] for c in courses: filtered_assignments = [] try: assignments = (c.get("Marks").get("Mark").get( "Assignments").get("Assignment")) if assignments != None and long: for assignment in assignments: filtered_assignments.append([ assignment.get("@Measure"), assignment.get("@Points") ]) except: pass try: grades.append([ c.get("@Title"), c.get("Marks").get("Mark").get("@CalculatedScoreRaw"), filtered_assignments, ]) except: grades.append([ c.get("@Title"), "Grade unavailable", filtered_assignments, ]) fgrades = "" i = 0 for grade in grades: add_grade = False i += 1 if course != all: if type(course) is list: if i in course or str(i) in course: add_grade = True elif type(course) is int or type(course) is str: if str(i) == str(course): add_grade = True else: raise TypeError( 'Type of "course" expected to be list or int. Got ' + type(course).__name__) if course == "all" or add_grade: fgrades += grade[0].split("(")[0].rstrip() + ": " fgrades += str(grade[1]) + "%\n" for assignment in grade[2]: fgrades += "\t" + assignment[0] + ": " if "Points Possible" in assignment[1].split("/")[0]: fgrades += (str(float(assignment[1].split(" ")[0])) + " " + " ".join(assignment[1].split(" ")[1:]) + "\n") else: fgrades += (str(float(assignment[1].split("/")[0])) + " / " + str(float(assignment[1].split("/")[1])) + "\n") return fgrades.strip() def schedule(self): times = [] now = datetime.datetime.now() sched = (self.sv.get_schedule().get("StudentClassSchedule").get( "TodayScheduleInfoData").get("SchoolInfos").get("SchoolInfo")) if sched != None: sched = sched.get("Classes").get("ClassInfo") for item in sched: start = item.get("@StartTime").split(" ") end = item.get("@EndTime").split(" ") stimestr = start[0].split(":") etimestr = end[0].split(":") stime = [] etime = [] for item in stimestr: stime.append(int(item)) for item in etimestr: etime.append(int(item)) if start[1] == "PM" and stime[0] != 12: stime[0] += 12 if end[1] == "PM" and etime[0] != 12: etime[0] += 12 if start[1] == "AM" and stime[0] == 12: stime[0] -= 12 if end[1] == "AM" and etime[0] == 12: etime[0] -= 12 times.append([stime, etime]) fschedule = f"Schedule for {now.month}/{now.day}/{now.year}:\n" t = 0 for item in times: fschedule += ("\t" + " ".join(sched[t].get("@ClassName").split( " ")[1:]).split("-")[0].rstrip() + ": ") fschedule += f"{datetime.time(hour=item[0][0],minute=item[0][1])} to {datetime.time(hour=item[1][0],minute=item[1][1])}\n" t += 1 return fschedule.strip() else: return "No school schedule"