Multifile EOF error
avenpace at gmail.com
avenpace at gmail.com
Wed Mar 22 04:49:07 EST 2006
> Try to trim down your script to the minimal code that produces the error
> and post both. Copy'n'paste code and traceback, don't retype it.
The code is kinda bit long so you can see the whole idea. I use some
libgmail and twisted web
#code start
def displayComment(request):
gmc = libgmail.GmailAccount(gmailacc, gmailpasswd)
try:
gmc.login()
except:
request.write("Cannot feed comment now, sorry")
for tkey, tvals in request.args.items():
if tkey == "tiddler":
for tval in tvals:
tidlabel = tval
else:
request.write("Wrong url setting in the commen plugin")
fold = gmc.getMessagesByLabel(tidlabel)
for thread in fold:
for msg in thread:
msource = msg.source
cmess = str(feedComment(msource))
print "abis manggil feed"
fcmess = join(cmess)
def feedComment(fsrcs):
print fsrcs
srcsw = file("/tmp/srcs" + magic + ".tmp_", "w") #creating and
write the mess source
srcsw.write(fsrcs)
srcsw.close()
srcs = file("/tmp/srcs" + magic + ".tmp_", "r")
dstfile = file("/tmp/" + magic + ".tmp","w")
src = multifile.MultiFile(srcs,0)
print "diatas header"
headers = mimetools.Message(src, src.seekable)
print "dibawah header"
if headers.getmaintype() != "multipart":
print "message is not multipart :("
boundary = headers.getparam("boundary")
if not boundary:
print "meesage boundary not specified"
src.push(boundary)
src.next()
headers = mimetools.Message(src, src.seekable)
encode = headers.getencoding()
if not encode:
print "Unknown encoding mail"
mimetools.decode(src, dstfile, encode)
dstfile.close()
dstread = file("/tmp" + magic + ".tmp", "r")
mess = dstread.read()
#removing all the file generated in the tmp dir
os.remove("/tmp/srcs" + magic + ".tmp_")
os.remove("/tmp" + magic + ".tmp")
return mess +"\n\n"
#end of code
the error that I get is
Traceback (most recent call last):
File
"/usr/lib/python2.4/site-packages/twisted/internet/selectreactor.py",
line 133, in doSelect
_logrun(selectable, _drdw, selectable, method, dict)
File "/usr/lib/python2.4/site-packages/twisted/python/log.py", line
56, in callWithLogger
return callWithContext({"system": lp}, func, *args, **kw)
File "/usr/lib/python2.4/site-packages/twisted/python/log.py", line
41, in callWithContext
return context.call({ILogContext: newCtx}, func, *args, **kw)
File "/usr/lib/python2.4/site-packages/twisted/python/context.py",
line 31, in callWithContext
return func(*args,**kw)
--- <exception caught here> ---
File
"/usr/lib/python2.4/site-packages/twisted/internet/selectreactor.py",
line 139, in _doReadOrWrite
why = getattr(selectable, method)()
File "/usr/lib/python2.4/site-packages/twisted/internet/tcp.py", line
351, in doRead
return self.protocol.dataReceived(data)
File "/usr/lib/python2.4/site-packages/twisted/protocols/basic.py",
line 221, in dataReceived
why = self.lineReceived(line)
File "/usr/lib/python2.4/site-packages/twisted/web/http.py", line
961, in lineReceived
self.allContentReceived()
File "/usr/lib/python2.4/site-packages/twisted/web/http.py", line
1002, in allContentReceived
req.requestReceived(command, path, version)
File "/usr/lib/python2.4/site-packages/twisted/web/http.py", line
557, in requestReceived
self.process()
File "libgmail-0.1.4/servetiddly.py", line 180, in process
handler(self)
File "libgmail-0.1.4/servetiddly.py", line 149, in displayComment
cmess = str(feedComment(msource))
File "libgmail-0.1.4/servetiddly.py", line 118, in feedComment
src.next()
File "/usr/lib/python2.4/multifile.py", line 120, in next
while self.readline(): pass
File "/usr/lib/python2.4/multifile.py", line 80, in readline
raise Error, 'sudden EOF in MultiFile.readline()'
multifile.Error: sudden EOF in MultiFile.readline()
More information about the Python-list
mailing list