@gen.coroutine<EOL><INDENT>def post(self, cpfile):<DEDENT>
<EOL>if self.readonly:<EOL><INDENT>msg = "<STR_LIT>"<EOL>resultdict = {'<STR_LIT:status>':'<STR_LIT:error>',<EOL>'<STR_LIT:message>':msg,<EOL>'<STR_LIT>':self.readonly,<EOL>'<STR_LIT:result>':None}<EOL>self.write(resultdict)<EOL>raise tornado.web.Finish()<EOL><DEDENT>try:<EOL><INDENT>self.cpfile = base64.b64decode(url_unescape(cpfile)).decode()<EOL>cpcontents = self.get_argument('<STR_LIT>', default=None)<EOL>savetopng = self.get_argument('<STR_LIT>', default=None)<EOL>if not self.cpfile or not cpcontents:<EOL><INDENT>msg = "<STR_LIT>"<EOL>resultdict = {'<STR_LIT:status>':'<STR_LIT:error>',<EOL>'<STR_LIT:message>':msg,<EOL>'<STR_LIT>':self.readonly,<EOL>'<STR_LIT:result>':None}<EOL>self.write(resultdict)<EOL>raise tornado.web.Finish()<EOL><DEDENT>cpcontents = json.loads(cpcontents)<EOL>updated = {'<STR_LIT>': cpcontents['<STR_LIT>'],<EOL>'<STR_LIT>':cpcontents['<STR_LIT>'],<EOL>'<STR_LIT>':cpcontents['<STR_LIT>'],<EOL>'<STR_LIT>':cpcontents['<STR_LIT>']}<EOL>cpfpath = os.path.join(<EOL>os.path.abspath(os.path.dirname(self.cplistfile)),<EOL>self.cpfile<EOL>)<EOL>LOGGER.info('<STR_LIT>' % cpfpath)<EOL>if not os.path.exists(cpfpath):<EOL><INDENT>msg = "<STR_LIT>" % cpfpath<EOL>LOGGER.error(msg)<EOL>resultdict = {'<STR_LIT:status>':'<STR_LIT:error>',<EOL>'<STR_LIT:message>':msg,<EOL>'<STR_LIT>':self.readonly,<EOL>'<STR_LIT:result>':None}<EOL>self.write(resultdict)<EOL>raise tornado.web.Finish()<EOL><DEDENT>updated = yield self.executor.submit(checkplot_pickle_update,<EOL>cpfpath, updated)<EOL>if updated:<EOL><INDENT>LOGGER.info('<STR_LIT>' % updated)<EOL>resultdict = {'<STR_LIT:status>':'<STR_LIT:success>',<EOL>'<STR_LIT:message>':'<STR_LIT>',<EOL>'<STR_LIT>':self.readonly,<EOL>'<STR_LIT:result>':{'<STR_LIT>':updated,<EOL>'<STR_LIT>':utime.time(),<EOL>'<STR_LIT>':cpcontents,<EOL>'<STR_LIT>': None}}<EOL>if savetopng:<EOL><INDENT>cpfpng = os.path.abspath(cpfpath.replace('<STR_LIT>','<STR_LIT>'))<EOL>cpfpng = StrIO()<EOL>pngdone = yield self.executor.submit(<EOL>checkplot_pickle_to_png,<EOL>cpfpath, cpfpng<EOL>)<EOL>if pngdone is not None:<EOL><INDENT>pngdone.seek(<NUM_LIT:0>)<EOL>pngbin = pngdone.read()<EOL>pngb64 = base64.b64encode(pngbin)<EOL>pngdone.close()<EOL>del pngbin<EOL>resultdict['<STR_LIT:result>']['<STR_LIT>'] = pngb64<EOL><DEDENT>else:<EOL><INDENT>resultdict['<STR_LIT:result>']['<STR_LIT>'] = '<STR_LIT>'<EOL><DEDENT><DEDENT>self.write(resultdict)<EOL>self.finish()<EOL><DEDENT>else:<EOL><INDENT>LOGGER.error('<STR_LIT>' %<EOL>(self.cpfile, cpcontents))<EOL>msg = "<STR_LIT>"<EOL>resultdict = {'<STR_LIT:status>':'<STR_LIT:error>',<EOL>'<STR_LIT:message>':msg,<EOL>'<STR_LIT>':self.readonly,<EOL>'<STR_LIT:result>':None}<EOL>self.write(resultdict)<EOL>self.finish()<EOL><DEDENT><DEDENT>except Exception as e:<EOL><INDENT>LOGGER.exception('<STR_LIT>' %<EOL>(self.cpfile, cpcontents))<EOL>msg = "<STR_LIT>"<EOL>resultdict = {'<STR_LIT:status>':'<STR_LIT:error>',<EOL>'<STR_LIT:message>':msg,<EOL>'<STR_LIT>':self.readonly,<EOL>'<STR_LIT:result>':None}<EOL>self.write(resultdict)<EOL>self.finish()<EOL><DEDENT>
This handles POST requests.

        Also an AJAX endpoint. Updates the persistent checkplot dict using the
        changes from the UI, and then saves it back to disk. This could
        definitely be faster by just loading the checkplot into a server-wide
        shared dict or something.