Exemplo n.º 1
0
def check_login(username=None, password=None):
  if username is not None:
    db.check_db()
    students = cherrypy.thread_data.students
    row = students.select().where(students.c.username == username).execute().fetchone()
    if (row is not None) and (password == row['password']):
      cherrypy.session[SESSION_KEY] = username
      raise cherrypy.HTTPRedirect("https://dbm-rbs.rutgers.edu/xml")
Exemplo n.º 2
0
 def test(self, zip_f=None):
   results = []
   if zip_f and zip_f.file:
     db.check_db()
     conf = cherrypy.request.app.config['test']
     # Run tests
     try:
       gold_zip = zipfile.ZipFile(conf['gold_zip'], 'r')
       test_zip = zipfile.ZipFile(zip_f.file)
       results = test.test_all(self.doc, gold_zip, test_zip)
     finally:
       gold_zip.close()
       test_zip.close()
     # Log zipfile submission
     timestamp = datetime.datetime.now().strftime('%Y%m%d_%H%M%S')
     filename = '%s/%s_%s.zip' % (conf['logdir'], timestamp, \
                                  cherrypy.request.username)
     fp = open(filename, 'w')
     try:
       fp.write(zip_f.fullvalue())
     finally:
       fp.close()
   return template.render(results=results)
Exemplo n.º 3
0
 def scores(self):
   db.check_db()
   scoreboard = cherrypy.thread_data.scoreboard
   scores = scoreboard.select().execute().fetchall()
   return template.render(scores=scores)