diff --git a/src/libprs500/devices/errors.py b/src/libprs500/devices/errors.py
index b81c8ab5e2..c22d95db23 100644
--- a/src/libprs500/devices/errors.py
+++ b/src/libprs500/devices/errors.py
@@ -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}
"""
diff --git a/src/libprs500/devices/prs500/cli/main.py b/src/libprs500/devices/prs500/cli/main.py
index 7c165ec980..638572dde2 100755
--- a/src/libprs500/devices/prs500/cli/main.py
+++ b/src/libprs500/devices/prs500/cli/main.py
@@ -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)
diff --git a/src/libprs500/devices/prs500/driver.py b/src/libprs500/devices/prs500/driver.py
index f5cadc7872..bf5b59f022 100755
--- a/src/libprs500/devices/prs500/driver.py
+++ b/src/libprs500/devices/prs500/driver.py
@@ -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):
diff --git a/src/libprs500/devices/prs505/driver.py b/src/libprs500/devices/prs505/driver.py
index 702bb9d3ca..01b65292ba 100644
--- a/src/libprs500/devices/prs505/driver.py
+++ b/src/libprs500/devices/prs505/driver.py
@@ -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):
%(main_memory)s
- %(deviceclass)s
+ %(deviceclass)s
@@ -76,13 +76,13 @@ class PRS505(Device):
%(storage_card)s
- %(deviceclass)s
+ %(deviceclass)s
-'''
+'''%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
diff --git a/src/libprs500/ebooks/lrf/pdf/reflow.py b/src/libprs500/ebooks/lrf/pdf/reflow.py
index 32fa16447f..d5535af029 100644
--- a/src/libprs500/ebooks/lrf/pdf/reflow.py
+++ b/src/libprs500/ebooks/lrf/pdf/reflow.py
@@ -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)