• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python objects.File类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中mediacrush.objects.File的典型用法代码示例。如果您正苦于以下问题:Python File类的具体用法?Python File怎么用?Python File使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了File类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: frame

    def frame(self, id):
        send = self._send_file(id)
        if send:
            return send
        # We only want to maintain one page for mobile, not a dozen
        if (
            request.user_agent.platform in ["android", "iphone", "ipad"]
            or "windows phone" in request.user_agent.string.lower()
        ):
            return redirect("/" + id, code=302)

        klass = RedisObject.klass(id)
        if klass is Album:
            album = klass.from_hash(id)
            v = _album_params(album)
            v["embedded"] = True
            v["filename"] = id
            return render_template("album-embedded.html", **v)

        if klass is not File:
            abort(404)

        f = File.from_hash(id)
        template_params = _template_params(f)
        template_params["embedded"] = True
        return render_template("direct.html", **template_params)
开发者ID:JIVS,项目名称:MediaCrush,代码行数:26,代码来源:media.py


示例2: process_file

def process_file(path, h, ignore_limit):
    f = File.from_hash(h)
    result = detect(path)

    processor = result['type'] if result else 'default'
    if processor == 'default': # Unrecognised file type
        failed = FailedFile(hash=h, status="unrecognised")
        failed.save()

        delete_file(f)
        return

    metadata = result['metadata'] if result else {}
    processor_state = result['processor_state'] if result else {}

    f.processor = processor

    setattr(f.flags, 'nsfw', False)
    if result and result['flags']:
        for flag, value in result['flags'].items():
            setattr(f.flags, flag, value)

    f.save()

    task = convert_file.s(h, path, processor, metadata, processor_state, ignore_limit)
    task_result = task.freeze() # This sets the taskid, so we can pass it to the UI

    # This chord will execute `syncstep` and `asyncstep`, and `cleanup` after both of them have finished.
    c = chord(task, cleanup.s(path, h))
    c.apply_async()

    f.taskid = task_result.id
    f.save()
开发者ID:Jaex,项目名称:MediaCrush,代码行数:33,代码来源:tasks.py


示例3: report

 def report(self, id):
     rate_limit_update(1, section="report")
     if not current_app.debug and rate_limit_exceeded(section="report"):
         return {'error': 413}, 413
     f = File.from_hash(id)
     f.add_report()
     return render_template("report.html")
开发者ID:FoleyDiver,项目名称:MediaCrush,代码行数:7,代码来源:media.py


示例4: process_file

def process_file(path, h):
    f = File.from_hash(h)
    result = detect(path)

    processor = result['type'] if result else 'default'
    metadata = result['metadata'] if result else {}
    processor_state = result['processor_state'] if result else {}

    f.processor = processor

    if result and result['flags']:
        for flag, value in result['flags'].items():
            setattr(f.flags, flag, value)

    f.save()

    task = convert_file.s(h, path, processor, metadata, processor_state)
    task_result = task.freeze() # This sets the taskid, so we can pass it to the UI

    # This chord will execute `syncstep` and `asyncstep`, and `cleanup` after both of them have finished.
    c = chord(task, cleanup.s(path, h))
    c.apply_async()

    f.taskid = task_result.id
    f.save()
开发者ID:JIVS,项目名称:MediaCrush,代码行数:25,代码来源:tasks.py


示例5: fragment

    def fragment(self, id):
        klass = RedisObject.klass(id)
        if klass is not File:
            abort(404)

        f = File.from_hash(id)
        params = _template_params(f)
        params['album'] = True
        return render_template(params['fragment'], **params)
开发者ID:FoleyDiver,项目名称:MediaCrush,代码行数:9,代码来源:media.py


示例6: cleanup

def cleanup(results, path, h):
    f = File.from_hash(h)
    os.unlink(path)

    if f.status in ["internal_error", "error", "timeout", "unrecognised"]:
        failed = FailedFile(hash=h, status=f.status) # Create a "failed file" record
        failed.save()

        delete_file(f)
开发者ID:FoleyDiver,项目名称:MediaCrush,代码行数:9,代码来源:tasks.py


示例7: status

    def status(self, id):
        klass = RedisObject.klass(id)
        if klass is not File:
            abort(404)

        f = File.from_hash(id)
        template_params = _template_params(f)

        if f.status in ['done', 'ready']:
            return tor_redirect('/' + f.hash)
        return render_template("status.html", **_template_params(f))
开发者ID:FoleyDiver,项目名称:MediaCrush,代码行数:11,代码来源:media.py


示例8: _upload_object

def _upload_object(result, status):
    if status == 200:
        return {'hash': result}
    else:
        resp = {'error': status}
        if status == 409:
            f = _file_object(File.from_hash(result))

            resp[result] = f
            resp['hash'] = result

        return resp, status
开发者ID:mpmedia,项目名称:MediaCrush,代码行数:12,代码来源:api.py


示例9: convert_file

def convert_file(self, h, path, p, extra):
    f = File.from_hash(h)

    if p not in processor_table:
        p = 'default'

    processor = processor_table[p](path, f, extra)

    # Execute the synchronous step.
    processor.sync()

    # Save compression information
    f = File.from_hash(h) # Reload file; user might have changed the config vector while processing
    f.compression = compression_rate(path, f)
    f.save()

    # Notify frontend: sync step is done.
    self.update_state(state="READY")

    # Execute the asynchronous step.
    processor.important = False
    processor.async()
开发者ID:amumu,项目名称:MediaCrush,代码行数:22,代码来源:tasks.py


示例10: _upload_f

def _upload_f(f, filename):
    result = upload(f, filename)
    if not isinstance(result, tuple):
        return {'hash': result}
    else:
        h, status = result

        resp = {'error': status}
        if status == 409:
            f = _file_object(File.from_hash(h))

            resp[h] = f
            resp['hash'] = h

        return resp, status
开发者ID:SCORE42,项目名称:MediaCrush,代码行数:15,代码来源:api.py


示例11: process_file

def process_file(path, h):
    f = File.from_hash(h)
    p, extra = detect(path)

    f.processor = p
    f.save()

    task = convert_file.s(h, path, p, extra)
    task_result = task.freeze() # This sets the taskid, so we can pass it to the UI

    # This chord will execute `syncstep` and `asyncstep`, and `cleanup` after both of them have finished.
    c = task | cleanup.s(path, h)
    c.apply_async()

    f.taskid = task_result.id
    f.save()
开发者ID:SCORE42,项目名称:MediaCrush,代码行数:16,代码来源:tasks.py


示例12: get

    def get(self, id, layout):
        send = self._send_file(id)
        if send:
            return send

        klass = RedisObject.klass(id)
        if klass is Album:
            album = klass.from_hash(id)
            v = _album_params(album)
            return render_template("albums/%s.html" % layout, **v)

        if klass is not File:
            abort(404)

        f = File.from_hash(id)
        return render_template("view.html", **_template_params(f))
开发者ID:Thapelo-Tsotetsi,项目名称:MediaCrush,代码行数:16,代码来源:media.py


示例13: status

    def status(self, h):
        klass = RedisObject.klass(h)

        if not klass:
            return {'error': 404}, 404

        if klass is not File:
            return {'error': 415}, 415

        f = File.from_hash(h)
        ret = {'status': f.status}
        if ret['status'] == 'done':
            ret[h] = _file_object(f)
            ret['hash'] = h

        return ret
开发者ID:Web5design,项目名称:MediaCrush,代码行数:16,代码来源:api.py


示例14: direct

    def direct(self, id):
        send = self._send_file(id)
        if send:
            return send

        klass = RedisObject.klass(id)
        if klass is Album:
            album = klass.from_hash(id)
            v = _album_params(album)
            return render_template("album.html", **v)

        if klass is not File:
            abort(404)

        f = File.from_hash(id)
        template_params = _template_params(f)
        return render_template("direct.html", **template_params)
开发者ID:Thapelo-Tsotetsi,项目名称:MediaCrush,代码行数:17,代码来源:media.py


示例15: process_file

def process_file(path, h, ignore_limit):
    t = time.time() + 2
    while True:
        f = File.from_hash(h)
        if f or time.time() > t:
            break
        time.sleep(0.05) # Wait for Redis to catch up

    try:
        result = detect(path)
        processor = result['type'] if result else 'default'
    except:
        processor = 'default'
    finally:
        if processor == 'default': # Unrecognised file type
            failed = FailedFile(hash=h, status="unrecognised")
            failed.save()

            delete_file(f)
            return

    metadata = result['metadata'] if result else {}
    processor_state = result['processor_state'] if result else {}

    f.processor = processor
    queue = "priority" if processor.startswith("image") else "celery"

    setattr(f.flags, 'nsfw', False)
    if result and result['flags']:
        for flag, value in result['flags'].items():
            setattr(f.flags, flag, value)

    f.save()

    args = [h, path, processor, metadata, processor_state, ignore_limit]
    task = signature("mediacrush.tasks.convert_file", args=args, options={'queue': queue})
    task_result = task.freeze() # This sets the taskid, so we can pass it to the UI

    # This chord will execute `syncstep` and `asyncstep`, and `cleanup` after both of them have finished.
    c = chord(task, cleanup.s(path, h))
    c.apply_async()

    f.taskid = task_result.id
    f.save()
开发者ID:FoleyDiver,项目名称:MediaCrush,代码行数:44,代码来源:tasks.py


示例16: urlinfo

    def urlinfo(self):
        l = request.form['list']
        items = l.split(",") if "," in l else [l]

        result = {}
        for item in items:
            key = _k("url.%s" % item)
            h = r.get(key)
            if h:
                f = File.from_hash(h)
                if f:
                    result[item] = _file_object(f)
                else:
                    result[item] = None
                    r.delete(key)
            else:
                result[item] = None

        return result
开发者ID:mpmedia,项目名称:MediaCrush,代码行数:19,代码来源:api.py


示例17: get

    def get(self, id, layout):
        send = self._send_file(id)
        if send:
            return send

        klass = RedisObject.klass(id)
        if klass is Album:
            album = klass.from_hash(id)
            v = _album_params(album)
            v['layout'] = layout
            if layout == "random":
                random.shuffle(v['items']) # It's in-place
            return render_template("albums/%s.html" % layout, **v)

        if klass is not File:
            abort(404)

        f = File.from_hash(id)
        return render_template("view.html", **_template_params(f))
开发者ID:Artanis44,项目名称:MediaCrush,代码行数:19,代码来源:media.py


示例18: get

    def get(self, id, layout):
        klass = RedisObject.klass(id)
        if klass is Album:
            album = klass.from_hash(id)
            v = _album_params(album)
            v['layout'] = layout
            if layout == "random":
                random.shuffle(v['items']) # It's in-place
            return render_template("albums/%s.html" % layout, **v)

        if klass is not File:
            abort(404)

        f = File.from_hash(id)

        if not f.processor:
            # TODO: Better error page
            return render_template("error.html", error="Unable to detect file type")

        return render_template("view.html", **_template_params(f))
开发者ID:nerdzeu,项目名称:NERDZCrush,代码行数:20,代码来源:media.py


示例19: frame

    def frame(self, id):
        send = self._send_file(id)
        if send:
            return send

        klass = RedisObject.klass(id)
        if klass is Album:
            album = klass.from_hash(id)
            v = _album_params(album)
            v['embedded'] = True
            v['filename'] = id
            return render_template("album-embedded.html", **v)

        if klass is not File:
            abort(404)

        f = File.from_hash(id)
        template_params = _template_params(f)
        template_params['embedded'] = True
        return render_template("direct.html", **template_params)
开发者ID:FoleyDiver,项目名称:MediaCrush,代码行数:20,代码来源:media.py


示例20: direct

    def direct(self, id):
        send = self._send_file(id)
        if send:
            return send
        # We only want to maintain one page for mobile, not a dozen
        if request.user_agent.platform in ['android', 'iphone', 'ipad'] or 'windows phone' in request.user_agent.string.lower():
            return redirect("/" + id, code=302)

        klass = RedisObject.klass(id)
        if klass is Album:
            album = klass.from_hash(id)
            v = _album_params(album)
            return render_template("album.html", **v)

        if klass is not File:
            abort(404)

        f = File.from_hash(id)
        template_params = _template_params(f)
        return render_template("direct.html", **template_params)
开发者ID:FoleyDiver,项目名称:MediaCrush,代码行数:20,代码来源:media.py



注:本文中的mediacrush.objects.File类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python objects.RedisObject类代码示例发布时间:2022-05-27
下一篇:
Python network.get_ip函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap