def home(): """ Handles the home page rendering.""" soc = Soc() subjects = soc.get_subjects() form = SnipeForm(request.form) if request.method == 'POST' and form.validate(): if request.args.get('name') == 'snipe': form.save() return render_template('success.html', form=form) if request.args.get('name') == 'sections': req_sections = request.form.sections chosen_sections = set(req_sections.split(',')) if ',' in req_sections else [req_sections] courses = soc.get_courses() sections = [] for course in courses(): for section in course: if section["index"] in chosen_sections: sections.append(section["index"]) choices = zip(range(1,len(sections)+1), sections) form.checkbox = SelectMultipleField(choices=choices) form.save() return render_template('home.html', form=form, subjects=subjects, sections=sections) if not request.form: # this trick allows us to prepopulate entries using links sent out in emails. form = SnipeForm(request.args) return render_template('home.html', form=form, subjects=subjects)
def test(): from cron import poll # Make sure tables exist. If not, create them try: db.session.query(User).first() db.session.query(Snipe).first() except Exception: db.create_all() soc = Soc() math_courses = soc.get_courses(640) open_courses = poll(640, result=True) for dept, sections in open_courses.iteritems(): open_courses[dept] = [section.number for section in sections] success = True for math_course in math_courses: course_number = math_course['courseNumber'] if course_number.isdigit(): course_number = str(int(course_number)) for section in math_course['sections']: section_number = section['number'] if section_number.isdigit(): section_number = str(int(section_number)) if section['openStatus'] and not section_number in open_courses[ course_number]: raise Exception('Test failed') success = False return success
def test(): from cron import poll soc = Soc() math_courses = soc.get_courses(640) open_courses = poll(640, result = True) for dept, sections in open_courses.iteritems(): open_courses[dept] = [section.number for section in sections] success = True for math_course in math_courses: course_number = math_course['courseNumber'] if course_number.isdigit(): course_number = str(int(course_number)) for section in math_course['sections']: section_number = section['number'] if section_number.isdigit(): section_number = str(int(section_number)) if section['openStatus'] and not section_number in open_courses[course_number]: raise Exception('Test failed') success = False return success
def test(): from cron import poll soc = Soc() math_courses = soc.get_courses(640) open_courses = poll(640, result=True) for dept, sections in open_courses.iteritems(): open_courses[dept] = [section.number for section in sections] success = True for math_course in math_courses: course_number = math_course['courseNumber'] if course_number.isdigit(): course_number = str(int(course_number)) for section in math_course['sections']: section_number = section['number'] if section_number.isdigit(): section_number = str(int(section_number)) if section['openStatus'] and not section_number in open_courses[ course_number]: raise Exception('Test failed') success = False return success
def test(): from cron import poll # Make sure tables exist. If not, create them try: db.session.query(User).first() db.session.query(Snipe).first() except Exception: db.create_all() soc = Soc() math_courses = soc.get_courses(640) open_courses = poll(640, result = True) for dept, sections in open_courses.iteritems(): open_courses[dept] = [section.number for section in sections] success = True for math_course in math_courses: course_number = math_course['courseNumber'] if course_number.isdigit(): course_number = str(int(course_number)) for section in math_course['sections']: section_number = section['number'] if section_number.isdigit(): section_number = str(int(section_number)) if section['openStatus'] and not section_number in open_courses[course_number]: raise Exception('Test failed') success = False return success
def add(self, title, text): item = Soc() if(not item.setText(text) and not item.setTitle(title)): self.__lib.append(item) self.sort() self.save() return 0 else: return -1
def home(): """ Handles the home page rendering.""" soc = Soc() subjects = soc.get_subjects() form = SnipeForm(request.form) if request.method == 'POST' and form.validate(): form.save() return render_template('success.html', form=form) if not request.form: # this trick allows us to prepopulate entries using links sent out in emails. form = SnipeForm(request.args) return render_template('home.html', form=form, subjects=subjects)
def home(): """ Handles the home page rendering.""" soc = Soc(**get_current_tylc()) form = SnipeForm(request.form) if request.method == 'POST' and form.validate(): form.save() return render_template('success.html', form=form) if not request.form: # this trick allows us to prepopulate entries using links sent out in emails. form = SnipeForm(request.args) # change to return home.html when active return render_template('home.html', form=form)
def test(): from cron import poll soc = Soc(**get_current_tylc()) return True
#!/usr/bin/env python """ This represents the cronjob that runs to check for course openings""" from flaskext.mail import Message import urllib from models import db, Snipe from soc import Soc from app import mail, app import datetime from collections import namedtuple soc = Soc() EMAIL_SENDER = "Course Sniper <*****@*****.**>" Section = namedtuple('Section', ['number', 'index']) def poll(subject, result=False): """ Poll a subject for open courses. """ app.logger.warning("Polling for %s" % (subject)) # get all the course data from SOC courses = soc.get_courses(subject) # build information about which courses/sections are currently open. open_data = {} for course in courses: course_number = course['courseNumber'] # remove leading zeroes
from baremetal import * from soc import Soc print_debug = False verbose = False print_memory = False # initialise instruction memory with open("build/test.hex") as f: instructions = [] for line in f: instructions.append(int(line, 16)) clk = Clock("clk") soc = Soc(clk, 1024 * 1024, instructions) soc.simulate(10000)
#!/usr/bin/env python """ This represents the cronjob that runs to check for course openings""" from flaskext.mail import Message import urllib from models import db, Snipe from soc import Soc from app import mail, app import datetime from collections import namedtuple EMAIL_SENDER = "Course Sniper <*****@*****.**>" CAMPUSES = ['NB', 'NK', 'CM'] socs = {'NB': Soc(campus='NB'), 'NK': Soc(campus='NK'), 'CM': Soc(campus='CM')} Section = namedtuple('Section', ['number', 'index']) def poll(campus, subject, result=False): """ Poll a subject for open courses. """ app.logger.warning("Polling for %s %s" % (campus, subject)) soc = socs[campus] # get all the course data from SOC courses = soc.get_courses(subject) # build information about which courses/sections are currently open. open_data = {}