From: Patrick T. <tul...@fl...> - 2003-11-10 05:58:45
|
Appended below is small patch for phonebook.py. The first patch (checking the indexes in PhoneDataTable.GetValue) seems to prevent an infinite recursion of exceptions. (I think its trying to invoke GetValue on something in an exception handler, which causes another, etc. Eventually I get Python's equivalent of a stack overflow.) Returning "" if an index is bad seems to not cause any problems, but I've no idea if its safe... (FYI, the explosion of exceptions dialogs happens at the end of getting the phonebook contents. I can get the log contents before/after the patch if that might help.) It might be worth adding code to notice exceptions during the exception display and suppress them... heh, you could even pop up a bitpim-BSOD... :) The second patch is just because wxPython doesn't word-wrap its dialog boxes, so I manually wrapped the long message. The "python way" probably doesn't involve +='ing string constants... With these two changes I can read my existing phonebook entries off my phone. I haven't taken the plunge and actually written anything back yet. :) My phone is an LGVX4400, I'm running bitpim out of CVS (sync'd as of AM Nov. 09), on Linux (Debian/testing, 2.4.22 kernel). I've got wxpython version 2.4.2.4, python 2.3, pyserial 2.0, and DSV 1.4.0. I'm using the USB cable. I haven't had a chance to play with bitpim for about 6 months. Its progressed impressively since then! I'm really hoping the palm<->lg sync stuff will let me migrate my contact info out of jpliot... -Pat ----- ----- ---- --- --- -- - - - - - Pat Tullmann tul...@fl... Techs in white lab coats are the primary cause of cancer in rats. Index: phonebook.py =================================================================== RCS file: /cvsroot/bitpim/bitpim/phonebook.py,v retrieving revision 1.9 diff -u -b -u -r1.9 phonebook.py --- phonebook.py 8 Nov 2003 11:53:29 -0000 1.9 +++ phonebook.py 10 Nov 2003 04:47:43 -0000 @@ -190,7 +190,16 @@ return res def GetValue(self, row, col): - entry=self.main._data[self.rowkeys[row]] + if row >= len(self.rowkeys): + return "" + else: + key=self.rowkeys[row] + + if key >= len(self.main._data): + return "" + else: + entry=self.main._data[key] + if col==0: names=entry.get("names", [{'full': '<not set>'}]) name=names[0] @@ -278,7 +287,12 @@ # 1 to 2 etc if version==1: - wx.MessageBox("BitPim can't upgrade your old phone data stored on disk, and has discarded it. Please re-read your phonebook from the phone. If you downgrade, please delete the phonebook directory in the BitPim data directory first", "Phonebook file format not supported", wx.OK|wx.ICON_EXCLAMATION) + msg="BitPim can't upgrade your old phone data stored on disk,\n" + msg+="and has discarded it. Please re-read your phonebook from\n" + msg+="the phone.\n\n" + msg+="If you downgrade, please delete the phonebook directory in\n" + msg+="the BitPim data directory first\n" + wx.MessageBox(msg, "Phonebook file format not supported", wx.OK|wx.ICON_EXCLAMATION) version=2 dict['phonebook']={} |