def get(self): with open_results() as db: protocols = db.get_files() nprotocols = dict() sep = "-" * 40 for name, text in protocols.items(): lines = text.split("\n") sections = [] i = 0 while i < len(lines): if lines[i].startswith(sep) and lines[i + 2].startswith(sep): sections.append(dict(name=lines[i + 1], lines=[])) i += 3 else: sections[-1]["lines"].append(lines[i]) i += 1 nprotocols[name] = sections self.render("report.html", ilias_version=self.state.get_ilias_version() or "unavailable", results=db.get_results(), protocols=nprotocols)
def get(self, batch): if batch.endswith(".zip"): batch = batch[:-4] f = io.BytesIO() with open_results() as db: db.get_zipfile(batch, f) self.set_header('Content-Type', 'application/zip') self.set_header("Content-Disposition", "attachment; filename=%s.zip" % batch) self.write(f.getvalue()) f.close() self.finish()
def get(self, what): with open_results() as db: if what == "counts": data = db.get_counts() elif what == "details": data = db.get_details() elif what == "coverage": data = db.get_coverage() elif what == "performance": data = db.get_performance_data() elif what == "longterm": data = db.get_longterm_data() self.write(json.dumps(data)) self.finish()
def store_into_database(self, elapsed_time): files = self.files.copy() files['protocol.txt'] = self._make_protocol().encode('utf8') if self.protocols["readjustments"]: files['readjustments/protocol.txt'] = ("\n".join( self.protocols["readjustments"])).encode('utf8') for part in itertools.chain(["master"], (user.get_username() for user in self.users)): files['machines/%s.txt' % part] = ("\n".join( self.protocols[part])).encode('utf8') files_data = dict( (k, base64.b64encode(v).decode('utf8')) for k, v in files.items()) with open_results() as db: db.put(batch_id=self.batch_id, success=encode_success(self.success), files=json.dumps(files_data), num_users=len(self.users), elapsed_time=elapsed_time) db.put_performance_data(self.performance_data) db.put_coverage_data(self.coverage)
def get(self): with open_results() as db: db.clear() self.finish()