예제 #1
0
    def get_transcript(self):
        #The transcript page url
        trans_url = 'https://adminfo.ucsadm.oregonstate.edu/prod/bwskotrn.P_ViewTran'

        #set up correct header information
        self.header_values['Referer'] = 'https://adminfo.ucsadm.oregonstate.edu/prod/bwskotrn.P_ViewTermTran'
        self.header_values['Origin'] = 'https://adminfo.ucsadm.oregonstate.edu'
        form_data = urllib.urlencode({'levl' : '', 'tprt' : 'WWW'})
        request = urllib2.Request(trans_url, form_data, headers = self.header_values)
        response = self.opener.open(request)
        html = response.read()
        if parse_html.get_page_title(html) != 'Login':
            return html
            #return transcript.Transcript(html)
        else:
            self.fix_login("get_transcript")
예제 #2
0
def get_transcript(sid, pin):
    """ get transcript including list of classes taken, grade, and current gpa """

    login_number = 2
    #If we are not logged in we will loop around again
    for i in range(login_number):

        #The transcript page url
        html = fetch_html.get_transcript()

        if parse_html.get_page_title(html) != 'Login':
            # We set the transcript variable to a instance of the transcript class
            grades = parse_html.get_grades(html)
            credits = parse_html.get_credits(html)
            gpa = parse_html.get_gpa(html)
            return transcript.Transcript(html, grades, credits, gpa)

        else:
            login(sid, pin)
예제 #3
0
def get_transcript(sid, pin):
    """ get transcript including list of classes taken, grade, and current gpa """

    login_number = 2
    #If we are not logged in we will loop around again
    for i in range(login_number):

        #The transcript page url
        html = fetch_html.get_transcript()
        
        if parse_html.get_page_title(html) != 'Login':
            # We set the transcript variable to a instance of the transcript class
            grades = parse_html.get_grades(html)
            credits = parse_html.get_credits(html)
            gpa = parse_html.get_gpa(html)
            return transcript.Transcript(html, grades, credits, gpa)

        else:
            login(sid, pin)
예제 #4
0
def add_class(sid, pin, crn1, crn2, schedule):
    """ registers for a class, takes two crns for lab/rec """

    login_number = 2
    for i in range(login_number):
        html = fetch_html.setup_add_drop_page()
        title = parse_html.get_page_title(html)
        form_data = ''
        if title != 'Login':
            # a drop down box asks which term to register for. will need to implement for future terms
            if title == 'Select Term ':
                schedule.current_term = parse_html.get_current_term(html)
                form_data = fetch_html.current_term_form(schedule.current_term)
        else:
            login(sid, pin)
            continue
        
        html = fetch_html.add_drop_page(form_data)
        # Get a dictionary of values to post as the form
        values = parse_html.add_class(html, crn1, crn2)
        html = fetch_html.add_class(values)
        
        # See if there were any errors when posting the form
        return parse_html.add_class_has_errors(html) 
예제 #5
0
def drop_classes(sid, pin, crn_list, schedule):
    """ drops a class, takes a crn or two for lec/lab """

    login_number = 2
    for i in range(login_number):
        html = fetch_html.setup_add_drop_page()
        title = parse_html.get_page_title(html)
        form_data = ''
        if title != 'Login':
            # a drop down box asks which term to register for. will need to implement for future terms
            if title == 'Select Term ':
                schedule.current_term = parse_html.get_current_term(html)
                form_data = fetch_html.current_term_form(schedule.current_term)
        else:
            login(sid, pin)
            continue
        
        html = fetch_html.add_drop_page(form_data)

        # Gets list of action_ids which are form values to submit 
        values = parse_html.drop_classes(html, crn_list)
        html = fetch_html.drop_classes(values)
        
    return parse_html.add_class_has_errors(html) 
예제 #6
0
def drop_classes(sid, pin, crn_list, schedule):
    """ drops a class, takes a crn or two for lec/lab """

    login_number = 2
    for i in range(login_number):
        html = fetch_html.setup_add_drop_page()
        title = parse_html.get_page_title(html)
        form_data = ''
        if title != 'Login':
            # a drop down box asks which term to register for. will need to implement for future terms
            if title == 'Select Term ':
                schedule.current_term = parse_html.get_current_term(html)
                form_data = fetch_html.current_term_form(schedule.current_term)
        else:
            login(sid, pin)
            continue

        html = fetch_html.add_drop_page(form_data)

        # Gets list of action_ids which are form values to submit
        values = parse_html.drop_classes(html, crn_list)
        html = fetch_html.drop_classes(values)

    return parse_html.add_class_has_errors(html)
예제 #7
0
def add_class(sid, pin, crn1, crn2, schedule):
    """ registers for a class, takes two crns for lab/rec """

    login_number = 2
    for i in range(login_number):
        html = fetch_html.setup_add_drop_page()
        title = parse_html.get_page_title(html)
        form_data = ''
        if title != 'Login':
            # a drop down box asks which term to register for. will need to implement for future terms
            if title == 'Select Term ':
                schedule.current_term = parse_html.get_current_term(html)
                form_data = fetch_html.current_term_form(schedule.current_term)
        else:
            login(sid, pin)
            continue

        html = fetch_html.add_drop_page(form_data)
        # Get a dictionary of values to post as the form
        values = parse_html.add_class(html, crn1, crn2)
        html = fetch_html.add_class(values)

        # See if there were any errors when posting the form
        return parse_html.add_class_has_errors(html)
예제 #8
0
def get_schedule(sid, pin, Next):
    """ Function to set our schedule variable. Get current schedule if next schedule flag not set """
    
    login_number = 2
    term = ''
    for i in range(login_number):
        
        html = fetch_html.setup_schedule_page()
        title = parse_html.get_page_title(html)
        if title != 'Login':
            if title == 'Select Term ':
                term = parse_html.get_current_term(html)
                if Next:
                    term = to_next_term(term)
            else:
                courses = parse_html.get_current_classes(html) 
                return schedule.Schedule(html, courses, term)
        else:
            login(sid, pin)
            continue

        html = fetch_html.get_schedule(term)
        courses = parse_html.get_current_classes(html)
        return schedule.Schedule(html, courses, term)