diff options
author | Sascha 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) |
commit | d7b1e9ef47a0ea4ffa9e36005e3169fccc37eb21 (patch) | |
tree | d398ece53048426763180da2f2af37e2401b2351 | |
parent | 11611772efa058bcf7aae715d2dbbe0b8cc51840 (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.py | 15 |
1 files changed, 10 insertions, 5 deletions
@@ -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 |