当前位置: 首页>>代码示例>>Python>>正文


Python File.from_upload方法代码示例

本文整理汇总了Python中mkt.files.models.File.from_upload方法的典型用法代码示例。如果您正苦于以下问题:Python File.from_upload方法的具体用法?Python File.from_upload怎么用?Python File.from_upload使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mkt.files.models.File的用法示例。


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

示例1: test_file_hash

# 需要导入模块: from mkt.files.models import File [as 别名]
# 或者: from mkt.files.models.File import from_upload [as 别名]
    def test_file_hash(self):
        upload = self.upload('mozball')
        f = File.from_upload(upload, self.version)
        # Hash should have been stolen from the fileupload.
        eq_(f.hash, 'sha256:mozball.zip')

        upload = self.upload('mozball')
        f = File.from_upload(upload, self.version)
        # Hash should have been stolen from the fileupload again.
        eq_(f.hash, 'sha256:mozball.zip')
开发者ID:Witia1,项目名称:zamboni,代码行数:12,代码来源:test_models.py

示例2: from_upload

# 需要导入模块: from mkt.files.models import File [as 别名]
# 或者: from mkt.files.models.File import from_upload [as 别名]
    def from_upload(cls, upload, addon, platforms, send_signal=True):
        data = utils.parse_addon(upload, addon)
        try:
            license = addon.versions.latest().license_id
        except Version.DoesNotExist:
            license = None
        max_len = cls._meta.get_field_by_name('_developer_name')[0].max_length
        developer = data.get('developer_name', '')[:max_len]
        v = cls.objects.create(addon=addon, version=data['version'],
                               license_id=license, _developer_name=developer)
        log.info('New version: %r (%s) from %r' % (v, v.id, upload))

        platforms = [Platform.objects.get(id=amo.PLATFORM_ALL.id)]

        # To avoid circular import.
        from mkt.webapps.models import AppManifest

        # Note: This must happen before we call `File.from_upload`.
        manifest = utils.WebAppParser().get_json_data(upload)
        AppManifest.objects.create(
            version=v, manifest=json.dumps(manifest))

        for platform in platforms:
            File.from_upload(upload, v, platform, parse_data=data)

        # Update supported locales from manifest.
        # Note: This needs to happen after we call `File.from_upload`.
        update_supported_locales_single.apply_async(
            args=[addon.id], kwargs={'latest': True},
            eta=datetime.datetime.now() +
                datetime.timedelta(seconds=settings.NFS_LAG_DELAY))

        v.disable_old_files()
        # After the upload has been copied to all platforms, remove the upload.
        storage.delete(upload.path)
        if send_signal:
            version_uploaded.send(sender=v)

        # If packaged app and app is blocked, put in escalation queue.
        if addon.is_packaged and addon.status == amo.STATUS_BLOCKED:
            # To avoid circular import.
            from mkt.reviewers.models import EscalationQueue
            EscalationQueue.objects.create(addon=addon)

        return v
开发者ID:anushbmx,项目名称:zamboni,代码行数:47,代码来源:models.py

示例3: test_file_validation

# 需要导入模块: from mkt.files.models import File [as 别名]
# 或者: from mkt.files.models.File import from_upload [as 别名]
 def test_file_validation(self):
     upload = self.upload('mozball')
     file = File.from_upload(upload, self.version)
     fv = FileValidation.objects.get(file=file)
     eq_(fv.validation, upload.validation)
     eq_(fv.valid, True)
     eq_(fv.errors, 0)
     eq_(fv.warnings, 1)
     eq_(fv.notices, 2)
开发者ID:clouserw,项目名称:zamboni,代码行数:11,代码来源:test_models.py

示例4: from_upload

# 需要导入模块: from mkt.files.models import File [as 别名]
# 或者: from mkt.files.models.File import from_upload [as 别名]
    def from_upload(cls, upload, webapp, send_signal=True):
        data = utils.parse_webapp(upload, webapp)
        max_len = cls._meta.get_field_by_name('_developer_name')[0].max_length
        developer = data.get('developer_name', '')[:max_len]
        v = cls.objects.create(webapp=webapp, version=data['version'],
                               _developer_name=developer)
        log.info('New version: %r (%s) from %r' % (v, v.id, upload))

        # To avoid circular import.
        from mkt.webapps.models import AppManifest

        # Note: This must happen before we call `File.from_upload`.
        manifest = utils.WebAppParser().get_json_data(upload)
        AppManifest.objects.create(
            version=v, manifest=json.dumps(manifest))

        File.from_upload(upload, v, parse_data=data)

        # Update supported locales from manifest.
        # Note: This needs to happen after we call `File.from_upload`.
        update_supported_locales_single.apply_async(
            args=[webapp.id], kwargs={'latest': True},
            eta=datetime.datetime.now() +
            datetime.timedelta(seconds=settings.NFS_LAG_DELAY)
        )

        v.disable_old_files()
        # After the upload has been copied, remove the upload.
        private_storage.delete(upload.path)
        if send_signal:
            version_uploaded.send(sender=v)

        # If packaged app and app is blocked, put in escalation queue.
        if webapp.is_packaged and webapp.status == mkt.STATUS_BLOCKED:
            # To avoid circular import.
            from mkt.reviewers.models import EscalationQueue
            EscalationQueue.objects.create(webapp=webapp)

        return v
开发者ID:shahbaz17,项目名称:zamboni,代码行数:41,代码来源:models.py

示例5: test_file_hash_paranoia

# 需要导入模块: from mkt.files.models import File [as 别名]
# 或者: from mkt.files.models.File import from_upload [as 别名]
 def test_file_hash_paranoia(self):
     upload = self.upload('mozball')
     f = File.from_upload(upload, self.version)
     assert f.hash.startswith('sha256:ad85d6316166d46')
开发者ID:clouserw,项目名称:zamboni,代码行数:6,代码来源:test_models.py

示例6: test_size

# 需要导入模块: from mkt.files.models import File [as 别名]
# 或者: from mkt.files.models.File import from_upload [as 别名]
 def test_size(self):
     upload = self.upload('mozball')
     f = File.from_upload(upload, self.version)
     eq_(f.size, 93594)
开发者ID:clouserw,项目名称:zamboni,代码行数:6,代码来源:test_models.py

示例7: test_utf8

# 需要导入模块: from mkt.files.models import File [as 别名]
# 或者: from mkt.files.models.File import from_upload [as 别名]
 def test_utf8(self):
     upload = self.upload(u'mozball')
     self.version.addon.name = u'mözball'
     f = File.from_upload(upload, self.version)
     eq_(f.filename, u'app-name-0.1.webapp')
开发者ID:clouserw,项目名称:zamboni,代码行数:7,代码来源:test_models.py

示例8: test_file_hash

# 需要导入模块: from mkt.files.models import File [as 别名]
# 或者: from mkt.files.models.File import from_upload [as 别名]
 def test_file_hash(self):
     upload = self.upload('mozball')
     f = File.from_upload(upload, self.version)
     assert f.hash.startswith('sha256:')
     assert len(f.hash) == 64 + 7  # 64 for hash, 7 for 'sha256:'
开发者ID:clouserw,项目名称:zamboni,代码行数:7,代码来源:test_models.py

示例9: test_filename_packaged

# 需要导入模块: from mkt.files.models import File [as 别名]
# 或者: from mkt.files.models.File import from_upload [as 别名]
 def test_filename_packaged(self):
     self.addon.is_packaged = True
     upload = self.upload('mozball')
     f = File.from_upload(upload, self.version)
     eq_(f.filename, 'app-name-0.1.zip')
开发者ID:clouserw,项目名称:zamboni,代码行数:7,代码来源:test_models.py

示例10: test_filename_hosted

# 需要导入模块: from mkt.files.models import File [as 别名]
# 或者: from mkt.files.models.File import from_upload [as 别名]
 def test_filename_hosted(self):
     upload = self.upload('mozball')
     f = File.from_upload(upload, self.version)
     eq_(f.filename, 'app-name-0.1.webapp')
开发者ID:clouserw,项目名称:zamboni,代码行数:6,代码来源:test_models.py


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