Understanding and dealing with an exception
Vincent Davis
vincent at vincentdavis.net
Sun Oct 14 15:31:42 EDT 2012
Yes afile is the file name and extension, ifile is the full file name and
path.
Thanks
Vincent
On Sunday, October 14, 2012, MRAB wrote:
> On 2012-10-14 05:23, Vincent Davis wrote:
>
>> I am working on a script to find bad image files. I am using PIL
>> and specifically image.verify() I have a set of known to be bad image
>> files to test. I also what to be able to test any file for example a
>> .txt and deal with the exception.
>> Currently my code is basically
>>
>> try:
>> im = Image.open(ifile)
>> try:
>> print(im.verify())
>> except:
>> print('Pil image.verify() failed: ' + afile)
>> except IOError:
>> print('PIL cannot identify image file: ' + afile)
>> except:
>> print(ifile)
>> print("Unexpected error doing PIL.Image.open():", sys.exc_info()[0])
>> raise
>>
>> [snip]
> I notice that you have both "ifile" and "afile". Is that correct?
>
> --
> http://mail.python.org/**mailman/listinfo/python-list<http://mail.python.org/mailman/listinfo/python-list>
>
--
Vincent Davis
720-301-3003
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20121014/59afec7f/attachment.html>
More information about the Python-list
mailing list