本文整理汇总了Python中nnmware.core.imgutil.remove_file函数的典型用法代码示例。如果您正苦于以下问题:Python remove_file函数的具体用法?Python remove_file怎么用?Python remove_file使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了remove_file函数的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: delete
def delete(self, *args, **kwargs):
try:
remove_thumbnails(self.pic.path)
remove_file(self.pic.path)
except:
pass
super(Pic, self).delete(*args, **kwargs)
开发者ID:biomassives,项目名称:nnmware,代码行数:7,代码来源:abstract.py
示例2: _ajax_upload
def _ajax_upload(self, request, **kwargs):
if request.method == "POST":
tmb = None
self._upload_file(request, **kwargs)
fullpath = os.path.join(settings.MEDIA_ROOT, self.extra_context['path'])
try:
i = Image.open(fullpath)
except:
messages.error(request, "File is not image format")
os.remove(fullpath)
self.success = False
self.pic_id = None
if self.success:
ctype = get_object_or_404(ContentType, id=int(kwargs['content_type']))
object_id = int(kwargs['object_id'])
obj = ctype.get_object_for_this_type(pk=object_id)
try:
remove_thumbnails(obj.img.path)
remove_file(obj.img.path)
obj.img.delete()
except:
pass
obj.img = self.extra_context['path']
obj.save()
# let Ajax Upload know whether we saved it or not
addons = {'tmb': make_thumbnail(obj.img.url, width=int(kwargs['width']), height=int(kwargs['height']),
aspect=int(kwargs['aspect']))}
payload = {'success': self.success, 'filename': self.filename}
if self.extra_context is not None:
payload.update(self.extra_context)
if addons:
payload.update(addons)
return AjaxAnswer(payload)
开发者ID:wallaceosmar,项目名称:nnmware,代码行数:33,代码来源:ajax.py
示例3: delete
def delete(self, *args, **kwargs):
try:
remove_thumbnails(self.agent_img.path)
remove_file(self.agent_img.path)
except:
pass
super(AbstractEmployee, self).delete(*args, **kwargs)
开发者ID:cdrone-hotels,项目名称:nnmware,代码行数:7,代码来源:models.py
示例4: delete
def delete(self, *args, **kwargs):
# noinspection PyBroadException
try:
remove_file(self.doc.path)
except:
pass
super(Doc, self).delete(*args, **kwargs)
开发者ID:nnmware,项目名称:nnmware,代码行数:7,代码来源:abstract.py
示例5: delete
def delete(self, *args, **kwargs):
try:
remove_thumbnails(self.img.path)
remove_file(self.img.path)
except:
pass
super(AbstractImg, self).delete(*args, **kwargs)
开发者ID:krast,项目名称:nnmware,代码行数:7,代码来源:abstract.py
示例6: form_valid
def form_valid(self, form):
avatar_path = self.object.avatar.url
remove_thumbnails(avatar_path)
remove_file(avatar_path)
self.object = form.save(commit=False)
self.object.avatar_complete = False
self.object.save()
resize_image(self.object.avatar.url)
return super(AvatarEdit, self).form_valid(form)
开发者ID:ksenor,项目名称:nnmware,代码行数:9,代码来源:views.py
示例7: avatar_delete
def avatar_delete(request):
try:
u = request.user
remove_thumbnails(u.img.url)
remove_file(u.img.url)
u.img = ''
u.save()
payload = {'success': True}
except:
payload = {'success': False}
return AjaxLazyAnswer(payload)
开发者ID:wallaceosmar,项目名称:nnmware,代码行数:11,代码来源:ajax.py
示例8: avatar_delete
def avatar_delete(request):
try:
profile = request.user.get_profile()
remove_thumbnails(profile.avatar.url)
remove_file(profile.avatar.url)
profile.avatar = ''
profile.save()
payload = {'success': True}
except:
payload = {'success': False}
return AjaxLazyAnswer(payload)
开发者ID:ksenor,项目名称:nnmware,代码行数:11,代码来源:views.py
示例9: avatardelete
def avatardelete(request):
if request.is_ajax():
try:
u = request.user
remove_thumbnails(u.img.path)
remove_file(u.img.path)
u.avatar_complete = False
u.img = None
u.save()
payload = {'success': True}
except:
payload = {'success': False}
return ajax_answer_lazy(payload)
else:
raise Http404()
开发者ID:cihatkk,项目名称:nnmware,代码行数:15,代码来源:ajax.py
示例10: avatardelete
def avatardelete(request):
if request.is_ajax():
try:
profile = request.user.get_profile()
remove_thumbnails(profile.avatar.path)
remove_file(profile.avatar.path)
profile.avatar_complete = False
profile.avatar = None
profile.save()
payload = {'success': True}
except:
payload = {'success': False}
return AjaxLazyAnswer(payload)
else:
raise Http404()
开发者ID:ksenor,项目名称:nnmware,代码行数:15,代码来源:views.py
示例11: avatar_delete
def avatar_delete(request):
try:
remove_thumbnails(request.user.img.url)
remove_file(request.user.img.url)
request.user.img = ''
request.user.save()
payload = {'success': True}
try:
addons = dict(html=render_to_string('user/avatar.html', {'object': request.user}))
except:
addons = {}
payload.update(addons)
except:
payload = {'success': False}
return ajax_answer_lazy(payload)
开发者ID:cihatkk,项目名称:nnmware,代码行数:15,代码来源:ajax.py
示例12: avatar_set
def avatar_set(request):
uploader = AjaxUploader(filetype='image', upload_dir=setting('AVATAR_UPLOAD_DIR', 'avatars'),
size_limit=setting('AVATAR_UPLOAD_SIZE', 1024000))
result = uploader.handle_upload(request)
if result['success']:
try:
remove_thumbnails(request.user.img.url)
remove_file(request.user.img.url)
except:
pass
request.user.img = result['path']
request.user.save()
try:
addons = dict(html=render_to_string('user/avatar.html', {'object': request.user}))
except:
addons = {}
result.update(addons)
return ajax_answer_lazy(result)
开发者ID:cihatkk,项目名称:nnmware,代码行数:18,代码来源:ajax.py
示例13: file_uploader
def file_uploader(request, **kwargs):
uploader = AjaxUploader(filetype='image', upload_dir=setting('IMAGE_UPLOAD_DIR', 'images'),
size_limit=setting('IMAGE_UPLOAD_SIZE', 10485760))
result = uploader.handle_upload(request)
if result['success']:
ctype = get_object_or_404(ContentType, id=int(kwargs['content_type']))
object_id = int(kwargs['object_id'])
obj = ctype.get_object_for_this_type(pk=object_id)
try:
remove_thumbnails(obj.img.path)
remove_file(obj.img.path)
obj.img.delete()
except:
pass
obj.img = result['path']
obj.save()
try:
addons = dict(tmb=make_thumbnail(obj.img.url, width=int(kwargs['width']), height=int(kwargs['height']),
aspect=int(kwargs['aspect'])))
except:
addons = {}
result.update(addons)
return AjaxAnswer(result)
开发者ID:wallaceosmar,项目名称:nnmware,代码行数:23,代码来源:ajax.py
注:本文中的nnmware.core.imgutil.remove_file函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论