コード例 #1
0
ファイル: auth.py プロジェクト: spapadim/xmllab
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")
コード例 #2
0
ファイル: xmlapp.py プロジェクト: spapadim/xmllab
 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)
コード例 #3
0
ファイル: xmlapp.py プロジェクト: spapadim/xmllab
 def scores(self):
   db.check_db()
   scoreboard = cherrypy.thread_data.scoreboard
   scores = scoreboard.select().execute().fetchall()
   return template.render(scores=scores)