python-pillow / python-pillow/Sane

sane.Option doesn't properly handle buttons named "scan"

Open
#71 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
61
Forks
22
PR merge metrics
No merged PRs in 30d

Description

I have a couple of scanners (a Fujitsu SnapScan 1500 and a Canon CanoScan LiDE 210) that have front-panel buttons that can initiate scans. Unfortunately, the primary scan buttons are named "scan" and that collides with the bound method to ask the scanner to begin scanning.

>>> import sane
>>>
>>> sane.init()
(16777247, 1, 0, 31)
>>> sane.get_devices()
[('genesys:libusb:001:008', 'Canon', 'LiDE 210', 'flatbed scanner'), ('fujitsu:ScanSnap S1500:56050', 'FUJITSU', 'ScanSnap S1500', 'scanner')]
>>>
>>> scanner = sane.open('fujitsu:ScanSnap S1500:56050')
>>> scanner.opt['scan']

Name:      scan
Cur value: <bound method SaneDev.scan of <sane.SaneDev object at 0x7f8567e60f40>>
Index:     91
Title:     Scan button
Desc:      Scan button
Type:      TYPE_BOOL
Unit:      UNIT_NONE
Constr:    None
active:    yes
settable:  no

Modifying sane.py on line 307 to change the method name from scan to, say, doscan "fixes" the issue for me:

>>> scanner.opt['scan']

Name:      scan
Cur value: 0
Index:     91
Title:     Scan button
Desc:      Scan button
Type:      TYPE_BOOL
Unit:      UNIT_NONE
Constr:    None
active:    yes
settable:  no

I'm not sure what the proper way to fix this for real. :/

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading sane.py around line 307 and the SaneDev.scan method, then reproduce the collision with scanner.opt['scan'] using the example in the issue. Determine how option names and SaneDev methods are exposed together; done means the scan button remains accessible as an option while the scanner can still be asked to begin scanning.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
desktop
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.