From 69398972d713d5fb52926344795b0e9f3d217e5b Mon Sep 17 00:00:00 2001 From: htgoebel Date: Fri, 28 Jan 2005 19:35:51 +0000 Subject: [PATCH] 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 --- scripts/idle.py | 9 ++++++--- src/capisuite-py/core.py | 14 ++++++++++++-- src/capisuite-py/fax.py | 10 ++++++---- 3 files changed, 24 insertions(+), 9 deletions(-) diff --git a/scripts/idle.py b/scripts/idle.py index 8698f08..de17dd1 100644 --- a/scripts/idle.py +++ b/scripts/idle.py @@ -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) diff --git a/src/capisuite-py/core.py b/src/capisuite-py/core.py index 9a72f2a..d352045 100644 --- a/src/capisuite-py/core.py +++ b/src/capisuite-py/core.py @@ -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: diff --git a/src/capisuite-py/fax.py b/src/capisuite-py/fax.py index a7a84cd..95111e8 100644 --- a/src/capisuite-py/fax.py +++ b/src/capisuite-py/fax.py @@ -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