def process(self, job, id, px): job = uuid(job) meta = get_meta(job)['meta'] shp = dict(meta['shapes'])[int(id)] with get_file_for_job(job, shp['filename']) as f: web.header('Content-Type', 'image/svg+xml') return svgthumb.svg_thumb(f, int(px))
def process(self, job): web.header('Content-Type', 'text/json') job = str(uuid(job)) status, _ = get_job_status(job) if status == 'awaiting': return json(dict(status = status, **db.queue_position(job))) else: return json(dict(status = status))
def process(self, job, id): job = uuid(job) id = int(id) meta = get_meta(job) stats = db.get_completed(job) if 'error' in meta: return render.failed(meta['error'], str(job)) itemmeta = self.get_template_args(job, meta, id) sidebar = part_render.part_sidebar(current = self.WHERE, job = job, meta = meta['meta'], stats = stats) return getattr(render, self.WHERE + '_details')(sidebar = sidebar, job = job, **itemmeta)
def process(self, job): job = uuid(job) meta = get_meta(job) if 'error' in meta: return render.failed(meta['error'], str(job)) else: stats = db.get_completed(job) sidebar = part_render.part_sidebar(current = self.WHERE, job = job, meta = meta['meta'], stats = stats) args = self.get_template_args(job, meta) return getattr(render, self.WHERE)(sidebar = sidebar, job = job, **args)
def process(self, job, id, px): web.header('Content-Type', 'application/octet-stream') job = uuid(job) meta = get_meta(job)['meta'] img = dict(meta['images'])[int(id)] with get_file_for_job(job, img['filename']) as f: im = Image.open(f) im.load() im.thumbnail([int(px)] * 2, Image.ANTIALIAS) s = StringIO() im.save(s, 'PNG') return s.getvalue()
def serve_binary(job, chooser, mimetype = 'application/octet-stream'): job = uuid(job) meta = get_meta(job)['meta'] name = chooser(meta) if callable(mimetype): web.header('Content-Type', mimetype(meta)) else: web.header('Content-Type', mimetype) web.header('Content-Disposition', 'inline; filename=' + name) with get_file_for_job(job, name) as f: f.seek(0, os.SEEK_END) web.header('Content-Length', str(f.tell())) f.seek(0) return f.read()
def process_one(job): job = uuid(job) print 'We have job', job status, location = get_job_status(job) if status != 'awaiting': print 'rejected: already processed' return dict() outdir = path.join(config.outputdir, str(job)) try: meta = swfback.process_file(path.join(location, config.inputfn), location) except Exception, e: emit_meta(location, dict(error = 'Failed to process swf')) emit_exception(location) meta = dict()
def process(self, job): web.header('Content-Type', 'text/json') job = str(uuid(job)) return json(get_meta(job))
def process(self, job): job = str(uuid(job)) return render.await(job)