Bug 228505

Summary: Epson Stylus D78 gets wrong driver for queue
Product: [Fedora] Fedora Reporter: Tim Waugh <twaugh>
Component: system-config-printerAssignee: Tim Waugh <twaugh>
Status: CLOSED ERRATA QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: 6   
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: 0.7.52-1.fc6 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2007-02-15 09:55:37 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 207681, 228506    

Description Tim Waugh 2007-02-13 12:50:59 UTC
Description of problem:
When trying to create a queue for an Epson Stylus D78 (which is not in the
foomatic database yet), the close-match logic in foomatic.py ends up choosing
Epson Stylus Pro 10000 because

a) when scanning through the list, it isn't sorted in model order, and
b) the 'how many characters match' logic is slightly wrong

Version-Release number of selected component (if applicable):
system-config-printer-0.7.50-1.fc6

How reproducible:
100%

Steps to Reproduce:
1. Run this Python program:

#!/usr/bin/python
import sys
sys.path.append ('/usr/share/system-config-printer')
import foomatic
f=foomatic.Foomatic()
mfg='EPSON'
mdl='Stylus D78'
cmd=['ESCPL2','BDC','D4','D4PX']
print f.getPrinterFromDeviceID(mfg,mdl,commandsets=cmd)
  
Actual results:
Writing new pickle
Please report a bug in Bugzilla against 'foomatic':
  https://bugzilla.redhat.com/bugzilla
Include this complete message.
Guessing Epson-Stylus_Pro_10000 from IEEE 1284 ID:
      <manufacturer>EPSON</manufacturer>
      <model>Stylus D78</model>
      <description></description>
      <commandset>ESCPL2,BDC,D4,D4PX</commandset>
Epson-Stylus_Pro_10000

Expected results:
Writing new pickle
Please report a bug in Bugzilla against 'foomatic':
  https://bugzilla.redhat.com/bugzilla
Include this complete message.
Guessing Epson-Stylus_D68 from IEEE 1284 ID:
      <manufacturer>EPSON</manufacturer>
      <model>Stylus D78</model>
      <description></description>
      <commandset>ESCPL2,BDC,D4,D4PX</commandset>
Epson-Stylus_D68

Additional info:
Fix is:

Index: foomatic.py
===================================================================
RCS file: /usr/local/CVS/system-config-printer/foomatic.py,v
retrieving revision 1.52
diff -d -u -r1.52 foomatic.py
--- foomatic.py 8 Jan 2007 15:59:52 -0000       1.52
+++ foomatic.py 13 Feb 2007 12:49:17 -0000
@@ -776,12 +776,17 @@
             # Try to find the best match (case-insensitive)
             best_matchlen = 0
             mdll = mdl.lower ()
-            for (name, id) in mdls.iteritems():
-                name = name.lower ()
+            mdlnames = mdls.keys ()
+            mdlnames.sort (cups.modelSort)
+            mdlitems = map (lambda x: (x.lower (), mdls[x]), mdlnames)
+            for (name, id) in mdlitems:
                 if mdll[:1 + best_matchlen] == name[:1 + best_matchlen]:
-                    extra = 2
-                    while (mdll[1 + best_matchlen:extra + best_matchlen] ==
-                           name[1 + best_matchlen:extra + best_matchlen]):
+                    # We know we've got one more character matching.
+                    # Can we match any more on this entry?
+                    extra = 1
+                    while (mdll[1 + best_matchlen:1 + best_matchlen + extra] ==
+                           name[1 + best_matchlen:1 + best_matchlen + extra]):
+                        # Yes!  Try another!
                         extra += 1
                         if extra + best_matchlen >= len (name):
                             break

Comment 1 Tim Waugh 2007-02-13 12:56:14 UTC
Fixed in CVS.

Comment 2 Tim Waugh 2007-02-13 13:23:46 UTC
FC6 test update: 0.7.52-1.fc6.

Comment 3 Tim Waugh 2007-02-14 13:32:02 UTC
Fix verified.

Comment 4 Fedora Update System 2007-02-14 20:01:14 UTC
Fixed in update: system-config-printer-0.7.52-1.fc6