示例#1
0
 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))
示例#2
0
 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)
示例#3
0
 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)
示例#4
0
 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()
示例#5
0
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()
示例#6
0
 def process(self, job):
     web.header('Content-Type', 'text/json')
     job = str(uuid(job))
     return json(get_meta(job))