Scanning source - Invalid argument
When I try and scan, I am getting an error of"
mayan.apps.sources.models.scanner_sources <40> [ERROR] "get_upload_file_object() line 112 Exception while scanning from source:Scanner ; b'scanimage: open of device canon_dr failed: Invalid argument\n'"
I have had a look around, and I can see that in the file:
/opt/mayan-edms/lib/python3.7/site-packages/mayan/apps/sources/models/scanner_sources.py
There is this section:
class Meta:
verbose_name = _('SANE Scanner')
verbose_name_plural = _('SANE Scanners')
def clean_up_upload_file(self, upload_file_object):
pass
def get_upload_file_object(self, form_data):
temporary_file_object = TemporaryFile()
command_line = [
setting_scanimage_path.value, '-d', self.device_name,
'--format', 'tiff',
]
if self.resolution:
command_line.extend(
['--resolution', '{}'.format(self.resolution)]
)
if self.mode:
command_line.extend(
['--mode', self.mode]
)
if self.source:
command_line.extend(
['--source', self.source]
)
if self.adf_mode:
command_line.extend(
['--adf-mode', self.adf_mode]
)
filestderr = TemporaryFile()
try:
logger.debug('Scan command line: %s', command_line)
subprocess.check_call(
command_line, stdout=temporary_file_object, stderr=filestderr
)
except subprocess.CalledProcessError:
filestderr.seek(0)
error_message = filestderr.read()
logger.error(
'Exception while scanning from source:%s ; %s', self,
error_message
)
message = _('Error while scanning; %s') % error_message
self.logs.create(message=message)
raise SourceException(message)
else:
return SourceUploadedFile(
source=self, file=PseudoFile(
file=temporary_file_object, name='scan {}'.format(now())
)
)'
I noticed that this section builds the command for the "scanimage" ... but this section here:
if self.adf_mode:
command_line.extend(
['--adf-mode', self.adf_mode]
)
may be throwing it, as there is no --adf-mode in the scanimage command (unless it is scanner-dependent?).
I would like to turn on debugging to see what command is being sent to scanimage, but I don't seem to be able to switch on debug logging, following the procedure here: https://docs.mayan-edms.com/topics/development.html for some reason gives me LESS logging... not sure why, as the code appears to be there for debug reporting:
try:
logger.debug('Scan command line: %s', command_line)
subprocess.check_call(
command_line, stdout=temporary_file_object, stderr=filestderr
)
if I could see what is being sent to the CLI for scanning I may be able to sort this out.
I have tried commenting out the --adf-mode lines, but this doesn't seem to be helping.