properly differentiate between subdoc or fatal error in execm protocol
This commit is contained in:
parent
21e16bb8a2
commit
f4aa7fcec4
@ -9,6 +9,10 @@ class RclExecM:
|
||||
noteof = 0
|
||||
eofnext = 1
|
||||
eofnow = 2
|
||||
|
||||
noerror = 0
|
||||
subdocerror = 1
|
||||
fileerror = 2
|
||||
|
||||
def __init__(self):
|
||||
self.myname = os.path.basename(sys.argv[0])
|
||||
@ -60,25 +64,30 @@ class RclExecM:
|
||||
return (paramname, paramdata)
|
||||
|
||||
# Send answer: document, ipath, possible eof.
|
||||
def answer(self, docdata, ipath, iseof = noteof):
|
||||
def answer(self, docdata, ipath, iseof = noteof, iserror = noerror):
|
||||
|
||||
print "Document:", len(docdata)
|
||||
sys.stdout.write(docdata)
|
||||
if iserror != RclExecM.fileerror and iseof != RclExecM.eofnow:
|
||||
print "Document:", len(docdata)
|
||||
sys.stdout.write(docdata)
|
||||
|
||||
if len(ipath):
|
||||
print "Ipath:", len(ipath)
|
||||
sys.stdout.write(ipath)
|
||||
if len(ipath):
|
||||
print "Ipath:", len(ipath)
|
||||
sys.stdout.write(ipath)
|
||||
|
||||
if len(self.mimetype):
|
||||
print "Mimetype:", len(self.mimetype)
|
||||
sys.stdout.write(self.mimetype)
|
||||
if len(self.mimetype):
|
||||
print "Mimetype:", len(self.mimetype)
|
||||
sys.stdout.write(self.mimetype)
|
||||
|
||||
# If we're at the end of the contents, say so
|
||||
if iseof == self.eofnow:
|
||||
if iseof == RclExecM.eofnow:
|
||||
print "Eofnow: 0"
|
||||
elif iseof == self.eofnext:
|
||||
elif iseof == RclExecM.eofnext:
|
||||
print "Eofnext: 0"
|
||||
|
||||
if iserror == RclExecM.subdocerror:
|
||||
print "Subdocerror: 0"
|
||||
elif iserror == RclExecM.fileerror:
|
||||
print "Fileerror: 0"
|
||||
|
||||
# End of message
|
||||
print
|
||||
sys.stdout.flush()
|
||||
@ -93,7 +102,7 @@ class RclExecM:
|
||||
# If we're given a file name, open it.
|
||||
if len(params["filename:"]) != 0:
|
||||
if not processor.openfile(params):
|
||||
self.answer("", "", True)
|
||||
self.answer("", "", iserror = RclExecM.fileerror)
|
||||
return
|
||||
|
||||
# If we have an ipath, that's what we look for, else ask for next entry
|
||||
@ -107,7 +116,7 @@ class RclExecM:
|
||||
if ok:
|
||||
self.answer(data, ipath, eof)
|
||||
else:
|
||||
self.answer("", "", eof)
|
||||
self.answer("", "", eof, RclExecM.subdocerror)
|
||||
|
||||
# Loop on messages from our master
|
||||
def mainloop(self, processor):
|
||||
|
||||
@ -181,6 +181,8 @@ bool MimeHandlerExecMultiple::next_document()
|
||||
LOGDEB1(("MHExecMultiple: reading answer\n"));
|
||||
bool eofnext_received = false;
|
||||
bool eofnow_received = false;
|
||||
bool fileerror_received = false;
|
||||
bool subdocerror_received = false;
|
||||
string ipath;
|
||||
string mtype;
|
||||
for (int loop=0;;loop++) {
|
||||
@ -194,16 +196,22 @@ bool MimeHandlerExecMultiple::next_document()
|
||||
if (!stringlowercmp("eofnext:", name)) {
|
||||
LOGDEB(("MHExecMultiple: got EOFNEXT\n"));
|
||||
eofnext_received = true;
|
||||
}
|
||||
if (!stringlowercmp("eofnow:", name)) {
|
||||
} else if (!stringlowercmp("eofnow:", name)) {
|
||||
LOGDEB(("MHExecMultiple: got EOFNOW\n"));
|
||||
eofnow_received = true;
|
||||
}
|
||||
if (!stringlowercmp("ipath:", name)) {
|
||||
} else if (!stringlowercmp("subdocerror:", name)) {
|
||||
LOGDEB(("MHExecMultiple: got SUBDOCERROR\n"));
|
||||
subdocerror_received = true;
|
||||
} else if (!stringlowercmp("fileerror:", name)) {
|
||||
LOGDEB(("MHExecMultiple: got FILEERROR\n"));
|
||||
fileerror_received = true;
|
||||
} else if (!stringlowercmp("subdocerror:", name)) {
|
||||
LOGDEB(("MHExecMultiple: got SUBDOCERROR\n"));
|
||||
return false;
|
||||
} else if (!stringlowercmp("ipath:", name)) {
|
||||
ipath = data;
|
||||
LOGDEB(("MHExecMultiple: got ipath [%s]\n", data.c_str()));
|
||||
}
|
||||
if (!stringlowercmp("mimetype:", name)) {
|
||||
} else if (!stringlowercmp("mimetype:", name)) {
|
||||
mtype = data;
|
||||
LOGDEB(("MHExecMultiple: got mimetype [%s]\n", data.c_str()));
|
||||
}
|
||||
@ -214,11 +222,14 @@ bool MimeHandlerExecMultiple::next_document()
|
||||
}
|
||||
}
|
||||
|
||||
if (eofnow_received) {
|
||||
if (eofnow_received || fileerror_received) {
|
||||
// No more docs
|
||||
m_havedoc = false;
|
||||
return false;
|
||||
}
|
||||
if (subdocerror_received) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// It used to be that eof could be signalled just by an empty document, but
|
||||
// this was wrong. Empty documents can be found ie in zip files and should
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user