482
483
log.info("No devices found.")
485
tui.header("INSTALLED CUPS PRINTER QUEUES")
487
lpstat_pat = re.compile(r"""(\S*): (.*)""", re.IGNORECASE)
488
status, output = utils.run('lpstat -v')
493
for p in output.splitlines():
495
match = lpstat_pat.search(p)
496
printer_name = match.group(1)
497
device_uri = match.group(2)
498
cups_printers.append((printer_name, device_uri))
499
except AttributeError:
502
log.debug(cups_printers)
505
for p in cups_printers:
506
printer_name, device_uri = p
508
if device_uri.startswith("cups-pdf:/") or \
509
device_uri.startswith('ipp://'):
486
tui.header("INSTALLED CUPS PRINTER QUEUES")
488
lpstat_pat = re.compile(r"""(\S*): (.*)""", re.IGNORECASE)
489
status, output = utils.run('lpstat -v')
494
for p in output.splitlines():
513
back_end, is_hp, bus, model, serial, dev_file, host, zc, port = \
514
device.parseDeviceURI(device_uri)
516
back_end, is_hp, bus, model, serial, dev_file, host, zc, port = \
517
'', False, '', '', '', '', '', '', 1
519
#print back_end, is_hp, bus, model, serial, dev_file, host, zc, port
521
log.info(log.bold(printer_name))
522
log.info(log.bold('-'*len(printer_name)))
525
if back_end == 'hpfax':
527
elif back_end == 'hp':
530
log.info("Type: %s" % x)
533
# x = 'Yes, using the %s: CUPS backend.' % back_end
535
# x = 'No, not using the hp: or hpfax: CUPS backend.'
538
#log.info("Installed in HPLIP?: %s" % x)
539
log.info("Device URI: %s" % device_uri)
541
ppd = os.path.join('/etc/cups/ppd', printer_name + '.ppd')
543
if os.path.exists(ppd):
544
log.info("PPD: %s" % ppd)
545
nickname_pat = re.compile(r'''\*NickName:\s*\"(.*)"''', re.MULTILINE)
496
match = lpstat_pat.search(p)
497
printer_name = match.group(1)
498
device_uri = match.group(2)
499
cups_printers.append((printer_name, device_uri))
500
except AttributeError:
503
log.debug(cups_printers)
506
for p in cups_printers:
507
printer_name, device_uri = p
509
if device_uri.startswith("cups-pdf:/") or \
510
device_uri.startswith('ipp://'):
547
f = file(ppd, 'r').read(4096)
549
log.warn("Failed to read %s ppd file"%ppd)
514
back_end, is_hp, bus, model, serial, dev_file, host, zc, port = \
515
device.parseDeviceURI(device_uri)
517
back_end, is_hp, bus, model, serial, dev_file, host, zc, port = \
518
'', False, '', '', '', '', '', '', 1
520
#print back_end, is_hp, bus, model, serial, dev_file, host, zc, port
522
log.info(log.bold(printer_name))
523
log.info(log.bold('-'*len(printer_name)))
526
if back_end == 'hpfax':
528
elif back_end == 'hp':
531
log.info("Type: %s" % x)
534
# x = 'Yes, using the %s: CUPS backend.' % back_end
536
# x = 'No, not using the hp: or hpfax: CUPS backend.'
539
#log.info("Installed in HPLIP?: %s" % x)
540
log.info("Device URI: %s" % device_uri)
542
ppd = os.path.join('/etc/cups/ppd', printer_name + '.ppd')
544
if os.path.exists(ppd):
545
log.info("PPD: %s" % ppd)
546
nickname_pat = re.compile(r'''\*NickName:\s*\"(.*)"''', re.MULTILINE)
553
desc = nickname_pat.search(f).group(1)
554
except AttributeError:
548
f = file(ppd, 'r').read(4096)
550
log.warn("Failed to read %s ppd file"%ppd)
557
log.info("PPD Description: %s" % desc)
559
status, output = utils.run('lpstat -p%s' % printer_name)
560
log.info("Printer status: %s" % output.replace("\n", ""))
562
if back_end == 'hpfax' and not 'HP Fax' in desc:
564
log.error("Incorrect PPD file for fax queue '%s'. Fax queues must use 'HP-Fax-hplip.ppd'." % printer_name)
566
elif back_end == 'hp' and 'HP Fax' in desc:
568
log.error("Incorrect PPD file for a print queue '%s'. Print queues must not use 'HP-Fax-hplip.ppd'." % printer_name)
570
elif back_end not in ('hp', 'hpfax'):
571
log.warn("Printer is not HPLIP installed. Printers must use the hp: or hpfax: CUPS backend for HP-Devices.")
574
if device_avail and is_hp:
554
desc = nickname_pat.search(f).group(1)
555
except AttributeError:
558
log.info("PPD Description: %s" % desc)
560
status, output = utils.run('lpstat -p%s' % printer_name)
561
log.info("Printer status: %s" % output.replace("\n", ""))
563
if back_end == 'hpfax' and not 'HP Fax' in desc:
565
log.error("Incorrect PPD file for fax queue '%s'. Fax queues must use 'HP-Fax-hplip.ppd'." % printer_name)
567
elif back_end == 'hp' and 'HP Fax' in desc:
569
log.error("Incorrect PPD file for a print queue '%s'. Print queues must not use 'HP-Fax-hplip.ppd'." % printer_name)
571
elif back_end not in ('hp', 'hpfax'):
572
log.warn("Printer is not HPLIP installed. Printers must use the hp: or hpfax: CUPS backend for HP-Devices.")
575
if device_avail and is_hp:
578
d = device.Device(device_uri,None, None, None, True)
580
log.error("Device initialization failed.")
583
plugin = d.mq.get('plugin', PLUGIN_NONE)
584
if plugin in (PLUGIN_REQUIRED, PLUGIN_OPTIONAL):
586
from installer import pluginhandler
587
pluginObj = pluginhandler.PluginHandle()
588
plugin_sts = pluginObj.getStatus()
590
if plugin_sts == pluginhandler.PLUGIN_INSTALLED:
591
self.plugin_status = PLUGIN_INSTALLED
592
if plugin == pluginhandler.PLUGIN_REQUIRED:
593
log.info("Required plug-in status: Installed")
595
log.info("Optional plug-in status: Installed")
596
elif plugin_sts == pluginhandler.PLUGIN_NOT_INSTALLED:
597
self.plugin_status = PLUGIN_NOT_INSTALLED
598
if plugin == PLUGIN_REQUIRED:
600
log.error("Required plug-in status: Not installed")
603
log.warn("Optional plug-in status: Not installed")
604
elif plugin_sts == pluginhandler.PLUGIN_VERSION_MISMATCH:
606
self.plugin_status = pluginhandler.PLUGIN_VERSION_MISMATCH
607
log.warn("plug-in status: Version mismatch")
610
if bus in ('par', 'usb'):
617
deviceid = d.getDeviceID()
622
log.error("Communication status: Failed")
623
self.comm_error_devices[printer_name] = device_uri
626
log.info("Communication status: Good")
630
error_code, deviceid = d.getPML(pml.OID_DEVICE_ID)
579
d = device.Device(device_uri,None, None, None, True)
636
log.error("Communication status: Failed")
637
self.comm_error_devices[printer_name] = device_uri
640
log.info("Communication status: Good")
647
log.warn("No queues found.")
581
log.error("Device initialization failed.")
584
plugin = d.mq.get('plugin', PLUGIN_NONE)
585
if plugin in (PLUGIN_REQUIRED, PLUGIN_OPTIONAL):
587
from installer import pluginhandler
588
pluginObj = pluginhandler.PluginHandle()
589
plugin_sts = pluginObj.getStatus()
591
if plugin_sts == pluginhandler.PLUGIN_INSTALLED:
592
self.plugin_status = PLUGIN_INSTALLED
593
if plugin == pluginhandler.PLUGIN_REQUIRED:
594
log.info("Required plug-in status: Installed")
596
log.info("Optional plug-in status: Installed")
597
elif plugin_sts == pluginhandler.PLUGIN_NOT_INSTALLED:
598
self.plugin_status = PLUGIN_NOT_INSTALLED
599
if plugin == PLUGIN_REQUIRED:
601
log.error("Required plug-in status: Not installed")
604
log.warn("Optional plug-in status: Not installed")
605
elif plugin_sts == pluginhandler.PLUGIN_VERSION_MISMATCH:
607
self.plugin_status = pluginhandler.PLUGIN_VERSION_MISMATCH
608
log.warn("plug-in status: Version mismatch")
611
if bus in ('par', 'usb'):
618
deviceid = d.getDeviceID()
623
log.error("Communication status: Failed")
624
self.comm_error_devices[printer_name] = device_uri
627
log.info("Communication status: Good")
631
error_code, deviceid = d.getPML(pml.OID_DEVICE_ID)
637
log.error("Communication status: Failed")
638
self.comm_error_devices[printer_name] = device_uri
641
log.info("Communication status: Good")
648
log.warn("No queues found.")
649
650
tui.header("PERMISSION")
650
651
sts,avl_grps_out =utils.run('groups')