Mageia Bugzilla – Attachment 6184 Details for
Bug 15549
HP printer installed by system-config-printer not recognised by HP Printer Manager (HPLIP)
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
New Account
|
Forgot Password
patch to fix bugs in mga_printer_custom.py
fix-reading-hp-database.patch (text/plain), 2.86 KB, created by
Martin Whitaker
on 2015-04-04 14:47:19 CEST
(
hide
)
Description:
patch to fix bugs in mga_printer_custom.py
Filename:
MIME Type:
Creator:
Martin Whitaker
Created:
2015-04-04 14:47:19 CEST
Size:
2.86 KB
patch
obsolete
>--- mga_printer_custom.py.orig 2015-04-03 23:05:31.036280811 +0100 >+++ mga_printer_custom.py 2015-04-03 23:48:05.510346163 +0100 >@@ -11,6 +11,7 @@ > import ctypes > import ipaddress > import subprocess >+import platform > > SIOCGIFNETMASK = 0x891B > SIOCGIFADDR = 0x8915 >@@ -90,7 +91,7 @@ > # check scanning capabilities > if is_scanning_capable(make1, model1): > if task_printing_hp.count(make1): >- if sys.arch == 'x86_64': >+ if platform.machine() == 'x86_64': > lib="lib64" > else: > lib="lib" >@@ -146,29 +147,22 @@ > re_comment = re.compile("^#") > db = {} > current_entry=None >- while True: >+ for b in a: >+ if re_entry_title.match(b): >+ b = b.strip() >+ b = b.lower() >+ current_entry=b[1:-1] >+ db[current_entry] = {} >+ continue >+ if re_comment.match(b): >+ continue > try: >- b = a.next() >+ (entry,data) = b.split("=") > except: >- b = None >- >- if b: >- if re_entry_title.match(b): >- b = b.strip() >- b = b.lower() >- current_entry=b[1:-1] >- db[current_entry] = {} >- continue >- if re_comment.match(b): >- continue >- try: >- (entry,data) = b.split("=") >- except: >- continue >- db[current_entry][entry] = data.strip().lower() >- else: >- break >+ continue >+ db[current_entry][entry] = data.strip().lower() > >+ a.close(); > return db > > def is_scanning_capable(make, model): >@@ -177,10 +171,10 @@ > model1 = model1.replace(" ", "_") > if make2simplename(make1) == "hp": > a = read_hplip_db() >- if a and a.has_key(model1) and a[model1].has_key('scan-type'): >+ if a and model1 in a and 'scan-type' in a[model1]: > if a[model1]['scan-type'] != '0': > return True >- elif a and a.has_key(model1+"_series") and a[model1+"_series"].has_key('scan-type'): >+ elif a and (model1+"_series") in a and 'scan-type' in a[model1+"_series"]: > if a[model1+"_series"]['scan-type'] != '0': > return True > return False >@@ -191,10 +185,10 @@ > model1 = model1.replace(" ", "_") > if make2simplename(make1) == "hp": > a = read_hplip_db() >- if a and a.has_key(model1) and a[model1].has_key('fax-type'): >+ if a and model1 in a and 'fax-type' in a[model1]: > if a[model1]['fax-type'] != '0': > return True >- elif a and a.has_key(model1+"_series") and a[model1+"_series"].has_key('fax-type'): >+ elif a and (model1+"_series") in a and 'fax-type' in a[model1+"_series"]: > if a[model1+"_series"]['fax-type'] != '0': > return True > return False
--- mga_printer_custom.py.orig 2015-04-03 23:05:31.036280811 +0100 +++ mga_printer_custom.py 2015-04-03 23:48:05.510346163 +0100 @@ -11,6 +11,7 @@ import ctypes import ipaddress import subprocess +import platform SIOCGIFNETMASK = 0x891B SIOCGIFADDR = 0x8915 @@ -90,7 +91,7 @@ # check scanning capabilities if is_scanning_capable(make1, model1): if task_printing_hp.count(make1): - if sys.arch == 'x86_64': + if platform.machine() == 'x86_64': lib="lib64" else: lib="lib" @@ -146,29 +147,22 @@ re_comment = re.compile("^#") db = {} current_entry=None - while True: + for b in a: + if re_entry_title.match(b): + b = b.strip() + b = b.lower() + current_entry=b[1:-1] + db[current_entry] = {} + continue + if re_comment.match(b): + continue try: - b = a.next() + (entry,data) = b.split("=") except: - b = None - - if b: - if re_entry_title.match(b): - b = b.strip() - b = b.lower() - current_entry=b[1:-1] - db[current_entry] = {} - continue - if re_comment.match(b): - continue - try: - (entry,data) = b.split("=") - except: - continue - db[current_entry][entry] = data.strip().lower() - else: - break + continue + db[current_entry][entry] = data.strip().lower() + a.close(); return db def is_scanning_capable(make, model): @@ -177,10 +171,10 @@ model1 = model1.replace(" ", "_") if make2simplename(make1) == "hp": a = read_hplip_db() - if a and a.has_key(model1) and a[model1].has_key('scan-type'): + if a and model1 in a and 'scan-type' in a[model1]: if a[model1]['scan-type'] != '0': return True - elif a and a.has_key(model1+"_series") and a[model1+"_series"].has_key('scan-type'): + elif a and (model1+"_series") in a and 'scan-type' in a[model1+"_series"]: if a[model1+"_series"]['scan-type'] != '0': return True return False @@ -191,10 +185,10 @@ model1 = model1.replace(" ", "_") if make2simplename(make1) == "hp": a = read_hplip_db() - if a and a.has_key(model1) and a[model1].has_key('fax-type'): + if a and model1 in a and 'fax-type' in a[model1]: if a[model1]['fax-type'] != '0': return True - elif a and a.has_key(model1+"_series") and a[model1+"_series"].has_key('fax-type'): + elif a and (model1+"_series") in a and 'fax-type' in a[model1+"_series"]: if a[model1+"_series"]['fax-type'] != '0': return True return False
View Attachment As Raw
Actions:
View
Attachments on
bug 15549
:
6179
|
6183
| 6184 |
6185
|
6189