Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSascha Silbe <sascha-pgp@silbe.org>2015-08-20 11:36:48 (GMT)
committer Sascha Silbe <sascha-pgp@silbe.org>2015-08-20 11:36:48 (GMT)
commitd7b1e9ef47a0ea4ffa9e36005e3169fccc37eb21 (patch)
treed398ece53048426763180da2f2af37e2401b2351
parent11611772efa058bcf7aae715d2dbbe0b8cc51840 (diff)
Work around multi-page scan bug in python-sane 2.6.1
python-sane 2.6.1 doesn't correctly recognise the end of a multi-page scane in sane._SaneIterator and raises an exception instead of stopping the iteration. Detect end of scan (signalled by libsane via the 'error' message "Document feeder out of documents") ourselves and handle it properly.
-rw-r--r--scan.py15
1 files changed, 10 insertions, 5 deletions
diff --git a/scan.py b/scan.py
index cdd5cc8..9398f2f 100644
--- a/scan.py
+++ b/scan.py
@@ -515,12 +515,17 @@ class ScanThread(threading.Thread):
images = []
try:
self._dpi = self._device.resolution
- for image in scan_iter:
- images.append(self._process_image(image))
- if self._check_action(['stop', 'quit']):
- break
+ try:
+ for image in scan_iter:
+ images.append(self._process_image(image))
+ if self._check_action(['stop', 'quit']):
+ break
- self._dpi = self._device.resolution
+ self._dpi = self._device.resolution
+ except sane.error, exc:
+ # Work around python-sane bug.
+ if str(exc) != 'Document feeder out of documents':
+ raise
self._images = images