Shiny New E-Book Gizmo: The Amazon Kindle


View Full Version : libprs500 on openSuse 10.3?


mauibay
12-15-2007, 02:55 PM
Aloha,

Where is an appropriate place to ask for help to install libprs500 on linux? I installed prerequisites, and the easy-install process completes, but the postinstall script fails as does running the installed commands:

# easy_install-2.5 -U TTFQuery libprs500
Searching for TTFQuery
Reading http://cheeseshop.python.org/pypi/TTFQuery/
Reading http://members.rogers.com/mcfletch/
Reading https://sourceforge.net/project/showfiles.php?group_id=84080
Reading http://cheeseshop.python.org/pypi/TTFQuery/1.0.0
Best match: TTFQuery 1.0.0
Downloading http://downloads.sourceforge.net/ttfquery/TTFQuery-1.0.0.zip?modtime=1079827200&big_mirror=0
Processing TTFQuery-1.0.0.zip
Running TTFQuery-1.0.0/setup.py -q bdist_egg --dist-dir /tmp/easy_install-76AaPS/TTFQuery-1.0.0/egg-dist-tmp-r2u_V-
warning: no previously-included files matching '*CVS*' found anywhere in distribution
warning: no previously-included files matching '*Cvs*' found anywhere in distribution
warning: no previously-included files matching '*.pyc' found anywhere in distribution
warning: no previously-included files matching '*.pyo' found anywhere in distribution
warning: no previously-included files matching '*.ttf' found anywhere in distribution
warning: no previously-included files matching '*.cache' found anywhere in distribution
warning: no previously-included files matching '*.bat' found anywhere in distribution
zip_safe flag not set; analyzing archive contents...
ttfquery._scriptregistry: module references __file__
Adding TTFQuery 1.0.0 to easy-install.pth file

Installed /usr/local/lib64/python2.5/site-packages/TTFQuery-1.0.0-py2.5.egg
Processing dependencies for TTFQuery
Finished processing dependencies for TTFQuery
Searching for libprs500
Reading http://cheeseshop.python.org/pypi/libprs500/
Reading http://libprs500.kovidgoyal.net
Reading http://cheeseshop.python.org/pypi/libprs500/0.4.30
Best match: libprs500 0.4.30
Downloading http://pypi.python.org/packages/2.5/l/libprs500/libprs500-0.4.30-py2.5.egg#md5=3bef7a4eb26f470d308cecad930dcf45
Processing libprs500-0.4.30-py2.5.egg
Moving libprs500-0.4.30-py2.5.egg to /usr/local/lib64/python2.5/site-packages
Adding libprs500 0.4.30 to easy-install.pth file
Installing lrf-meta script to /usr/local/bin
Installing lit-meta script to /usr/local/bin
Installing pdf-meta script to /usr/local/bin
Installing rtf-meta script to /usr/local/bin
Installing web2lrf script to /usr/local/bin
Installing isbndb script to /usr/local/bin
Installing any2lrf script to /usr/local/bin
Installing pdf2lrf script to /usr/local/bin
Installing lrf2lrs script to /usr/local/bin
Installing web2disk script to /usr/local/bin
Installing html2lrf script to /usr/local/bin
Installing markdown-libprs500 script to /usr/local/bin
Installing libprs500_postinstall script to /usr/local/bin
Installing prs500 script to /usr/local/bin
Installing txt2lrf script to /usr/local/bin
Installing lit2lrf script to /usr/local/bin
Installing rtf2lrf script to /usr/local/bin
Installing lrfviewer script to /usr/local/bin
Installing libprs500 script to /usr/local/bin

Installed /usr/local/lib64/python2.5/site-packages/libprs500-0.4.30-py2.5.egg
Processing dependencies for libprs500
Finished processing dependencies for libprs500

# libprs500_postinstall
Traceback (most recent call last):
File "/usr/local/bin/libprs500_postinstall", line 8, in <module>
load_entry_point('libprs500==0.4.30', 'console_scripts', 'libprs500_postinstall')()
File "/usr/lib64/python2.5/site-packages/pkg_resources.py", line 277, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/lib64/python2.5/site-packages/pkg_resources.py", line 2179, in load_entry_point
return ep.load()
File "/usr/lib64/python2.5/site-packages/pkg_resources.py", line 1912, in load
entry = __import__(self.module_name, globals(),globals(), ['__name__'])
File "build/bdist.linux-i686/egg/libprs500/linux.py", line 24, in <module>
File "/usr/lib64/python2.5/site-packages/PIL/__init__.py", line 20, in devices

File "build/bdist.linux-i686/egg/libprs500/devices/prs500/driver.py", line 56, in <module>
File "build/bdist.linux-i686/egg/libprs500/devices/libusb.py", line 19, in <module>
File "/usr/lib64/python2.5/site-packages/ctypes/__init__.py", line 20, in <module>
raise Exception, ("Version number mismatch", __version__, _ctypes_version)
Exception: ('Version number mismatch', '1.0.1', '1.0.2')


I'm very familiar with linux in general, but not so much with python setuptools. It appears that there's a problem with the ctypes version, but I'm not sure which version is which or what should be done to correct it.

Running any of the installed commands results in the same error:

# libprs500
Traceback (most recent call last):
File "/usr/local/bin/any2lrf", line 8, in <module>
load_entry_point('libprs500==0.4.30', 'console_scripts', 'any2lrf')()
File "/usr/lib64/python2.5/site-packages/pkg_resources.py", line 277, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/lib64/python2.5/site-packages/pkg_resources.py", line 2179, in load_entry_point
return ep.load()
File "/usr/lib64/python2.5/site-packages/pkg_resources.py", line 1912, in load
entry = __import__(self.module_name, globals(),globals(), ['__name__'])
File "build/bdist.linux-i686/egg/libprs500/ebooks/lrf/any/convert_from.py", line 24, in <module>
File "build/bdist.linux-i686/egg/libprs500/ebooks/lrf/rtf/convert_from.py", line 22, in <module>
File "build/bdist.linux-i686/egg/libprs500/libwand.py", line 15, in <module>
File "/usr/lib64/python2.5/site-packages/ctypes/__init__.py", line 20, in <module>
raise Exception, ("Version number mismatch", __version__, _ctypes_version)
Exception: ('Version number mismatch', '1.0.1', '1.0.2')

Any helpful advice or a link to an appropriate forum/list would be very welcome!

mauibay
12-15-2007, 04:00 PM
Sorry to respond to myself, but I did get past this problem by using easy-install to update python-ctypes. I wanted to post in case anybody else bumps into the same issue since openSuse doesn't have ctypes 1.0.2 in any repositories, the most recent is 1.0.1.

So, I apparently have libprs500 working now, although have not had any luck with NYT Fetch News script, the hourglass has been spinning for about half an hour now.

I'm impressed with the features and polish so far! I'm hoping that entering the same tags for multiple files will create a collection on the prs505, or that there is some method for grouping books into collections that I haven't found yet.

Thanks!

kovidgoyal
12-15-2007, 04:10 PM
Yeah entering tags creates collections on the device.

mauibay
12-15-2007, 10:41 PM
ok, I'm stumped how to make collections. I'm sure I must be missing something obvious.

I'm editing the metadata for the books in libprs500, and setting the 'Tags' field to the author's name. All the other metadata is populated from the ISBNdb lookup. I select all the books and click the 'Save to disk' button and save to my SD card. What I want to test is for a collection to appear containing all the books by the same author.

When I insert the SD card in my prs505, the books appear in the title and author lists, but the number of collections is still zero. Also, the books are sorted in the title and author lists based on the actual filename, not the metadata, so many are not in the correct places. I didn't expect that. but can easily fix it by adopting an appropriate filename scheme.

But what's the trick to get the prs505 to generate the collections from the tags I enter in libprs500? I'd really like to not have to enter the xml playlist info in the cache file on the SD card by hand, it would be great if there is some way to generate it from libprs500 or get the prs505 to generate it automatically from the tags.

What am I misunderstanding?

Thanks!

kovidgoyal
12-16-2007, 12:48 AM
You have to use send to device if you want metadata to be transferred. Click the arrow next to the send to device button to choose the card as the destination.

mauibay
12-16-2007, 02:12 AM
Sorry, I didn't realize saving to the card was different than saving to the device. I was thinking that I would only need to save directly to the device if I wasn't using a card or wanted to save to internal memory.

Well I guess I need to figure out why I can't send to the device then. That button is disabled, so I can't choose a destination. On my system libprs500 doesn't see my prs505, these are the errors when it starts up:

Unable to open device
Traceback (most recent call last):
File "build/bdist.linux-i686/egg/libprs500/gui2/device.py", line 52, in run
File "build/bdist.linux-i686/egg/libprs500/devices/prs505/driver.py", line 219, in open
File "build/bdist.linux-i686/egg/libprs500/devices/prs505/driver.py", line 188, in open_linux
DeviceError: Unable to find PRS505. Is it connected?

I have a 512MB memory stick and a 2GB SD card inserted in the device. The device is plugged in and visible with lsusb, and both cards are detected and automounted by KDE:

# lsusb
Bus 002 Device 008: ID 054c:031e Sony Corp.

#df -h
/dev/sdi1 469M 96K 469M 1% /media/disk
/dev/sdj1 1.9G 35M 1.9G 2% /media/disk-1

So, as far as I can tell, the device is connected and operating normally. I can drag/drop files to it and read the contents of the mounted cards just fine.

Perhaps there is a library or dependency that I'm missing?

kovidgoyal
12-16-2007, 02:18 AM
Run libprs500_postinstall as root

mauibay
12-16-2007, 02:58 AM
Bingo! That did the trick. Obviously I either forgot to run it or something went wrong the first time after I fixed the ctypes version issue.

Thanks for all your quick responses, you've done a great job with this software! I just made a donation to your paypal account. I appreciate your help!

kovidgoyal
12-16-2007, 03:34 AM
Thanks :)

mauibay
12-16-2007, 03:07 PM
I did let the NY Times script run for over an hour and it finally completed. Wow. Nice results, but that's a long time. :) It would be really nice to be able to have a command line method to run these scripts so they could be fired off from a cron job.

I have also successfully converted PDF and RTF files to LRF, but every TXT file I've tried so far has frozen the app and I've had to kill the process to close it. It still says 'Jobs: 0" when it hangs and the window goes unresponsive. I didn't expect that, I thought TXT would be the easiest to convert from. Perhaps TXT files need a specific encoding?

kovidgoyal
12-16-2007, 04:05 PM
web2lrf --help


Try running txt2lrf on the TXT files with the --verbose switch.

mauibay
12-16-2007, 04:40 PM
> txt2lrf --verbose Bear\,\ Greg\ -\ SLANT.txt
[INFO] convert_from.py:60: Converting text to HTML...

It doesn't seem to generate any files and doesn't exit. It shows as using 100% cpu in top. I've let it run up to 20 minutes before killing it manually.

Am I just not waiting long enough? RTF and PDF only take a few seconds to convert, I can't imagine TXT taking more than 20 minutes!

kovidgoyal
12-16-2007, 07:06 PM
Hmm looks like a python-markdown issue. Open a ticket and attach the txt file.

mauibay
12-16-2007, 07:23 PM
Added ticket 392. My workaround is to simply convert text files to RTF or HTML with oowriter before adding to the libprs500 library, so no worries here.

The web2lrf feature is outstanding btw, thanks!

mauibay
12-16-2007, 07:53 PM
oops. I don't think I changed anything, but RTF conversions aren't working now either, only HTML:

Detailed traceback:
Traceback (most recent call last):
File "build/bdist.linux-i686/egg/libprs500/gui2/jobs.py", line 97, in run
File "build/bdist.linux-i686/egg/libprs500/ebooks/lrf/any/convert_from.py", line 140, in main
File "build/bdist.linux-i686/egg/libprs500/ebooks/lrf/any/convert_from.py", line 117, in process_file
File "build/bdist.linux-i686/egg/libprs500/ebooks/lrf/rtf/convert_from.py", line 85, in process_file
File "build/bdist.linux-i686/egg/libprs500/ebooks/lrf/rtf/convert_from.py", line 178, in generate_html2
File "build/bdist.linux-i686/egg/libprs500/ebooks/lrf/rtf/convert_from.py", line 125, in generate_xml
ImportError: No module named rtf2xml.ParseRtf
Log:
[INFO] convert_from.py:177: Converting RTF to XML...

I suspect there's something missing from openSuse's python packages, or something else weird.

mauibay
12-16-2007, 09:21 PM
ok, now I'm all screwed up again. I restarted my machine and now it doesn't talk to the prs505 anymore. It gets the same error as I had originally:

Unable to open device
Traceback (most recent call last):
File "build/bdist.linux-i686/egg/libprs500/gui2/device.py", line 52, in run
File "build/bdist.linux-i686/egg/libprs500/devices/prs505/driver.py", line 219, in open
File "build/bdist.linux-i686/egg/libprs500/devices/prs505/driver.py", line 188, in open_linux
DeviceError: Unable to find PRS505. Is it connected?

If I run libprs500_postinstall again, it has the same output as before, except it doesn't fix the problem:

# libprs500_postinstall
Trying to setup udev rules...
Shutting down HAL daemon done
Starting HAL daemon done
Loading CPUFreq modules done
Setting up bash completion... done
Setting up desktop integration...

So. I don't understand the process well enough to have a clue why it's not working now.

mauibay
12-17-2007, 11:57 AM
ok, found some more info by tailing /var/log/messages while connecting/disconnecting my prs505. The internal memory does not always get mounted when I connect the device. The two card slots always do, but for some reason it usually doesn't detect the internal partition.

On my system the prs505 mass storage devices are assigned to /dev/sdh/ dev/sdi and /dev/sdj. sdh is internal memory, sdi is the memory stick and sdj is the SD card. If the cards are inserted, linux sees /dev/sdi1 and /dev/sdj1 as appropriate every time. However, regardless of whether or not the cards are there, it usually does not see /dev/sdh1. When I look at the partition map for /dev/sdh with fdisk, when sdh1 is not detected it's empty and when detected it has a single FAT16 partition. So, it seems the problem is that most of the time there is something causing the internal memory's drive partition from been seen.

What I've noticed is that every time I connect the device and /dev/sdh1 is not detected and mounted, libprs500 fails to see the device. When /dev/sdh1 does get detected and mounted, libprs500 detects the device and I can send to it normally.

I've found there is a timing correlation that affects whether or not /dev/sdh1 appears when I connect the device. I haven't yet found a 100% reliable way to reproduce it, but I have found that if I don't wait for the device display to finish indicating it's done updating after unplugging the USB cable before plugging it in again it will get detected correctly. For example, it takes several seconds after unplugging the cable for the device screen to stop flashing and displaying the rotating sync icon. If I plug the cable back in sometime during this time, I'm now able to somewhat reliably have the device detected properly by libprs500.

I don't know if this problem is something unique to my system or device, or if this is just some quirk due to some difference between the prs500 and prs505 that hasn't been identified yet. I did notice that libprs500 apparently only recognizes one of the card slots when it does work, and that it doesn't always see the same slot. (It usually sees the memory stick, but sometimes sees the SD card, never both. Only one icon and 'send to' choice is offered.)

I can paste this into a ticket if desired, I just hope the info is helpful.

kovidgoyal
12-17-2007, 07:14 PM
the prs500 uses a custom USB protocol. The 505 exports itself as a mass storage device. libprs500 will only see the 505 if the OS first sees it and mounts it. Also libprs500 supports only one extension card at a time. That's a feature ;)

mauibay
12-17-2007, 09:55 PM
the prs500 uses a custom USB protocol. The 505 exports itself as a mass storage device.
I have discovered a way to reliably get my 505 to mount and be detected by libprs500 by plugging in the usb cable at a particular time during an onscreen update. If I plug the cable in at any other time such as when the device is idle, it does not connect. I'll keep looking into this, it might be an issue with openSuse or KDE's automount process.
libprs500 will only see the 505 if the OS first sees it and mounts it. Also libprs500 supports only one extension card at a time. That's a feature ;)
Interesting. ;) Is there any way (other than removing a card) to influence which extension card it decides to support? Right now it's somewhat random. It seems about 30% of the time it chooses my SD card, and the rest of the it's the MS card. It's a bit silly to have to disconnect/reconnect a few times until it gets the card I want, especially with connections issues I'm having. ;)

kovidgoyal
12-18-2007, 10:14 AM
That would require playing around with the driver code. Unfortunately, I don't have a memory stick so I can't do that.

mauibay
12-18-2007, 12:49 PM
If you are interested at all in looking at the issue I'd be happy to send you one.:cool:

kovidgoyal
12-18-2007, 03:23 PM
Sure, it shouldn't take more than 10mins of work.

mauibay
12-18-2007, 10:52 PM
No problem. Just send me a forum private message with an address to send it to and I'll stick a stick in the mail. :)

mauibay
01-12-2008, 04:25 PM
I've been using libprs500 pretty well for the past few weeks and other than the randomness of which memory card it chooses (It would be great if both memory cards could be selectable,) I've found another simple suggestion to make...

When converting a book, there is a checkbox to use the cover image from metadata. Since there is a big button on the toolbar to edit metadata which includes setting an image for the book cover, I assumed that the conversion checkbox (which is checked by default) meant to use that metadata image set in the libprs500 library. When I converted several books from lit to lrf it used the lit image instead. That's when I discovered that the checkbox means to select the image in the book file metadata, not the library metadata. So my suggestion is to change the checkbox label to make it obvious which image is to be used. Because the user may be selecting between two different metadata images, I think it's likely that people will make the same incorrect assumption that I did that the metadata to be used is the one set in the library.

btw, I hope you got the memory stick I sent ok. :)

kovidgoyal
01-12-2008, 04:29 PM
Ah you were the one that sent me the card (I'd forgotten what it was for). Could you open a ticket for both these issues and I'll look at them asap.

mauibay
01-12-2008, 07:21 PM
OK, tickets 463 and 464 opened. Thanks!