Discussion:
[Bitpim-devel] small patches for phonebook.py
Patrick Tullmann
2003-11-10 05:58:37 UTC
Permalink
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 ***@flux.utah.edu
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']={}
Roger Binns
2003-11-11 06:52:26 UTC
Permalink
Post by Patrick Tullmann
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 did a different change earlier. What is actually happening is
that the grid thinks there are more rows than there actually
are. It starts asking for non-existent ones which generate an
exception. The exception dialog is a modal dialog (ie the
ShowModal function starts a new message loop and doesn't
return until the dialog is closed). The phonebook tries to
display the next cell, and causes another exception which causes
another modal exception dialog to appear etc. It isn't infinite -
there will just be one exception per cell, but it is a reasonable
approximation of infinity :-)

A future enhancement I will need to do is to make new exceptions
append to the existing dialog if it is visible rather than
cause a new dialog to be displayed.

The root cause was that the message to tell the grid that rows were
deleted was being ignored. That was because it has to be told which
rows were deleted, not just how many. The appending of rows worked
fine however, so it just kept growing each time new entries were
read in.

I have now fixed the code to do the correct deletion and all works
fine. I do however want to use a custom widget at some point. The
grid does lots of nasty stuff I don't like. For example try pressing
the arrow keys to see how broken that is.
Post by Patrick Tullmann
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...
I do it all the time :-) The actual problem is that there isn't an
auto-sizing word wrapping text widget in wxWindows. I did however
find that the HTML widget will at least wrap its text, but it won't
shrink or expand its size. Try the import dialog after selecting
a file and resize the dialog, paying attention to the instructions
at the top.

Now, if anyone wants a little project then a self sizing HTML widget
would be great. It shouldn't be too much work, and the wxPython
community would be very grateful :-) Let me know if you or anyone
else wants to tackle this.

I would use it all over the place.
Post by Patrick Tullmann
My phone is an LGVX4400, I'm running bitpim out of CVS (sync'd as of
AM Nov. 09),
The public CVS servers are now synced every 5 hours with the main ones
according to SourceForge.
Post by Patrick Tullmann
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.
On Linuxm, I use Redhat 8 which is the same versions as above except
Python is 2.2. As that machine suffers from kernel panics when closing
the USB serial device (a known kernel bug), I don't actually talk to the
phone with it. I then use my dual boot XP/RH9 box for testing that
actually involves the phone.
Post by Patrick Tullmann
I'm really hoping the palm<->lg
sync stuff will let me migrate my contact info out of jpliot...
The CSV import is coming on nicely. I am just working on code to display
an entry (that is the right hand side in the main phone book tab).
The idea is that the last part of the import process will work much
like personal finance programs. It will show you what was supplied
from the import, what record already existed, and the result.

I also found a Python library function that makes working out matches
a real cinch. Run experiments/matching.py to see it in action. According
to the doc, a figure of 60 or greater should be considered a match. My
first attempt is just going to convert each record to text and run
that function. I suspect it will give pretty decent results.

And if you want some real fun, turn on protocol logging, read from the
phone and then press Ctrl-Alt-P while viewing the protocol log.

Roger
Stephen Wood
2003-11-12 15:54:32 UTC
Permalink
My phone's browser will accept urls without http:// in front of them.
So generally, the urls in my phonebook don't have the http://. I
noticed that in the new phonebook display gui, you can only successfully
click on properly formed urls with the http://.

When I read the phone book from the phone, should I add the http:// to
urls that are missing it? (I would only do it strings that could be
urls, name that match stuff1.stuff2[/morestuff] where stuff1 and stuff2
have not whitespace. Or should the phonebook display be modified to
work with urls without the http://?

Steve
Roger Binns
2003-11-12 21:07:53 UTC
Permalink
Post by Stephen Wood
I
noticed that in the new phonebook display gui, you can only successfully
click on properly formed urls with the http://.
That code is actually currently incomplete. I will be adding a click handler
that will actually invoke your main browser and feed it the URL doing
URL transmogrification as needed.

Roger
Bob Rosenberg
2003-11-23 19:03:56 UTC
Permalink
Roger (and the group)

Using a guide on another webpage, piecing together Python 2.3 for OS-X,
etc I got Bitpim 1.9 to work (sort-of). So here it goes:
1) Can you supply to me, or to the Bitpim site a bp.py that is the
latest version? (I cannot use the .rpm or the .exe, of course, but the
.py file seems to actually work (even though it seems targeted to the
WinTel environment!)
2) I already have a Qualcom driver loaded. It directly conflicts with
the python serial extensions (which have a BSD Un*x driver!) The
Qualcom driver shows up as tty.usbmodem191 or tty.usbmodem181 (191 for
USB port 2, 181 for USB port 1). This Qualcom driver allows OS-X to see
the phone as a modem. Is there something that I can do (as a
non-programmer) that can get you info that, knowing Bitpim, can assist
me in going further towards an OS-X solution? I'll be glad to publish
here and at http://videogamexchange.com/sites/lg4400/ (The OS-X
step-by-step site I mentioned)

* Caed Mille Failte (100,000 Welcomes) *
* Shalom! *
* 73 from W6HIM *
* Bob Rosenberg *
* San Juan Capistrano, CA. *
* mailto:rose-***@cox.net *
Roger Binns
2003-11-24 08:56:32 UTC
Permalink
Post by Bob Rosenberg
1) Can you supply to me, or to the Bitpim site a bp.py that is the
latest version? (I cannot use the .rpm or the .exe, of course, but the
.py file seems to actually work
bp.py has been unchanged since almost the begining. BitPim is actually
scattered across a rather large number of files, including code files,
images, help files etc

I recommend you work from CVS instead (details are on the developer
page).

The reason why there isn't a prepackaged Mac version is quite
simply because I don't have a Mac, and none of the Mac owners
have stepped forward to put the effort in to package it all
up. There are no technical or other reasons why it hasn't
been done.
Post by Bob Rosenberg
(even though it seems targeted to the WinTel environment!)
Not in the slightest. The only WinTel specific code deals with audio
format conversion and that is only because Qualcomm only releases
a binary for Windows.

All of the code is platform neutral although it does work around
various quirks on various platforms.

Actually I lied slightly. You need to do right clicks in the
filesystem view. I assume that works fine on multi-buttoned
Mac mice. I have no idea what you do if you have a single
button.
Post by Bob Rosenberg
2) I already have a Qualcom driver loaded. It directly conflicts with
the python serial extensions (which have a BSD Un*x driver!)
The Python serial extensions do not include a driver. They are merely
a convenient way to access the ports from BitPim code without having
to deal with platform specific issues. Things such as setting
timeouts are quite horrid to deal with on each platform.
Post by Bob Rosenberg
This Qualcom driver allows OS-X to see
the phone as a modem.
That isn't a Qualcomm driver. What you are seeing is that the
phone's USB interface is actually a composite interface with
two sub interfaces. One of them is a standard modem interface
and the Mac operating system (as well as Linux) have a default
driver interface for that.

The other interface is a bulk serial interface that you do need
special drivers for. To my knowledge those drivers are only
available on Windows. It is that interface (labelled "Diagnostic
Serial interface" on Windows drivers) which BitPim talks to.

The other alternative is to get a USB to serial interface, since
the serial interface in the phone combines access to the modem
interface and the diagnostics interface.
Post by Bob Rosenberg
Is there something that I can do (as a
non-programmer) that can get you info that, knowing Bitpim, can assist
me in going further towards an OS-X solution?
If you work from CVS I would like to know about any bugs or
other visual glitches.

Other than that, finding someone who has developer skills on a Mac
to make a bundled distribution. They need to know how to make Mac
packages which I believe is a tool called Bundle Builder. They
will also have to know all about Framework installs of libraries and
how to build the bundles off them.

Roger

Loading...