Exemplo n.º 1
0
    def get_current_classes(self):
        classes_list_url = 'https://adminfo.ucsadm.oregonstate.edu/prod/bwskfshd.P_CrseSchdDetl'
        self.header_values['Referer'] = 'https://adminfo.ucsadm.oregonstate.edu/prod/twbkwbis.P_GenMenu?name=bmenu.P_RegMnu'

        request = urllib2.Request(classes_list_url, headers = self.header_values)
        response = self.opener.open(request)
        html = response.read()
        current_term = parse_html.get_current_term(html)

        form_data = urllib.urlencode({'term_in' : current_term})

        request = urllib2.Request(classes_list_url, form_data, headers=self.header_values)
        response = self.opener.open(request)
        return response
Exemplo n.º 2
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) 
Exemplo n.º 3
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) 
Exemplo n.º 4
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)
Exemplo n.º 5
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)
Exemplo n.º 6
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)