Removed automatic dependency installation as it only works in Linux.

Removed dependency on PyXML.
Fixed unicode handling in books command of CLI
Various minor bug fixes to make things run smoothly in windows.
Version bump.
This commit is contained in:
Kovid Goyal 2007-01-09 03:23:30 +00:00
parent 9cad32e207
commit 7a814b5401
7 changed files with 24 additions and 34 deletions

View File

@ -25,7 +25,7 @@ try:
try: try:
import Image import Image
except ImportError: except ImportError:
if sys.platform not in ['win32', 'darwin']: if sys.platform.lower()[:5] not in ['win32', 'darwin']:
print "Trying to install the Python Imaging Library" print "Trying to install the Python Imaging Library"
easy_install(["-f", "http://www.pythonware.com/products/pil/", "Imaging"]) easy_install(["-f", "http://www.pythonware.com/products/pil/", "Imaging"])
else: else:
@ -48,10 +48,6 @@ if sys.hexversion < 0x2050000:
sys.exit(1) sys.exit(1)
install_requires=[]
if sys.platform not in ['win32', 'darwin']:
install_requires = ["pyusb>=0.3.5", "pyxml>=0.8.4"]
setup( setup(
name='libprs500', name='libprs500',
packages = find_packages('src'), packages = find_packages('src'),
@ -74,10 +70,6 @@ setup(
'gui_scripts' : [ 'prs500-gui = libprs500.gui.main:main'] 'gui_scripts' : [ 'prs500-gui = libprs500.gui.main:main']
}, },
zip_safe = True, zip_safe = True,
install_requires = install_requires,
dependency_links = ["http://sourceforge.net/project/showfiles.php?group_id=6473",
"http://easynews.dl.sourceforge.net/sourceforge/pyusb/pyusb-0.3.5.tar.gz",
],
description = description =
""" """
Library to interface with the Sony Portable Reader 500 Library to interface with the Sony Portable Reader 500

View File

@ -37,6 +37,6 @@ the following rule in C{/etc/udev/rules.d/90-local.rules} ::
You may have to adjust the GROUP and the location of the rules file to You may have to adjust the GROUP and the location of the rules file to
suit your distribution. suit your distribution.
""" """
__version__ = "0.3.0b5" __version__ = "0.3.0b6"
__docformat__ = "epytext" __docformat__ = "epytext"
__author__ = "Kovid Goyal <kovid@kovidgoyal.net>" __author__ = "Kovid Goyal <kovid@kovidgoyal.net>"

View File

@ -16,7 +16,6 @@
This module contains the logic for dealing with XML book lists found This module contains the logic for dealing with XML book lists found
in the reader cache. in the reader cache.
""" """
from xml.dom.ext import PrettyPrint
import xml.dom.minidom as dom import xml.dom.minidom as dom
from base64 import b64decode as decode from base64 import b64decode as decode
from base64 import b64encode as encode from base64 import b64encode as encode
@ -94,8 +93,8 @@ class Book(object):
self.prefix = prefix self.prefix = prefix
self.root = root self.root = root
def __repr__(self): def __repr__(self):
return self.title + " by " + self.author+ " at " + self.path return self.title + u" by " + self.author + u" at " + self.path
def __str__(self): def __str__(self):
return self.__repr__() return self.__repr__()
@ -208,4 +207,4 @@ class BookList(list):
def write(self, stream): def write(self, stream):
""" Write XML representation of DOM tree to C{stream} """ """ Write XML representation of DOM tree to C{stream} """
PrettyPrint(self.document, stream) stream.write(self.document.toxml('utf-8'))

View File

@ -207,7 +207,8 @@ def main():
str(0 if total[i]==0 else int(100*(total[i]-free[i])/(total[i]*1.)))+"%") str(0 if total[i]==0 else int(100*(total[i]-free[i])/(total[i]*1.)))+"%")
elif command == "books": elif command == "books":
print "Books in main memory:" print "Books in main memory:"
for book in dev.books(): print book for book in dev.books():
print unicode(book)
print "\nBooks on storage card:" print "\nBooks on storage card:"
for book in dev.books(oncard=True): print book for book in dev.books(oncard=True): print book
elif command == "mkdir": elif command == "mkdir":

View File

@ -480,9 +480,9 @@ class PRS500Device(Device):
command_number=FileIO.RNUMBER, packet_size=4096) command_number=FileIO.RNUMBER, packet_size=4096)
try: try:
# The first 16 bytes are meta information on the packet stream # The first 16 bytes are meta information on the packet stream
array('B', packets[0][16:]).tofile(outfile) outfile.write("".join(map(chr, packets[0][16:])))
for i in range(1, len(packets)): for i in range(1, len(packets)):
array('B', packets[i]).tofile(outfile) outfile.write("".join(map(chr, packets[i])))
except IOError, err: except IOError, err:
self.send_validated_command(FileClose(_id)) self.send_validated_command(FileClose(_id))
raise ArgumentError("File get operation failed. " + \ raise ArgumentError("File get operation failed. " + \

View File

@ -522,6 +522,8 @@ class Main(QObject, Ui_MainWindow):
except DeviceBusy, err: except DeviceBusy, err:
Error("Device is in use by another application", None) Error("Device is in use by another application", None)
self.status("Device busy") self.status("Device busy")
self.window.setCursor(Qt.ArrowCursor)
return
except DeviceError, err: except DeviceError, err:
self.dev.reconnect() self.dev.reconnect()
self.thread().msleep(100) self.thread().msleep(100)
@ -550,26 +552,17 @@ class Main(QObject, Ui_MainWindow):
sc = space[1] if int(space[1])>0 else space[2] sc = space[1] if int(space[1])>0 else space[2]
self.device_tree.model().update_free_space(space[0], sc) self.device_tree.model().update_free_space(space[0], sc)
class LockFile(object):
def __init__(self, path):
self.path = path
f = open(path, "w")
f.close()
def __del__(self):
if os.access(self.path, os.F_OK): os.remove(self.path)
class DeviceConnectDetector(QObject): class DeviceConnectDetector(QObject):
def timerEvent(self, e): def timerEvent(self, e):
if e.timerId() == self.device_detector: if e.timerId() == self.device_detector:
is_connected = self.dev.is_connected() is_connected = self.dev.is_connected()
if is_connected and not self.is_connected: if is_connected and not self.is_connected:
self.emit(SIGNAL("device_connected()"))
self.is_connected = True self.is_connected = True
self.emit(SIGNAL("device_connected()"))
elif not is_connected and self.is_connected: elif not is_connected and self.is_connected:
self.emit(SIGNAL("device_removed()"))
self.is_connected = False self.is_connected = False
self.emit(SIGNAL("device_removed()"))
def udi_is_device(self, udi): def udi_is_device(self, udi):
ans = False ans = False
@ -638,7 +631,6 @@ def main():
QCoreApplication.setOrganizationName("KovidsBrain") QCoreApplication.setOrganizationName("KovidsBrain")
QCoreApplication.setApplicationName(APP_TITLE) QCoreApplication.setApplicationName(APP_TITLE)
Main(window, options.log_packets) Main(window, options.log_packets)
lock = LockFile(lock)
return app.exec_() return app.exec_()
if __name__ == "__main__": if __name__ == "__main__":

View File

@ -53,7 +53,7 @@
<property name="maximumSize" > <property name="maximumSize" >
<size> <size>
<width>10000</width> <width>10000</width>
<height>95</height> <height>90</height>
</size> </size>
</property> </property>
<property name="verticalScrollBarPolicy" > <property name="verticalScrollBarPolicy" >
@ -81,11 +81,17 @@
<property name="sizePolicy" > <property name="sizePolicy" >
<sizepolicy> <sizepolicy>
<hsizetype>5</hsizetype> <hsizetype>5</hsizetype>
<vsizetype>0</vsizetype> <vsizetype>5</vsizetype>
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="maximumSize" >
<size>
<width>16777215</width>
<height>90</height>
</size>
</property>
<property name="text" > <property name="text" >
<string>For help visit &lt;a href="https://libprs500.kovidgoyal.net/wiki/GuiUsage">http://libprs500.kovidgoyal.net&lt;/a>&lt;br>&lt;br>&lt;b>libprs500&lt;/b> was created by &lt;b>Kovid Goyal&lt;/b> &amp;copy; 2006&lt;br>%1 %2 %3</string> <string>For help visit &lt;a href="https://libprs500.kovidgoyal.net/wiki/GuiUsage">http://libprs500.kovidgoyal.net&lt;/a>&lt;br>&lt;br>&lt;b>libprs500&lt;/b> was created by &lt;b>Kovid Goyal&lt;/b> &amp;copy; 2006&lt;br>%1 %2 %3</string>
</property> </property>
@ -281,8 +287,8 @@
<widget class="QToolBar" name="tool_bar" > <widget class="QToolBar" name="tool_bar" >
<property name="minimumSize" > <property name="minimumSize" >
<size> <size>
<width>163</width> <width>124</width>
<height>58</height> <height>50</height>
</size> </size>
</property> </property>
<property name="movable" > <property name="movable" >