def POST(self): form = self.TestForm(); form.validates() code = form["code"].value print code stdin = form["stdin"].value compiler = Compiler() compileHasSucceeded = compiler.compile(code) error = "" if compileHasSucceeded : compiler.run(stdin) compiler.clean() else: error = "compilation has failed" return self.render.free( code, error, compiler.compileSdtout, stdin, compiler.runStdout )
def POST(self,exoNumber): form = self.ExoForm() form.validates() code = unicode(form["code"].value) var = dict(id= exoNumber) tests = self.db.select( "tests", var, what = "stdin, stdout", where = 'exo_id = $id', ); compiler = Compiler() compileHasSucceeded = compiler.compile(code) #array of boolean if a given test has succed or not successTests = [] oneTestHasFailed = False error = "" if compileHasSucceeded : for test in tests: compiler.run(test.stdin) success = compiler.runStdout == test.stdout print "prout" print compiler.runStdout successTests.append(success) if not success: error = "Some of the tests to check if your software works has failed" compiler.clean() else: error = "compilation has failed" return self.render.result( code, error, compiler.compileSdtout, successTests )