Fixed passing fax-info about received faxes to MailFaxRecievd message.

Details:
core.py: some fax functions did not return faxInfo even if the C++
         implementaion does. Fixed.
fax.py: sendinfo now returns the faxInfo like this:
        ((result, resultB3), faxInfo)
idle-script: faxInfo is now taken from fax.sendfax() and included into
             sendinfo, which is used by MailFaxRecievd message.


git-svn-id: https://svn.ibp.de/svn/capisuite/trunk/capisuite@429 4ebea2bb-67d4-0310-8558-a5799e421b66
This commit is contained in:
htgoebel 2005-01-28 19:35:51 +00:00
parent 4f97c8f413
commit 69398972d7
3 changed files with 24 additions and 9 deletions

View File

@ -115,19 +115,23 @@ def idle(capi):
core.log("job %s from %s to %s initiated" %
(jobnum, user, sendinfo['dialstring']), 1)
result, resultB3 = capisuite.fax.sendfax(config, user, capi,
fax_file, **sendinfo)
result, faxinfo = capisuite.fax.sendfax(config, user, capi,
fax_file, **sendinfo)
result, resultB3 = result
core.log("job %s: result was 0x%x, 0x%x" % \
(jobnum, result, resultB3), 1)
sendinfo['result'] = result
sendinfo['resultB3'] = resultB3
sendinfo['hostname'] = os.uname()[1]
if faxinfo:
sendinfo.update(faxinfo.as_dict())
# todo: use symbolic names for these results to be more
# meaningfull
send_ok = resultB3 == 0 \
and result in (0, 0x3400, 0x3480, 0x3490, 0x349f)
tries = control.getint("tries") +1
control.set('tries', tries)
if send_ok:
core.log("job %s: finished successfully" % jobnum, 1)
control = capisuite.fax.moveJob(controlfile, doneQ, user)
@ -152,7 +156,6 @@ def idle(capi):
(jobnum, next_delay), 2)
starttime = time.time() + next_delay
control.set('starttime', time.ctime(starttime))
control.set('tries', tries)
control.write(controlfile)
finally:
_releaseLock(lock)

View File

@ -344,6 +344,7 @@ class Call:
faxInfo = _capisuite.switch_to_faxG3(self._handle,
faxStationID, faxHeadline)
self.service = SERVICE_FAXG3
log('faxinfo: %s' % repr(faxInfo), 3)
if not faxInfo:
return FaxInfo()
return FaxInfo(*faxInfo)
@ -373,6 +374,7 @@ class Call:
"""
faxInfo = _capisuite.connect_faxG3(self._handle, faxStationID,
faxHeadline, delay)
log('faxinfo: %s' % repr(faxInfo), 3)
if not faxInfo:
return FaxInfo()
return FaxInfo(*faxInfo)
@ -394,7 +396,11 @@ class Call:
faxfilename: file to send
"""
_capisuite.fax_send(self._handle, faxfilename)
faxInfo = _capisuite.fax_send(self._handle, faxfilename)
log('faxinfo: %s' % repr(faxInfo), 3)
if not faxInfo:
return FaxInfo()
return FaxInfo(*faxInfo)
def fax_receive(self, filename):
@ -413,7 +419,11 @@ class Call:
filename: where to save the received fax.
"""
_capisuite.fax_receive(self._handle, filename)
faxInfo = _capisuite.fax_receive(self._handle, filename)
log('faxinfo: %s' % repr(faxInfo), 3)
if not faxInfo:
return FaxInfo()
return FaxInfo(*faxInfo)
class FaxInfo:

View File

@ -231,6 +231,8 @@ def sendfax(config, user, capi, faxfile,
outgoing_num, dialstring, stationID=None, headline=None):
"""
Send a fax out via the capi.
Returns a tuple ((result, resultB3), faxinfo)
"""
import capisuite.core as core
@ -252,8 +254,8 @@ def sendfax(config, user, capi, faxfile,
core.log('result from capi.call_faxG3: %s' % result, 2)
if result:
# an errror occured
return result, 0
call.fax_send(faxfile)
return call.disconnect()
return (result, 0), None
faxinfo = call.fax_send(faxfile)
return call.disconnect(), faxinfo
except core.CallGoneError:
return call.disconnect()
return call.disconnect(), None