本文整理汇总了Python中mkt.site.storage_utils.public_storage.delete函数的典型用法代码示例。如果您正苦于以下问题:Python delete函数的具体用法?Python delete怎么用?Python delete使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了delete函数的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_upload_sign_error_existing
def test_upload_sign_error_existing(self, sign_app_mock):
sign_app_mock.side_effect = SigningError
langpack = self.create_langpack()
eq_(LangPack.objects.count(), 1)
original_uuid = langpack.uuid
original_file_path = langpack.file_path
original_file_version = langpack.file_version
original_version = langpack.version
# create_langpack() doesn't create a fake file, let's add one.
with public_storage.open(langpack.file_path, 'w') as f:
f.write('.')
upload = self.upload('langpack')
with self.assertRaises(SigningError):
LangPack.from_upload(upload, instance=langpack)
# Test that we didn't delete the upload file
ok_(private_storage.exists(upload.path))
# Test that we didn't delete the existing filename or alter the
# existing langpack in the database.
eq_(LangPack.objects.count(), 1)
langpack.reload()
eq_(original_uuid, langpack.uuid)
eq_(langpack.file_path, original_file_path)
eq_(original_file_version, langpack.file_version)
eq_(original_version, langpack.version)
ok_(public_storage.exists(langpack.file_path))
# Cleanup
public_storage.delete(langpack.file_path)
开发者ID:Fjoerfoks,项目名称:zamboni,代码行数:28,代码来源:test_models.py
示例2: delete
def delete(self):
log.info(u'Version deleted: %r (%s)' % (self, self.id))
mkt.log(mkt.LOG.DELETE_VERSION, self.webapp, str(self.version))
models.signals.pre_delete.send(sender=Version, instance=self)
was_current = False
if self == self.webapp.current_version:
was_current = True
self.update(deleted=True)
# Set file status to disabled.
f = self.all_files[0]
f.update(status=mkt.STATUS_DISABLED, _signal=False)
f.hide_disabled_file()
# If version deleted was the current version and there now exists
# another current_version, we need to call some extra methods to update
# various bits for packaged apps.
if was_current and self.webapp.current_version:
self.webapp.update_name_from_package_manifest()
self.webapp.update_supported_locales()
if self.webapp.is_packaged:
# Unlink signed packages if packaged app.
public_storage.delete(f.signed_file_path)
log.info(u'Unlinked file: %s' % f.signed_file_path)
private_storage.delete(f.signed_reviewer_file_path)
log.info(u'Unlinked file: %s' % f.signed_reviewer_file_path)
models.signals.post_delete.send(sender=Version, instance=self)
开发者ID:shahbaz17,项目名称:zamboni,代码行数:32,代码来源:models.py
示例3: remove_public_signed_file
def remove_public_signed_file(self):
"""Remove the public signed file if it exists.
Return the size of the unsigned file, to be used by the caller to
update the size property on the current instance."""
if public_storage.exists(self.signed_file_path):
public_storage.delete(self.signed_file_path)
return private_storage.size(self.file_path)
开发者ID:1Smert1,项目名称:zamboni,代码行数:8,代码来源:models.py
示例4: delete_preview_files
def delete_preview_files(id, **kw):
task_log.info('[[email protected]] Removing preview with id of %s.' % id)
p = Preview(id=id)
for f in (p.thumbnail_path, p.image_path):
try:
public_storage.delete(f)
except Exception, e:
task_log.error('Error deleting preview file (%s): %s' % (f, e))
开发者ID:mrheides,项目名称:zamboni,代码行数:9,代码来源:tasks.py
示例5: setup_files
def setup_files(self):
# Clean out any left over stuff.
public_storage.delete(self.file.signed_file_path)
private_storage.delete(self.file.signed_reviewer_file_path)
# Make sure the source file is there.
if not private_storage.exists(self.file.file_path):
copy_stored_file(self.packaged_app_path('mozball.zip'),
self.file.file_path, src_storage=local_storage,
dst_storage=private_storage)
开发者ID:Fjoerfoks,项目名称:zamboni,代码行数:10,代码来源:tests.py
示例6: check_delete
def check_delete(self, file_, filename):
"""Test that when the File object is deleted, it is removed from the
filesystem."""
try:
with public_storage.open(filename, 'w') as f:
f.write('sample data\n')
assert public_storage.exists(filename)
file_.delete()
assert not public_storage.exists(filename)
finally:
if public_storage.exists(filename):
public_storage.delete(filename)
开发者ID:Witia1,项目名称:zamboni,代码行数:12,代码来源:test_models.py
示例7: test_delete_with_file
def test_delete_with_file(self):
"""Test that when a LangPack instance is deleted, the corresponding
file on the filesystem is also deleted."""
langpack = LangPack.objects.create(version='0.1')
file_path = langpack.file_path
with public_storage.open(file_path, 'w') as f:
f.write('sample data\n')
assert public_storage.exists(file_path)
try:
langpack.delete()
assert not public_storage.exists(file_path)
finally:
if public_storage.exists(file_path):
public_storage.delete(file_path)
开发者ID:Fjoerfoks,项目名称:zamboni,代码行数:14,代码来源:test_models.py
示例8: test_resize_transparency
def test_resize_transparency():
src = get_image_path('transparent.png')
dest = tempfile.mkstemp(dir=settings.TMP_PATH)[1]
expected = src.replace('.png', '-expected.png')
if storage_is_remote():
copy_to_storage(src, src, src_storage=local_storage)
try:
resize_image(src, dest, (32, 32), remove_src=False)
with public_storage.open(dest) as dfh:
with open(expected) as efh:
assert dfh.read() == efh.read()
finally:
if public_storage.exists(dest):
public_storage.delete(dest)
开发者ID:ayushagrawal288,项目名称:zamboni,代码行数:14,代码来源:test_utils_.py
示例9: sign_and_move_file
def sign_and_move_file(self, upload):
ids = json.dumps({
# 'id' needs to be an unique identifier not shared with anything
# else (other langpacks, webapps, extensions...), but should not
# change when there is an update. Since our PKs are uuid it's the
# best choice.
'id': self.pk,
# 'version' should be an integer and should be monotonically
# increasing.
'version': self.file_version
})
with statsd.timer('langpacks.sign'):
try:
# This will read the upload.path file, generate a signature
# and write the signed file to self.file_path.
sign_app(private_storage.open(upload.path),
self.file_path, ids)
except SigningError:
log.info('[LangPack:%s] Signing failed' % self.pk)
if public_storage.exists(self.file_path):
public_storage.delete(self.file_path)
raise
开发者ID:shahbaz17,项目名称:zamboni,代码行数:22,代码来源:models.py
示例10: _uploader
def _uploader(resize_size, final_size):
img = get_image_path('mozilla.png')
original_size = (339, 128)
for rsize, fsize in zip(resize_size, final_size):
dest_name = os.path.join(settings.ADDON_ICONS_PATH, '1234')
src = tempfile.NamedTemporaryFile(mode='r+w+b', suffix='.png',
delete=False)
# resize_icon removes the original, copy it to a tempfile and use that.
copy_stored_file(img, src.name, src_storage=local_storage,
dest_storage=private_storage)
# Sanity check.
with private_storage.open(src.name) as fp:
src_image = Image.open(fp)
src_image.load()
eq_(src_image.size, original_size)
val = tasks.resize_icon(src.name, dest_name, resize_size)
eq_(val, {'icon_hash': 'bb362450'})
dest_image_filename = '%s-%s.png' % (dest_name, rsize)
with public_storage.open(dest_image_filename) as fp:
dest_image = Image.open(fp)
dest_image.load()
# Assert that the width is always identical.
eq_(dest_image.size[0], fsize[0])
# Assert that the height can be a wee bit fuzzy.
assert -1 <= dest_image.size[1] - fsize[1] <= 1, (
'Got width %d, expected %d' % (
fsize[1], dest_image.size[1]))
if public_storage.exists(dest_image_filename):
public_storage.delete(dest_image_filename)
assert not public_storage.exists(dest_image_filename)
assert not private_storage.exists(src.name)
开发者ID:ayushagrawal288,项目名称:zamboni,代码行数:37,代码来源:test_tasks.py
示例11: _promo_img_uploader
def _promo_img_uploader(resize_size, final_size):
img = get_image_path('game_1050.jpg')
original_size = (1050, 591)
for rsize, fsize in zip(resize_size, final_size):
dst_name = os.path.join(settings.WEBAPP_PROMO_IMG_PATH, '1234')
src = tempfile.NamedTemporaryFile(mode='r+w+b', suffix='.jpg',
delete=False)
# resize_icon removes the original, copy it to a tempfile and use that.
copy_stored_file(img, src.name, src_storage=local_storage,
dst_storage=private_storage)
# Sanity check.
with private_storage.open(src.name) as fp:
src_image = Image.open(fp)
src_image.load()
eq_(src_image.size, original_size)
val = tasks.resize_promo_imgs(src.name, dst_name, resize_size)
eq_(val, {'promo_img_hash': '215dd2a2'})
dst_img_name = '%s-%s.png' % (dst_name, rsize)
with public_storage.open(dst_img_name) as fp:
dst_image = Image.open(fp)
dst_image.load()
# Assert that the width is always identical.
eq_(dst_image.size[0], fsize[0])
# Assert that the height can be a wee bit fuzzy.
assert -1 <= dst_image.size[1] - fsize[1] <= 1, (
'Got width %d, expected %d' % (
fsize[1], dst_image.size[1]))
if public_storage.exists(dst_img_name):
public_storage.delete(dst_img_name)
assert not public_storage.exists(dst_img_name)
assert not private_storage.exists(src.name)
开发者ID:Fjoerfoks,项目名称:zamboni,代码行数:36,代码来源:test_tasks.py
示例12: destroy
def destroy(self, request, *args, **kwargs):
obj = self.get_object()
if getattr(obj, "image_hash", None):
public_storage.delete(obj.image_path(self.image_suffix))
obj.update(**{self.hash_field: None})
return Response(status=status.HTTP_204_NO_CONTENT)
开发者ID:waseem18,项目名称:zamboni,代码行数:6,代码来源:views.py
示例13: tearDown
def tearDown(self):
public_storage.delete(self.latest_file.file_path)
开发者ID:Fjoerfoks,项目名称:zamboni,代码行数:2,代码来源:test_views.py
示例14: tearDown
def tearDown(self):
public_storage.delete(self.img_path)
开发者ID:ayushagrawal288,项目名称:zamboni,代码行数:2,代码来源:test_tasks.py
示例15: remove_promo_imgs
def remove_promo_imgs(destination):
for size in mkt.PROMO_IMG_SIZES:
filename = '%s-%s.png' % (destination, size)
if public_storage.exists(filename):
public_storage.delete(filename)
开发者ID:kolyaflash,项目名称:zamboni,代码行数:5,代码来源:utils.py
示例16: remove_icons
def remove_icons(destination):
for size in mkt.CONTENT_ICON_SIZES:
filename = '%s-%s.png' % (destination, size)
if public_storage.exists(filename):
public_storage.delete(filename)
开发者ID:kolyaflash,项目名称:zamboni,代码行数:5,代码来源:utils.py
示例17: remove_signed_file
def remove_signed_file(self):
if public_storage.exists(self.signed_file_path):
public_storage.delete(self.signed_file_path)
开发者ID:shahbaz17,项目名称:zamboni,代码行数:3,代码来源:models.py
注:本文中的mkt.site.storage_utils.public_storage.delete函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论