[Tutor] can not get subtype?

Ertl, John John.Ertl at fnmoc.navy.mil
Thu Oct 21 18:44:37 CEST 2004


I am working on a simple web service that uses SOAP with attachments and the
attachment is a multi part mime message.  The MIME has some text and a png
image.

I have recently transferred everything including rebuilding python (same
version as old system 2.3.4) and now the email MIMEImage can not
automatically figure out the image type (it worked on the old system).  I
had to add '_subtype="png"' to the MIMEImage line (see below).  For now I
guess that is OK but I am wondering if something else is going on that I
should know about.  This also precludes me from producing other types
without changing my code.

###### error I was getting before I add _subtype to MIMEImage #########

File
"/gpfs3/opt/webservices/apache/app/tmd/cgi-bin/TMD/checking/makeMIME.py",
line 64, in mimeMe
    img = MIMEImage(fp.read())
  File "/home/ertlj/ertljVersion/lib/python2.3/email/MIMEImage.py", line 42,
in __init__
    raise TypeError, 'Could not guess image MIME subtype'
TypeError: Could not guess image MIME subtype

######## Fixed MIMEImage #########
fp = open(pngfullpath, 'rb')
        img = MIMEImage(fp.read(),_subtype="png")
        fp.close()


Thanks for the help.

John Ertl 


More information about the Tutor mailing list