Closed twinklebob closed 8 years ago
The relevant piece of code is
def next(self):
try:
self.device.start()
except Exception as e:
if str(e) == 'Document feeder out of documents':
raise StopIteration
else:
raise
The first thing to try would be whether an exception is raised at all, and possibly just with a different message (i.e. other than Document feeder out of documents
).
It doesn't seem to raise an exception at all, at least not one that Python picks up. As I say, Python isn't my primary language, does raise
rethrow the earlier exception, or would I need to explicitly rethrow it?
Did a quick and dirty, added print str(e)
as the first line in the except
block and it's not hitting that at all, so apparently no exception being thrown by SANE.
It's a pretty old scanner, it has to be said, but if anything I'd expect it to complain quite loudly! :-)
Here's the output from scan-image if I put no documents in the feeder
scanimage --mode Color --resolution 150 --depth 8 -x 210 -y 297 --source ADF --batch --format=pnm
scanimage: rounded value of br-y from 297 to 296.888
Scanning -1 pages, incrementing by 1, numbering from 1
Scanning page 1
scanimage: sane_start: Document feeder out of documents
Could it be because I haven't expressly set the source to be the ADF?
It was!
dev.source = "ADF"
Was all it needed. Any chance you could add an example of using the multi_scan()
to the documentation, because I'm doing a lot of guessing here.
Sorry for wasting your time! :smile:
Hmm I actually never tested with an ADF scanner (don't even have access to one), so I wonder if all devices require this or if it is device dependent. If all devices require it, one could set the option directly in multi_scan
(and the set the option to the corresponding value for non-ADF mode when doing scan
or snap
). But as I said, I have no idea whether source=ADF
is in any way a standard requirement.
Well, for the record, is was definitely needed with my ancient HP. It looks like once the feeder was empty it just used the standard bed. I should've guessed by the content of the image, really, as it had scanned the entire bad, not just the section where it normally reads the ADF documents. I'd guess that most combination scanners will do the same, use the document feeder if populated or just assume that you're doing a flatbed scan otherwise, but I have no way of knowing.
I also have HP Flatbed with ADF. I tried batch scans using dev.source = ADF as and
for i, pageim in enumerate(dev.multi_scan()): pageim.save('test ' + str(i) + '.png')
It doesn't seems to exit when I am scanning more than 3 pages at a row. Is there anything I am missinghere?
Do let me know. Thanks in Advance
python-sane doesn't detect my device every time
1st it detects and scans normally but after the first scan it doesn't detect any device
I've got an HP flatbed with an ADF attached.
Using SANE directly I can run batch scans and it will correctly quit after the last page is scanned. However the python-sane library (v2.8.2 installed with PIP) doesn't seem to exit.
A quick scan through the code looks like it uses an exception to tell the iterator to stop, any ideas why that might not be thrown by the SANE backend?
I'm a novice Python developer, so I'm probably doing it wrong, but I've tried:
and
But to be honest even a single scan will continue if there is no paper:
Let me know what you need from me to debug this.