def post(self): data = T3PKonfigurator(self.request_dict, self.lang) data.create_configuration() conf = {'tube': data.configuration.tube, 'depths': data.configuration.depths, 'order': data.configuration.order} ib = ImageBuilder() img = ib.build(conf['order'], conf['tube'], conf['depths']) if self.request_dict['probes_done']: data.probes_done = True if self.request_dict['create_pdf']: data.create_configuration() pdf = data.create_pdf() with open(pdf, 'r') as f: self.write(f.read()) self.set_header("Content-Type", 'application/pdf; charset="utf-8"') self.set_header("Content-Disposition", "attachment; filename=" + pdf) os.remove(pdf) msg = self.set_message(data) self.render(self.templates[self.lang], msg=msg, data=data, img=img)
def get(self): data = T3PKonfigurator(self.request_dict, self.lang) data.create_configuration() conf = {'tube': data.configuration.tube, 'depths': data.configuration.depths, 'order': data.configuration.order} ib = ImageBuilder() img = ib.build(conf['order'], conf['tube'], conf['depths']) self.render(self.templates[self.lang], msg=self.messages.initial_message, data=data, img=img)
def post(self): outcome, message, request_id = ImageBuilder().new(request.data) result = {'status': 'ok' if outcome else 'failed', 'message': '' if outcome else message, 'result': '' if not outcome else dict({'request_id': request_id})} return result, 200
def get(self, request_id): outcome, message, ret = ImageBuilder().result(request_id) result = {'status': 'ok' if outcome else "failed", 'message': '' if outcome else message, 'result': '' if not outcome else ret} return result, 200 '''
def delete(self, request_id): outcome, message = ImageBuilder().delete(request_id) result = { 'status': 'ok' if outcome else "failed", 'message': '' if outcome else message } return result, 200
def get(self, request_id): logdir, logfile = ImageBuilder().getLogPath(request_id) if not logdir or not logfile: result = {'status': 'failed', 'message': 'Requested log does not exist!'} return result, 200 else: return send_from_directory(logdir, logfile, as_attachment=True)
def get(self, request_id): outcome, message, reqstate, reqoutcome = ImageBuilder().state(request_id) result = {'status': 'ok' if outcome else 'failed', 'message': '' if outcome else message, 'result': '' if not outcome else dict({'request_id': request_id, 'request_status': reqstate, 'outcome:': reqoutcome})} return result, 200
def get(self, request_id, output_id): imgdir, imgfile, outputs = ImageBuilder().getOutputs(request_id) if not imgdir or not imgfile or output_id > len(outputs) - 1: result = { 'status': 'failed', 'message': 'Requested image does not exist!' } return result, 200 else: current_app.logger.debug("Serving file '{}/{}'".format( imgdir, outputs[output_id])) return send_from_directory(imgdir, outputs[output_id], as_attachment=True)