Bugzilla – Bug 462603
capisuite 0.4.5 error in cs_helper.py sox related
Last modified: 2012-01-22 19:30:47 UTC
With new version of sox (& python) there's some messages which lead to an error raised. error log Thu Dec 25 16:42:00 2008 CapiSuite 0xbffae698: CapiSuite 0.4.5 started. Thu Dec 25 16:42:57 2008 Pythonscript /usr/lib/capisuite/incoming.py,callIncoming,0x826d2e8: A python error occured. See traceback below. Thu Dec 25 16:42:57 2008 Pythonscript 0x826d2e8: Python traceback: Traceback (most recent call last): Thu Dec 25 16:42:57 2008 Pythonscript 0x826d2e8: Traceback: File "/usr/lib/capisuite/incoming.py", line 75, in callIncoming Thu Dec 25 16:42:57 2008 Pythonscript 0x826d2e8: Traceback: voiceIncoming(call,call_from,call_to,curr_user,config) Thu Dec 25 16:42:57 2008 Pythonscript 0x826d2e8: Traceback: File "/usr/lib/capisuite/incoming.py", line 255, in voiceIncoming Thu Dec 25 16:42:57 2008 Pythonscript 0x826d2e8: Traceback: +"See attached file.\nThe original file was saved to file://"+filename+"\n\n", filename) Thu Dec 25 16:42:57 2008 Pythonscript 0x826d2e8: Traceback: File "/usr/lib/python2.6/site-packages/cs_helpers.py", line 234, in sendMIMEMail Thu Dec 25 16:42:57 2008 Pythonscript 0x826d2e8: Traceback: raise "conv-error","Error while calling sox. Not installed?" Thu Dec 25 16:42:57 2008 Pythonscript 0x826d2e8: Traceback: TypeError: exceptions must be classes or instances, not str Thu Dec 25 18:35:27 2008 CapiSuite 0xbffae698: CapiSuite finished. This could be corrected by this line the diff patch extract @@ -229,7 +229,8 @@ elif (mail_type=="la"): # voice file # la -> wav # don't use stdout as sox needs a file to be able to seek in it otherwise the header will be incomplete - ret = os.spawnlp(os.P_WAIT,"sox","sox",attachment,"-w",basename+"wav") + # ret = os.spawnlp(os.P_WAIT,"sox","sox",attachment,"-w",basename+"wav") + ret = os.spawnlp(os.P_WAIT,"sox","sox","-r","8000","-c","1",attachment,basename+"wav") if (ret or not os.access(basename+"wav",os.R_OK)): raise "conv-error","Error while calling sox. Not installed?" filepart = email.MIMEAudio.MIMEAudio(open(basename+"wav").read(),"x-wav",email.Encoders.encode_base64,name=os.path.basename(basename)+"wav") This only correct the call to sox without any warning or message. As I can't to much correct python code.
Additionally, all Text Exceptions should be replaced by Exception classes, as 11.1 ships python 2.6 and this does not accept them anymore. So for the example above: raise "conv-error","Error while calling sox." it should be replaced with something like: raise Exception("conv-error","Error while calling sox.")
Since I'm not a python expert as well, is this simple change enough, no need to define something else ? It seems to work: Thu Jan 15 15:49:36 2009 Pythonscript /usr/lib/capisuite/incoming.py,callIncoming,0x85a8c0: A python error occured. See traceback below. Thu Jan 15 15:49:36 2009 Pythonscript 0x85a8c0: Python traceback: Traceback (most recent call last): Thu Jan 15 15:49:36 2009 Pythonscript 0x85a8c0: Traceback: File "/usr/lib/capisuite/incoming.py", line 75, in callIncoming Thu Jan 15 15:49:36 2009 Pythonscript 0x85a8c0: Traceback: voiceIncoming(call,call_from,call_to,curr_user,config) Thu Jan 15 15:49:36 2009 Pythonscript 0x85a8c0: Traceback: File "/usr/lib/capisuite/incoming.py", line 255, in voiceIncoming Thu Jan 15 15:49:36 2009 Pythonscript 0x85a8c0: Traceback: +"See attached file.\nThe original file was saved to file://"+filename+"\n\n", filename) Thu Jan 15 15:49:36 2009 Pythonscript 0x85a8c0: Traceback: File "/usr/lib64/python2.6/site-packages/cs_helpers.py", line 235, in sendMIMEMail Thu Jan 15 15:49:36 2009 Pythonscript 0x85a8c0: Traceback: raise Exception("conv-error","Error while calling sox. Not installed?") Thu Jan 15 15:49:36 2009 Pythonscript 0x85a8c0: Traceback: Exception: ('conv-error', 'Error while calling sox. Not installed?')
You don't need to define something else. Perhaps it's not a beautiful solution, as a python list ('item','item') is put out, not a pure message. In the python 2.6.1 docs http://docs.python.org/c-api/exceptions.html#deprecation-of-string-exceptions it's written, that these string exceptions would be just depreacted, but still working. This does seem to be right, just the real "exception content" is replaced by their error message "Error: exceptions must be classes or instances, not str". My test program seems to continue after such a catched exception. So it's more eyecandy to replace the strings by classes. It's was just the locating of the problem in our real "sox"-bug for me becoming harder. This is something, that the maintainer of the capisuite should fix, but it seems that there is no one at the moment. Sorry, that I started a discussion about "another bug" by posting a comment to the sox bug
In this case it is OK, I'll fix it together, for the next release this avoid problems if python make it really fail. But I think it is not complete, it should not trow a traceback here. I think this code need also a change: except "conv-error",errormessage: text+="\n\nERROR occured while converting file: "+errormessage+"\nPlease talk to your friendly administrator.\n" textpart = email.MIMEText.MIMEText(text) msg.attach(textpart) Reading in the docu comes up with: except Exception as (errno, errormessage): ... Correct ?
What would be great as a fix, is to try it also with phython-3 as this version also come with opensuse 11.1 and would become the standard in near future.
Hmm I do not see python-3 on 11.1, which packages ?
zypper se ( or yast2 sw_single -> search ) python3 And you would get them | python3 | Python3 Interpreter | package | python3-2to3 | Python 3.0 conversion tool | package | python3-curses | Python Interface to the (N)Curses Library | package | python3-dbm | Python Interface to the GDBM Library | package | python3-demo | Python Demonstration Scripts | package | python3-devel | Include Files and Libraries Mandatory for Building Python Modules | package | python3-doc | Additional Package Documentation for Python. | package | python3-doc-pdf | Python PDF Documentation | package | python3-idle | An Integrated Development Environment for Python | package | python3-tk | TkInter - Python Tk Interface | package | python3-xml | A Python XML Interface
I thought that I searched for python3 and python-3, but maybe on the wrong installation. So to test this I think I need to build capisuite with python3-devel, but this gives an error on detecting the version: Python 3.0b3 (r30b3:65927, Dec 3 2008, 13:14:01) [GCC 4.3.2 [gcc-4_3-branch revision 141291]] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import sys; print sys.version[:3] File "<stdin>", line 1 import sys; print sys.version[:3] ^ SyntaxError: invalid syntax
OK this part was easy: import sys; print(sys.version[:3]) but also then the environment is not really ready for python3, autoconf will not find an interpreter with AM_PATH_PYTHON(3.0) so configure fail. I think this is now too much for this report, the problem is fixed and python3 has to wait.
The python3 was just an enhancement in case of . I couldn't evaluate how large would be the modification. If you have success with 2.6. You could close this bug when the updated package is published. Thanks a lot. As I think many european using isdn telephony & fax would be happy to see this package continue to work.
This need a maintenance update.
If this needs a maintenance update, please do not assign, but needinfo ast@novell.com
Anja, we are at less than 8 weeks from 11.2 release, why this bug is always in state open / assign ? Should you need something more to have this working in 11.2 ?
> Anja, we are at less than 8 weeks from 11.2 release, why this bug is always in > state open / assign ? I should be fixed by the maintainer in Factory. Then he can close the bug. > Should you need something more to have this working in 11.2 ? No. You only have to submit the fix to Factory. No SwampID is needed here.
This has been solved by related updates Confirmed to work with 11.3,11.4,12.1