Skip to content
This repository has been archived by the owner on Dec 18, 2019. It is now read-only.

"resolution" option misnamed on Lexmark MFP (CX510de) #533

Closed
tiramiseb opened this issue Nov 24, 2016 · 27 comments
Closed

"resolution" option misnamed on Lexmark MFP (CX510de) #533

tiramiseb opened this issue Nov 24, 2016 · 27 comments

Comments

@tiramiseb
Copy link
Collaborator

With my new multifunction printer (Lexmark CX510de), scanner calibration doesn't work, the following error is displayed:

Erreur lors du scan: Error while scanning: 'resolution'

Traceback in the terminal is:

ERROR  paperwork.frontend.util.jobs   ===> Job CalibrationScan:0 raised an exception: <class 'KeyError'>: 'resolution'
ERROR  paperwork.frontend.util.jobs    0: /usr/local/lib/python3.5/dist-packages/paperwork/frontend/util/jobs.py: L  180: _run
ERROR  paperwork.frontend.util.jobs    1: /usr/local/lib/python3.5/dist-packages/paperwork/frontend/settingswindow/__init__.py: L  361: do
ERROR  paperwork.frontend.util.jobs    2: /usr/local/lib/python3.5/dist-packages/paperwork/frontend/settingswindow/__init__.py: L  398: _do
ERROR  paperwork.frontend.util.jobs    3: /usr/local/lib/python3.5/dist-packages/pyinsane2/__init__.py: L   51: set_scanner_opt
ERROR  paperwork.frontend.util.jobs   ---> Job CalibrationScan:0 was started by:
ERROR  paperwork.frontend.util.jobs    0: /usr/local/bin/paperwork: L    6: <module>
ERROR  paperwork.frontend.util.jobs    1: /usr/local/lib/python3.5/dist-packages/paperwork/paperwork.py: L  153: main
ERROR  paperwork.frontend.util.jobs    2: /usr/local/lib/python3.5/dist-packages/paperwork/frontend/util/actions.py: L   67: on_button_clicked_cb
ERROR  paperwork.frontend.util.jobs    3: /usr/local/lib/python3.5/dist-packages/paperwork/frontend/util/actions.py: L   64: __do
ERROR  paperwork.frontend.util.jobs    4: /usr/local/lib/python3.5/dist-packages/paperwork/frontend/settingswindow/__init__.py: L  640: do
ERROR  paperwork.frontend.util.jobs    5: /usr/local/lib/python3.5/dist-packages/paperwork/frontend/util/jobs.py: L  249: schedule
@tiramiseb
Copy link
Collaborator Author

This errors occurs when using the printer over the network AND with usb.

@jflesch
Copy link
Member

jflesch commented Nov 24, 2016

.. it seems your scanner doesn't provide the option 'resolution' .. which is a problem ...

Let's check. Can you turn your scanner on, start Paperwork, and then open the diagnostic window please ? (this window is in the application menu --> "advanced"). It's going to collect various informations: logs, various statistics, sys info, and scanner infos (the last one being what I'm looking for).
Then can you send me the output of this dialog (either on this ticket or by email), please ?

@tiramiseb
Copy link
Collaborator Author

tiramiseb commented Nov 24, 2016

Ouch. In french it is "diagnostic", not "diagnostique" ! (the latter is accepted but really ugly)

(it is running right now, I will provide data here in a few minutes)

@tiramiseb
Copy link
Collaborator Author

tiramiseb commented Nov 24, 2016

Here is the diag result...

The printer is currently usable with network and USB, both are configured. So it can be seen twice in the diag.

diag_paperwork.txt

@tiramiseb
Copy link
Collaborator Author

There seems to be a scan-resolution option...

@tiramiseb
Copy link
Collaborator Author

tiramiseb commented Nov 24, 2016

I have changed line 398 of paperwork/frontend/settingswindow/__init__.py to:

            pyinsane2.set_scanner_opt(dev, 'scan-resolution', [resolution])

... and it works as expected.

Maybe you could loop on multiple values, "resolution" and "scan-resolution", when trying to set the resolution.

By the way, I think targetting the correct option would rather be pyinsane2's job.
paperwork would use a methode like pyinsane2.set_resolution([resolution]) or pyinsane2.set_resolution(resolution)...

@jflesch
Copy link
Member

jflesch commented Nov 24, 2016

In french it is "diagnostic", not "diagnostique" !

Ah oui mince, c'est subtile... :/ ( http://www.projet-voltaire.fr/blog/regle-orthographe/%C2%AB-diagnostic-%C2%BB-ou-%C2%AB-diagnostique-%C2%BB )

@jflesch
Copy link
Member

jflesch commented Nov 24, 2016

72f3b8b (pour "diagnostic")

@jflesch
Copy link
Member

jflesch commented Nov 24, 2016

"scan-resolution" ...... great, someone wrote a full driver without reading the documentation first ...
I'm going to add a workaround in Pyinsane later today.

@tiramiseb
Copy link
Collaborator Author

Maybe devs at Lexmark don't have enough time to RTFM :D

@tiramiseb
Copy link
Collaborator Author

tiramiseb commented Nov 24, 2016

By the way, have you seen the "source" option for the network scanner ? It's f***ing awesome!

INFO   paperwork.frontend.diag        Option: source
INFO   paperwork.frontend.diag          Title: Scan source
INFO   paperwork.frontend.diag          Desc: Indicates the number of pages to be scanned.

(related to #534)

@jflesch
Copy link
Member

jflesch commented Nov 24, 2016

Basically, since Pyinsane2, I'm trying to put all the workarounds for the scanners as much as possible in Pyinsane itself.
So here, what's I'm going to do in Pyinsane:
If there is an option 'scan-resolution', I'm going to add a fake option 'resolution' actually pointing to and reading from 'scan-resolution'

@jflesch
Copy link
Member

jflesch commented Nov 24, 2016

Hm, not sure I'm supposed to see with the option 'source' ? It's what it should be (I have pretty much the same thing on my HP scanner, just I got "ADF" instead of "Automatic Document Feeder")

@tiramiseb
Copy link
Collaborator Author

Okay for what you'll be doing for scan-resolution in Pyinsane.

Regarding the "source" option, it's what it should be in the USB scanner (first occurrence) but not in the network scanner (second occurrence).

(both are detailed in the diag file)

@tiramiseb
Copy link
Collaborator Author

(regarding the source option, this discussion must continue in #534)

@tiramiseb
Copy link
Collaborator Author

Probably related...

As said before, I have changed pyinsane2.set_scanner_opt(dev, 'resolution', [resolution]) to pyinsane2.set_scanner_opt(dev, 'scan-resolution', [resolution]) for both occurrences I have seen this function call.

  • when calibrating, it displays the "real" scanner zone and I can correctly select the part I want
  • at the moment the scan is running, the zone is correcly displayed too
  • after scanning, when doing the OCR, it looks like the scan resolution is always 200dpi and the zone taken into account depends on the wanted resolution. If I want 75dpi, it works on an area smaller than the page itself. If I want 300dpi, it works on an area much larger than the page itself.

See attached screencasts: paperwork_resolution_problem_videos.zip

@jflesch, if it does not seem related to you, I'll create a new issue...

@tiramiseb tiramiseb changed the title Calibration error "resolution" option misnamed on Lexmark MFP (CX510de) Nov 24, 2016
@jflesch
Copy link
Member

jflesch commented Nov 24, 2016

I'm going to check on mine. I hope it isn't a bug I introduced in 1.0.5 while trying to make some crappy Windows scanners work :/

@jflesch
Copy link
Member

jflesch commented Nov 24, 2016

Does it it only happen on multi-scan, or single scans too ?

@tiramiseb
Copy link
Collaborator Author

It happens constantly. Single scan, multi scan, USB, network...

@jflesch
Copy link
Member

jflesch commented Nov 24, 2016

Ok, first I'm going to do a clean patch in Pyinsane, and then we will see if you still have the issue

@tiramiseb
Copy link
Collaborator Author

That's perfect

@jflesch jflesch removed the to study label Nov 24, 2016
@jflesch
Copy link
Member

jflesch commented Nov 24, 2016

The workaround has been implemented in the branch 'wip-workaroud-lexmark' of Pyinsane. Unfortunately, I cannot really try it. Can you give it a try please ?

git clone https://github.com/jflesch/pyinsane.git
cd pyinsane
git checkout wip-workaround-lexmark
python3 ./setup.py install

@tiramiseb
Copy link
Collaborator Author

ERROR  paperwork.frontend.util.jobs   ===> Job ResolutionFinder:2 raised an exception: <class 'RecursionError'>: maximum recursion depth exceeded
ERROR  paperwork.frontend.util.jobs    0: /usr/local/lib/python3.5/dist-packages/paperwork/frontend/util/jobs.py: L  180: _run
ERROR  paperwork.frontend.util.jobs    1: /usr/local/lib/python3.5/dist-packages/paperwork/frontend/settingswindow/__init__.py: L  256: do
ERROR  paperwork.frontend.util.jobs    2: /usr/local/lib/python3.5/dist-packages/pyinsane2-2.0.7-py3.5.egg/pyinsane2/sane/abstract_proc.py: L  249: _get_options
ERROR  paperwork.frontend.util.jobs    3: /usr/local/lib/python3.5/dist-packages/pyinsane2-2.0.7-py3.5.egg/pyinsane2/sane/abstract_proc.py: L   71: remote_do
ERROR  paperwork.frontend.util.jobs    4: /usr/local/lib/python3.5/dist-packages/pyinsane2-2.0.7-py3.5.egg/pyinsane2/util.py: L   26: __getattr__
ERROR  paperwork.frontend.util.jobs    5: /usr/local/lib/python3.5/dist-packages/pyinsane2-2.0.7-py3.5.egg/pyinsane2/util.py: L   26: __getattr__

@jflesch
Copy link
Member

jflesch commented Nov 28, 2016

Hm, ok, should be fixed (still in the same branch)

@tiramiseb
Copy link
Collaborator Author

Weird error...
keyerror on _options, which is defined in the __init__... :/

ERROR  paperwork.frontend.util.jobs   ===> Job SourceFinder:4 raised an exception: <class 'KeyError'>: '_options'
ERROR  paperwork.frontend.util.jobs    0: /usr/local/lib/python3.5/dist-packages/paperwork/frontend/util/jobs.py: L  180: _run
ERROR  paperwork.frontend.util.jobs    1: /usr/local/lib/python3.5/dist-packages/paperwork/frontend/settingswindow/__init__.py: L  166: do
ERROR  paperwork.frontend.util.jobs    2: /usr/local/lib/python3.5/dist-packages/pyinsane2-2.0.7-py3.5.egg/pyinsane2/sane/abstract_proc.py: L  249: _get_options
ERROR  paperwork.frontend.util.jobs    3: /usr/local/lib/python3.5/dist-packages/pyinsane2-2.0.7-py3.5.egg/pyinsane2/sane/abstract_proc.py: L   71: remote_do
ERROR  paperwork.frontend.util.jobs    4: /usr/local/lib/python3.5/dist-packages/pyinsane2-2.0.7-py3.5.egg/pyinsane2/util.py: L   30: __getattr__
ERROR  paperwork.frontend.util.jobs   ---> Job SourceFinder:4 was started by:
ERROR  paperwork.frontend.util.jobs    0: /usr/local/bin/paperwork: L    6: <module>
ERROR  paperwork.frontend.util.jobs    1: /usr/local/lib/python3.5/dist-packages/paperwork/paperwork.py: L  153: main
ERROR  paperwork.frontend.util.jobs    2: /usr/local/lib/python3.5/dist-packages/paperwork/frontend/util/actions.py: L   85: on_combobox_changed_cb
ERROR  paperwork.frontend.util.jobs    3: /usr/local/lib/python3.5/dist-packages/paperwork/frontend/util/actions.py: L   64: __do
ERROR  paperwork.frontend.util.jobs    4: /usr/local/lib/python3.5/dist-packages/paperwork/frontend/settingswindow/__init__.py: L  514: do
ERROR  paperwork.frontend.util.jobs    5: /usr/local/lib/python3.5/dist-packages/paperwork/frontend/util/jobs.py: L  249: schedule
INFO   paperwork.frontend.settingswindow Looking for resolution of device [lexmark_nscan:libusb/003/005]
ERROR  paperwork.frontend.util.jobs   ===> Job ResolutionFinder:4 raised an exception: <class 'KeyError'>: '_options'
ERROR  paperwork.frontend.util.jobs    0: /usr/local/lib/python3.5/dist-packages/paperwork/frontend/util/jobs.py: L  180: _run
ERROR  paperwork.frontend.util.jobs    1: /usr/local/lib/python3.5/dist-packages/paperwork/frontend/settingswindow/__init__.py: L  256: do
ERROR  paperwork.frontend.util.jobs    2: /usr/local/lib/python3.5/dist-packages/pyinsane2-2.0.7-py3.5.egg/pyinsane2/sane/abstract_proc.py: L  249: _get_options
ERROR  paperwork.frontend.util.jobs    3: /usr/local/lib/python3.5/dist-packages/pyinsane2-2.0.7-py3.5.egg/pyinsane2/sane/abstract_proc.py: L   71: remote_do
ERROR  paperwork.frontend.util.jobs    4: /usr/local/lib/python3.5/dist-packages/pyinsane2-2.0.7-py3.5.egg/pyinsane2/util.py: L   30: __getattr__
INFO   paperwork.frontend.settingswindow Selected source: -1
ERROR  paperwork.frontend.util.jobs   ---> Job ResolutionFinder:4 was started by:
ERROR  paperwork.frontend.util.jobs    0: /usr/local/bin/paperwork: L    6: <module>
ERROR  paperwork.frontend.util.jobs    1: /usr/local/lib/python3.5/dist-packages/paperwork/paperwork.py: L  153: main
ERROR  paperwork.frontend.util.jobs    2: /usr/local/lib/python3.5/dist-packages/paperwork/frontend/util/actions.py: L   85: on_combobox_changed_cb
INFO   paperwork.frontend.settingswindow Scanner sources: []
ERROR  paperwork.frontend.util.jobs    3: /usr/local/lib/python3.5/dist-packages/paperwork/frontend/util/actions.py: L   64: __do
ERROR  paperwork.frontend.util.jobs    4: /usr/local/lib/python3.5/dist-packages/paperwork/frontend/settingswindow/__init__.py: L  518: do
ERROR  paperwork.frontend.util.jobs    5: /usr/local/lib/python3.5/dist-packages/paperwork/frontend/util/jobs.py: L  249: schedule

@jflesch
Copy link
Member

jflesch commented Dec 1, 2016

Yep, weird. It seems for some reason getattr was called before init() was even called.
Honestly, this is about the limit of my knowledge in Python, so I've just added an if to work around that.

Anyway, this time, I took more time to test it (I patched Pyinsane a little to test it on my hardware), and I'm confident it will work this time. I'm merge it on the branch 'stable'. Feel free to give it a try.

I'm closing this ticket. Please comment if I missed anything and I'll reopen it.

@jflesch jflesch closed this as completed Dec 1, 2016
@tiramiseb
Copy link
Collaborator Author

Seems okay, thanks

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants