def gen_pdf_file(doc_id): cmd = [] cmd.append('wkhtmltopdf') cmd.append('http://{host_url}/{doc_id}?stylesheet=print'.format(host_url=app.config.get('HOST_URL', 'localhost'), doc_id=doc_id)) fname = '{tmpdir}/{doc_id}.pdf'.format(tmpdir=tempfile.gettempdir(), doc_id=doc_id) cmd.append(fname) logger.debug(cmd) try: subprocess.check_call(cmd) logger.info("generated {fname}".format(fname=fname)) except subprocess.CalledProcessError as error: logger.error("Error trying to generate pdf file with command '{cmd}': {error}".format(error=error, cmd=error.cmd)) return fname
def doc_update(doc_id): "JSON endpoint for document updates. I still have to define protocol." doc = models.get_document(doc_id) if('client_id' not in session): flash("an error occured. Please contact <*****@*****.**>, with all the information you can provide. Please do not forget to include the exact time at which this occured.") logger.error("on /update, we don't have any client_id information. document: {doc_id}".format(doc_id=doc_id)) return abort() deltas_to_send = app.deltas[doc_id][ app.client_states[session['client_id']][doc_id]: ] app.client_states[session['client_id']][doc_id] = len(app.deltas[doc_id]) if(request.json): doc.update(request.json['data']) return json.dumps({ "events": deltas_to_send, "render":doc.render() })