def updateTestLists(self, rv): self.proc.stdout.seek(0) output = self.proc.stdout.read() self.compile_failed = not (rv == 0) self.get_tests_output = output if self.compile_failed: return i = 0 output.replace("\r\n", "\n") output.replace("\r", "\n") output = output.strip() if output.split("\n")[-1] != "##opjsunit: function end##": print "end:" + output.split("\n")[-1] self.compile_failed = True return testcases = [ item.strip() for item in output.split("##opjsunit: function end##") if item ] for i, testcase in enumerate(testcases): lines = testcase.split("\n") i = 0 if not lines[i].startswith("test"): print "lines[0]:", lines self.compile_failed = True return else: name = lines[i].strip() #skip blank lines while True: i += 1 if lines[i].strip(): break if not lines[i].startswith("comment: "): print "lines[%i]" % i, lines[i] self.compile_failed = True return else: comment = lines[i][len("comment: "):] #skip blank lines while True: i += 1 if lines[i].strip(): break function_code = "\n".join(lines[i:]) test = Test(name, self, opts.recursive, comment=comment, function_code=function_code, index=i + 1) self[unicode(test)] = test
def updateTestLists(self, rv): self.proc.stdout.seek(0) output = self.proc.stdout.read() self.compile_failed = not (rv == 0) self.get_tests_output = output if self.compile_failed: return i = 0 output.replace("\r\n", "\n") output.replace("\r", "\n") output = output.strip() if output.split("\n")[-1] != "##opjsunit: function end##": print "end:" + output.split("\n")[-1] self.compile_failed = True return testcases = [item.strip() for item in output.split("##opjsunit: function end##") if item] for i, testcase in enumerate(testcases): lines = testcase.split("\n") i = 0; if not lines[i].startswith("test"): print "lines[0]:", lines self.compile_failed = True return else: name = lines[i].strip() #skip blank lines while True: i += 1 if lines[i].strip(): break if not lines[i].startswith("comment: "): print "lines[%i]"%i, lines[i] self.compile_failed = True return else: comment = lines[i][len("comment: "):] #skip blank lines while True: i += 1 if lines[i].strip(): break function_code = "\n".join(lines[i:]) test = Test(name, self, opts.recursive, comment=comment, function_code=function_code, index=i+1) self[unicode(test)] = test
def parseTestOutput(self, output): start_re = re.compile("##opjsunit: (.+)##") rv = {} item_template = {"passed": False, "full": False, "messages": ""} current_output = "" for line in output.split("\n"): if line.endswith("\r"): line = line[:-1] if not line: continue start_match = start_re.match(line) if start_match is not None: current_item = start_match.groups()[0] rv[current_item] = item_template.copy() elif line == "--opjsunit:passed--": assert current_item is not None rv[current_item]["full"] = True rv[current_item]["passed"] = True current_item = None elif line == "--opjsunit:failed--": assert current_item is not None rv[current_item]["full"] = True else: if current_item is None: #This probably indicates a crash that truncated #output break else: rv[current_item]["messages"] += line + "\n" return rv
def parseTestOutput(self, output): start_re = re.compile("##opjsunit: (.+)##") rv = {} item_template = {"passed":False, "full":False, "messages":""} current_output = "" for line in output.split("\n"): if line.endswith("\r"): line = line[:-1] if not line: continue start_match = start_re.match(line) if start_match is not None: current_item = start_match.groups()[0] rv[current_item] = item_template.copy() elif line == "--opjsunit:passed--": assert current_item is not None rv[current_item]["full"] = True rv[current_item]["passed"] = True current_item = None elif line == "--opjsunit:failed--": assert current_item is not None rv[current_item]["full"] = True else: if current_item is None: #This probably indicates a crash that truncated #output break else: rv[current_item]["messages"] += line + "\n" return rv
def parseResult(self, output): start_re = re.compile("##opjsunit: (.+)##") rv = {"passed": False, "full": False, "messages": ""} for line in output.split("\n"): if line.endswith("\r"): line = line[:-1] if not line: continue start_match = start_re.match(line) if start_match is not None: #We have found the start of the output pass elif line == "--opjsunit:failed--": rv["full"] = True elif line == "--opjsunit:passed--": rv["passed"] = True rv["full"] = True else: rv["messages"] += line + "\n" return rv
def parseResult(self, output): start_re = re.compile("##opjsunit: (.+)##") rv = {"passed":False, "full":False, "messages":""} for line in output.split("\n"): if line.endswith("\r"): line = line[:-1] if not line: continue start_match = start_re.match(line) if start_match is not None: #We have found the start of the output pass elif line == "--opjsunit:failed--": rv["full"] = True elif line == "--opjsunit:passed--": rv["passed"] = True rv["full"] = True else: rv["messages"] += line + "\n" return rv
def wsgi_app(environ, start_response): import sys import pprint import os import re import urllib sys.path.append('/Users/member/git/excel_job') import output #output = pprint.pformat(os.listdir('.')) + '\n' output = sys.version + '\n' select = '' stgrade = '' stclass = '' students = '' for q in environ['QUERY_STRING'].split('&'): if q.startswith('select='): select=q.replace('select=','') if q.startswith('grade='): stgrade=q.replace('grade=','') if q.startswith('class='): stclass+=q.replace('class=','') if q.startswith('students='): students+=q.replace('students=','') if select == 'byclass' and stgrade != '' and stclass != '': import tempfile outpath=tempfile.mkdtemp() zip = output_excel(stgrade,stclass,outpath) if os.path.isfile(zip): headers = [('Content-type', 'application/zip'), ('Content-Length', str(os.path.getsize(zip))), ('Content-Disposition', 'attachment; filename="' + os.path.basename(zip) + '"')] with open(zip,'rb') as f: output=f.read() f.close() else: output = zip output = output.encode('utf-8') headers = [('Content-type', 'text/html; charset=utf-8'), ('Content-Length', str(len(output)))] elif select == 'bystudents' and students != '': output = urllib.parse.unquote(students) students = output.split() import tempfile outpath=tempfile.mkdtemp() zip = output_excel2(students,outpath) if os.path.isfile(zip): headers = [('Content-type', 'application/excel'), ('Content-Length', str(os.path.getsize(zip))), ('Content-Disposition', 'attachment; filename="' + os.path.basename(zip) + '"')] with open(zip,'rb') as f: output=f.read() f.close() else: output = zip output = output.encode('utf-8') headers = [('Content-type', 'text/html; charset=utf-8'), ('Content-Length', str(len(output)))] else: output = '<script type="text/javascript">' output += 'function byclass() {' output += ' var x = document.getElementsByName("grade");' output += ' for (i = 0; i < x.length; i++) x[i].disabled = false;' output += ' var x = document.getElementsByName("class");' output += ' for (i = 0; i < x.length; i++) x[i].disabled = false;' output += ' document.getElementsByName("students")[0].disabled = true;' output += '}' output += 'function bystudents() {' output += ' var x = document.getElementsByName("grade");' output += ' for (i = 0; i < x.length; i++) x[i].disabled = true;' output += ' var x = document.getElementsByName("class");' output += ' for (i = 0; i < x.length; i++) x[i].disabled = true;' output += ' document.getElementsByName("students")[0].disabled = false;' output += '}' output += '</script>' output += '<form>' output += 'Select: ' output += '<input type="radio" name="select" value="byclass" checked onclick="byclass()">By Class' output += '<input type="radio" name="select" value="bystudents" onclick="bystudents()">By Student IDs' output += '<br/>' output += 'Grade: ' for g in [1,2]: output += '<input type="radio" name="grade" value="' + str(g) + '">' + str(g) output += '<br/>' output += 'Class: ' for c in 'ABCDEFGHIJKL': output += '<input type="checkbox" name="class" value="' + str(c) + '">' + str(c) output += '<br/>' output += 'Students: <textarea name="students" disabled></textarea>' output += '<br/>' output += '<input type="submit" value="send"/>' output += '</form>' output = output.encode('utf-8') headers = [('Content-type', 'text/html; charset=utf-8'), ('Content-Length', str(len(output)))] status = '200 OK' start_response(status, headers) yield output