This commit is contained in:
Kovid Goyal 2008-03-11 08:13:24 +00:00
parent f86af16791
commit 6c7492b1ae
5 changed files with 17 additions and 17 deletions

View File

@ -13,7 +13,7 @@
## with this program; if not, write to the Free Software Foundation, Inc.,
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
"""
Defines the errors that the libprs500 device drivers generate.
Defines the errors that the device drivers generate.
G{classtree ProtocolError}
"""

View File

@ -21,7 +21,7 @@ For usage information run the script.
import StringIO, sys, time, os
from optparse import OptionParser
from libprs500 import __version__, iswindows
from libprs500 import __version__, iswindows, __appname__
from libprs500.devices.errors import PathError
from libprs500.terminfo import TerminalController
from libprs500.devices.errors import ArgumentError, DeviceError, DeviceLocked
@ -193,7 +193,7 @@ def main():
cols = 80
parser = OptionParser(usage="usage: %prog [options] command args\n\ncommand is one of: info, books, df, ls, cp, mkdir, touch, cat, rm\n\n"+
"For help on a particular command: %prog command", version="libprs500 version: " + __version__)
"For help on a particular command: %prog command", version=__appname__+" version: " + __version__)
parser.add_option("--log-packets", help="print out packet stream to stdout. "+\
"The numbers in the left column are byte offsets that allow the packet size to be read off easily.",
dest="log_packets", action="store_true", default=False)

View File

@ -58,9 +58,9 @@ from libprs500.devices.libusb import get_device_by_id
from libprs500.devices.prs500.prstypes import *
from libprs500.devices.errors import *
from libprs500.devices.prs500.books import BookList, fix_ids
from libprs500 import __author__
from libprs500 import __author__, __appname__
# Protocol versions libprs500 has been tested with
# Protocol versions this driver has been tested with
KNOWN_USB_PROTOCOL_VERSIONS = [0x3030303030303130L]
@ -111,7 +111,7 @@ class PRS500(Device):
# Height for thumbnails of books/images on the device
THUMBNAIL_HEIGHT = 68
# Directory on card to which books are copied
CARD_PATH_PREFIX = 'libprs500'
CARD_PATH_PREFIX = __appname__
_packet_number = 0 #: Keep track of the packet number for packet tracing
def log_packet(self, packet, header, stream=sys.stderr):

View File

@ -21,7 +21,7 @@ from itertools import cycle
from libprs500.devices.interface import Device
from libprs500.devices.errors import DeviceError, FreeSpaceError
from libprs500.devices.prs505.books import BookList, fix_ids
from libprs500 import iswindows, islinux, isosx
from libprs500 import iswindows, islinux, isosx, __appname__
from libprs500.devices.errors import PathError
class File(object):
@ -54,7 +54,7 @@ class PRS505(Device):
OSX_SD_NAME = 'Sony PRS-505/UC:SD Media'
OSX_MS_NAME = 'Sony PRS-505/UC:MS Media'
CARD_PATH_PREFIX = 'libprs500'
CARD_PATH_PREFIX = __appname__
FDI_TEMPLATE = \
'''
@ -64,7 +64,7 @@ class PRS505(Device):
<match key="@info.parent:@info.parent:@info.parent:@info.parent:usb.product_id" int="%(product_id)s">
<match key="volume.is_partition" bool="false">
<merge key="volume.label" type="string">%(main_memory)s</merge>
<merge key="libprs500.mainvolume" type="string">%(deviceclass)s</merge>
<merge key="%(app)s.mainvolume" type="string">%(deviceclass)s</merge>
</match>
</match>
</match>
@ -76,13 +76,13 @@ class PRS505(Device):
<match key="@info.parent:@info.parent:@info.parent:@info.parent:usb.product_id" int="%(product_id)s">
<match key="volume.is_partition" bool="true">
<merge key="volume.label" type="string">%(storage_card)s</merge>
<merge key="libprs500.cardvolume" type="string">%(deviceclass)s</merge>
<merge key="%(app)s.cardvolume" type="string">%(deviceclass)s</merge>
</match>
</match>
</match>
</match>
</device>
'''
'''%dict(app=__appname__)
def __init__(self, log_packets=False):
@ -139,7 +139,7 @@ class PRS505(Device):
def open_windows(self):
drives = []
import wmi
wmi = __import__('wmi', globals(), locals(), [], -1)
c = wmi.WMI()
for drive in c.Win32_DiskDrive():
if self.__class__.is_device(str(drive.PNPDeviceID)):
@ -181,7 +181,7 @@ class PRS505(Device):
return os.path.normpath('/media/'+label)+'/'
mm = hm.FindDeviceStringMatch('libprs500.mainvolume', self.__class__.__name__)
mm = hm.FindDeviceStringMatch(__appname__+'.mainvolume', self.__class__.__name__)
if not mm:
raise DeviceError('Unable to find %s. Is it connected?'%(self.__class__.__name__,))
self._main_prefix = None
@ -197,7 +197,7 @@ class PRS505(Device):
raise DeviceError('Could not open device for reading. Try a reboot.')
self._card_prefix = None
cards = hm.FindDeviceStringMatch('libprs500.cardvolume', self.__class__.__name__)
cards = hm.FindDeviceStringMatch(__appname__+'.cardvolume', self.__class__.__name__)
keys = []
for card in cards:
keys.append(int('UC_SD' in bus.get_object("org.freedesktop.Hal", card).GetPropertyString('info.parent', dbus_interface='org.freedesktop.Hal.Device')))
@ -261,7 +261,7 @@ class PRS505(Device):
def _windows_space(cls, prefix):
if prefix is None:
return 0, 0
import win32file
win32file = __import__('win32file', globals(), locals(), [], -1)
sectors_per_cluster, bytes_per_sector, free_clusters, total_clusters = \
win32file.GetDiskFreeSpace(prefix[:-1])
mult = sectors_per_cluster * bytes_per_sector

View File

@ -19,7 +19,7 @@ Convert PDF to a reflowable format using pdftoxml.exe as the PDF parsing backend
import sys, os, re, tempfile, subprocess, atexit, shutil, logging, xml.parsers.expat
from xml.etree.ElementTree import parse
from libprs500 import isosx, OptionParser, setup_cli_handlers
from libprs500 import isosx, OptionParser, setup_cli_handlers, __appname__
from libprs500.ebooks import ConversionError
PDFTOXML = 'pdftoxml.exe'
@ -364,7 +364,7 @@ class PDFConverter(object):
@classmethod
def generate_xml(cls, pathtopdf, logger):
pathtopdf = os.path.abspath(pathtopdf)
tdir = tempfile.mkdtemp('pdf2xml', 'libprs500')
tdir = tempfile.mkdtemp('pdf2xml', __appname__)
atexit.register(shutil.rmtree, tdir)
xmlfile = os.path.basename(pathtopdf)+'.xml'
os.chdir(tdir)