def setDefaultPrinterName(self): self.installed_print_devices = device.getSupportedCUPSDevices(['hp']) log.debug(self.installed_print_devices) self.installed_queues = [p.name for p in cups.getPrinters()] back_end, is_hp, bus, model, serial, dev_file, host, zc, port = device.parseDeviceURI(self.device_uri) default_model = utils.xstrip(model.replace('series', '').replace('Series', ''), '_') printer_name = default_model installed_printer_names = device.getSupportedCUPSPrinterNames(['hp']) # Check for duplicate names if (self.device_uri in self.installed_print_devices and printer_name in self.installed_print_devices[self.device_uri]) \ or (printer_name in installed_printer_names): i = 2 while True: t = printer_name + "_%d" % i if (t not in installed_printer_names) and (self.device_uri not in self.installed_print_devices or t not in self.installed_print_devices[self.device_uri]): printer_name += "_%d" % i break i += 1 self.printer_name_ok = True self.PrinterNameLineEdit.setText(printer_name) log.debug(printer_name) self.printer_name = printer_name
def setDefaultFaxName(self): self.installed_fax_devices = device.getSupportedCUPSDevices(['hpfax']) log.debug(self.installed_fax_devices) self.fax_uri = self.device_uri.replace('hp:', 'hpfax:') back_end, is_hp, bus, model, serial, dev_file, host, zc, port = device.parseDeviceURI(self.fax_uri) default_model = utils.xstrip(model.replace('series', '').replace('Series', ''), '_') fax_name = default_model + "_fax" installed_fax_names = device.getSupportedCUPSPrinterNames(['hpfax']) # Check for duplicate names if (self.fax_uri in self.installed_fax_devices and fax_name in self.installed_fax_devices[self.fax_uri]) \ or (fax_name in installed_fax_names): i = 2 while True: t = fax_name + "_%d" % i if (t not in installed_fax_names) and (self.fax_uri not in self.installed_fax_devices or t not in self.installed_fax_devices[self.fax_uri]): fax_name += "_%d" % i break i += 1 self.fax_name_ok = True self.FaxNameLineEdit.setText(fax_name) self.fax_name = fax_name
def setDefaultFaxName(self): self.installed_fax_devices = device.getSupportedCUPSDevices(['hpfax']) log.debug(self.installed_fax_devices) self.fax_uri = self.device_uri.replace('hp:', 'hpfax:') back_end, is_hp, bus, model, serial, dev_file, host, zc, port = device.parseDeviceURI(self.fax_uri) default_model = utils.xstrip(model.replace('series', '').replace('Series', ''), '_') fax_name = default_model + "_fax" # Check for duplicate names if self.fax_uri in self.installed_fax_devices and \ fax_name in self.installed_fax_devices[self.fax_uri]: #if fax_name in self.installed_queues or fax_name == self.printer_name: i = 2 while True: t = fax_name + "_%d" % i if t not in self.installed_fax_devices[self.fax_uri]: fax_name += "_%d" % i break i += 1 self.fax_name_ok = True self.faxNameLineEdit.setText(fax_name) self.faxNameLineEdit.setPaletteBackgroundColor(self.bg) self.defaultFaxNamePushButton.setEnabled(False) self.fax_name = fax_name
def setDefaultFaxName(self): self.installed_fax_devices = device.getSupportedCUPSDevices(['hpfax']) log.debug(self.installed_fax_devices) self.fax_uri = self.device_uri.replace('hp:', 'hpfax:') back_end, is_hp, bus, model, serial, dev_file, host, zc, port = device.parseDeviceURI(self.fax_uri) default_model = utils.xstrip(model.replace('series', '').replace('Series', ''), '_') fax_name = default_model + "_fax" installed_fax_names = device.getSupportedCUPSPrinterNames(['hpfax']) # Check for duplicate names if (self.fax_uri in self.installed_fax_devices and fax_name in self.installed_fax_devices[self.fax_uri]) \ or (fax_name in installed_fax_names): #if fax_name in self.installed_queues or fax_name == self.printer_name: i = 2 while True: t = fax_name + "_%d" % i if (t not in installed_fax_names) and (self.fax_uri not in self.installed_fax_devices or t not in self.installed_fax_devices[self.fax_uri]): fax_name += "_%d" % i break i += 1 self.fax_name_ok = True self.faxNameLineEdit.setText(fax_name) self.faxNameLineEdit.setPaletteBackgroundColor(self.bg) self.defaultFaxNamePushButton.setEnabled(False) self.fax_name = fax_name
def setDefaultPrinterName(self): self.installed_print_devices = device.getSupportedCUPSDevices(['hp']) #self.installed_print_devices = device.getSupportedCUPSDevices('*') log.debug(self.installed_print_devices) self.installed_queues = [p.name for p in cups.getPrinters()] back_end, is_hp, bus, model, serial, dev_file, host, zc, port = device.parseDeviceURI(self.device_uri) default_model = utils.xstrip(model.replace('series', '').replace('Series', ''), '_') printer_name = default_model # Check for duplicate names if self.device_uri in self.installed_print_devices and \ printer_name in self.installed_print_devices[self.device_uri]: i = 2 while True: t = printer_name + "_%d" % i if t not in self.installed_print_devices[self.device_uri]: printer_name += "_%d" % i break i += 1 self.printer_name_ok = True self.printerNameLineEdit.setText(printer_name) log.debug(printer_name) self.printerNameLineEdit.setPaletteBackgroundColor(self.bg) self.defaultPrinterNamePushButton.setEnabled(False) self.printer_name = printer_name
def setDefaultFaxName(self): self.installed_fax_devices = device.getSupportedCUPSDevices(["hpfax"]) log.debug(self.installed_fax_devices) self.fax_uri = self.device_uri.replace("hp:", "hpfax:") back_end, is_hp, bus, model, serial, dev_file, host, zc, port = device.parseDeviceURI(self.fax_uri) default_model = utils.xstrip(model.replace("series", "").replace("Series", ""), "_") fax_name = default_model + "_fax" installed_fax_names = device.getSupportedCUPSPrinterNames(["hpfax"]) # Check for duplicate names if (self.fax_uri in self.installed_fax_devices and fax_name in self.installed_fax_devices[self.fax_uri]) or ( fax_name in installed_fax_names ): # if fax_name in self.installed_queues or fax_name == self.printer_name: i = 2 while True: t = fax_name + "_%d" % i if (t not in installed_fax_names) and ( self.fax_uri not in self.installed_fax_devices or t not in self.installed_fax_devices[self.fax_uri] ): fax_name += "_%d" % i break i += 1 self.fax_name_ok = True self.faxNameLineEdit.setText(fax_name) self.faxNameLineEdit.setPaletteBackgroundColor(self.bg) self.defaultFaxNamePushButton.setEnabled(False) self.fax_name = fax_name
def setDefaultPrinterName(self): self.installed_print_devices = device.getSupportedCUPSDevices(['hp']) #self.installed_print_devices = device.getSupportedCUPSDevices('*') log.debug(self.installed_print_devices) self.installed_queues = [p.name for p in cups.getPrinters()] back_end, is_hp, bus, model, serial, dev_file, host, zc, port = device.parseDeviceURI(self.device_uri) default_model = utils.xstrip(model.replace('series', '').replace('Series', ''), '_') printer_name = default_model installed_printer_names = device.getSupportedCUPSPrinterNames(['hp']) # Check for duplicate names if (self.device_uri in self.installed_print_devices and printer_name in self.installed_print_devices[self.device_uri]) \ or (printer_name in installed_printer_names): i = 2 while True: t = printer_name + "_%d" % i if (t not in installed_printer_names) and (self.device_uri not in self.installed_print_devices or t not in self.installed_print_devices[self.device_uri]): printer_name += "_%d" % i break i += 1 self.printer_name_ok = True self.printerNameLineEdit.setText(printer_name) log.debug(printer_name) self.printerNameLineEdit.setPaletteBackgroundColor(self.bg) self.defaultPrinterNamePushButton.setEnabled(False) self.printer_name = printer_name
def updatePPDPage(self, ppds=None): QApplication.setOverrideCursor(QApplication.waitCursor) try: back_end, is_hp, bus, model, serial, dev_file, host, zc, port = device.parseDeviceURI( self.device_uri) except Error: self.FailureUI( self.__tr( "<b>Device not found or invalid HPLIP device.</b><p>If you specified a USB ID, IP address, or other parameter, please re-check it and try again." )) self.close() sys.exit() if ppds is None or not ppds: ppds = cups.getSystemPPDs() #print ppds default_model = utils.xstrip( model.replace('series', '').replace('Series', ''), '_') stripped_model = cups.stripModel2( models.normalizeModelName(model).lower()) #Check if common ppd name is already given in models.dat(This is needed because in case of devices having more than one derivatives #will have diffrent model name strings in device ID, because of which we don't get the common ppd name for search) ppd_name = self.mq.get('ppd-name', 0) if ppd_name == 0: self.ppd = cups.getPPDFile2(stripped_model, ppds) else: self.ppd = cups.getPPDFile2(ppd_name, ppds) log.debug(self.ppd) self.ppdListView.clear() if self.ppd is not None: #for ppd in self.ppd_dict: PPDListViewItem(self.ppdListView, self.ppd[0], self.ppd[1]) # i = self.ppdListView.firstChild() # self.ppdListView.setCurrentItem(i) # self.ppdListView.setSelected(i, True) # self.ppd_file = self.ppdListView.currentItem().ppd_file self.ppd_file = self.ppd[0] log.debug(self.ppd_file) else: self.FailureUI( self.__tr( '<b>PPD not file found.</b><p>An appropriate PPD file could not be found. Please check your HPLIP install, use <i>Select Other...</i>, or download one from linuxprinting.org.' )) QApplication.restoreOverrideCursor()
def setDefaultPrinterName(self): self.installed_print_devices = device.getSupportedCUPSDevices(["hp"]) # self.installed_print_devices = device.getSupportedCUPSDevices('*') log.debug(self.installed_print_devices) self.installed_queues = [p.name for p in cups.getPrinters()] back_end, is_hp, bus, model, serial, dev_file, host, zc, port = device.parseDeviceURI(self.device_uri) default_model = utils.xstrip(model.replace("series", "").replace("Series", ""), "_") printer_name = default_model installed_printer_names = device.getSupportedCUPSPrinterNames(["hp"]) # Check for duplicate names if ( self.device_uri in self.installed_print_devices and printer_name in self.installed_print_devices[self.device_uri] ) or (printer_name in installed_printer_names): warn_text = self.__tr( "<b>One or more print queues already exist for this device: %s</b>.<br> <b>Would you like to install another print queue for this device ?</b>" % ", ".join([printer.encode("utf-8") for printer in installed_printer_names if printer_name in printer]) ) if ( QMessageBox.warning( self, self.caption(), warn_text, QMessageBox.Yes, QMessageBox.No, QMessageBox.NoButton ) == QMessageBox.Yes ): i = 2 while True: t = printer_name + "_%d" % i if (t not in installed_printer_names) and ( self.device_uri not in self.installed_print_devices or t not in self.installed_print_devices[self.device_uri] ): printer_name += "_%d" % i break i += 1 else: self.close() self.printer_name_ok = True self.printerNameLineEdit.setText(printer_name) log.debug(printer_name) self.printerNameLineEdit.setPaletteBackgroundColor(self.bg) self.defaultPrinterNamePushButton.setEnabled(False) self.printer_name = printer_name
def setDefaultPrinterName(self): self.installed_print_devices = device.getSupportedCUPSDevices(['hp']) #self.installed_print_devices = device.getSupportedCUPSDevices('*') log.debug(self.installed_print_devices) self.installed_queues = [p.name for p in cups.getPrinters()] back_end, is_hp, bus, model, serial, dev_file, host, zc, port = device.parseDeviceURI( self.device_uri) default_model = utils.xstrip( model.replace('series', '').replace('Series', ''), '_') printer_name = default_model installed_printer_names = device.getSupportedCUPSPrinterNames(['hp']) # Check for duplicate names if (self.device_uri in self.installed_print_devices and printer_name in self.installed_print_devices[self.device_uri]) \ or (printer_name in installed_printer_names): warn_text = self.__tr( "<b>One or more print queues already exist for this device: %s</b>.<br> <b>Would you like to install another print queue for this device ?</b>" % ', '.join([ printer.encode('utf-8') for printer in installed_printer_names if printer_name in printer ])) if (QMessageBox.warning(self, self.caption(), warn_text, QMessageBox.Yes, QMessageBox.No, QMessageBox.NoButton) == QMessageBox.Yes): i = 2 while True: t = printer_name + "_%d" % i if (t not in installed_printer_names) and ( self.device_uri not in self.installed_print_devices or t not in self.installed_print_devices[ self.device_uri]): printer_name += "_%d" % i break i += 1 else: self.close() self.printer_name_ok = True self.printerNameLineEdit.setText(printer_name) log.debug(printer_name) self.printerNameLineEdit.setPaletteBackgroundColor(self.bg) self.defaultPrinterNamePushButton.setEnabled(False) self.printer_name = printer_name
def updatePPDPage(self, ppds=None): QApplication.setOverrideCursor(QApplication.waitCursor) try: back_end, is_hp, bus, model, serial, dev_file, host, zc, port = device.parseDeviceURI(self.device_uri) except Error: self.FailureUI(self.__tr("<b>Device not found or invalid HPLIP device.</b><p>If you specified a USB ID, IP address, or other parameter, please re-check it and try again.")) self.close() sys.exit() if ppds is None or not ppds: ppds = cups.getSystemPPDs() #print ppds default_model = utils.xstrip(model.replace('series', '').replace('Series', ''), '_') stripped_model = cups.stripModel2(models.normalizeModelName(model).lower()) #Check if common ppd name is already given in models.dat(This is needed because in case of devices having more than one derivatives #will have diffrent model name strings in device ID, because of which we don't get the common ppd name for search) ppd_name = self.mq.get('ppd-name',0) if ppd_name == 0: self.ppd = cups.getPPDFile2(stripped_model, ppds) else: self.ppd = cups.getPPDFile2(ppd_name, ppds) log.debug(self.ppd) self.ppdListView.clear() if self.ppd is not None: #for ppd in self.ppd_dict: PPDListViewItem(self.ppdListView, self.ppd[0], self.ppd[1]) # i = self.ppdListView.firstChild() # self.ppdListView.setCurrentItem(i) # self.ppdListView.setSelected(i, True) # self.ppd_file = self.ppdListView.currentItem().ppd_file self.ppd_file = self.ppd[0] log.debug(self.ppd_file) else: self.FailureUI(self.__tr('<b>PPD not file found.</b><p>An appropriate PPD file could not be found. Please check your HPLIP install, use <i>Select Other...</i>, or download one from linuxprinting.org.')) QApplication.restoreOverrideCursor()
tui.header("UPDATING PLUGIN") else: tui.header("PLUG-IN INSTALLATION") hp_plugin = utils.which('hp-plugin') if hp_plugin: cmd = "hp-plugin -i" if os_utils.execute(cmd) != 0: log.error("Failed to install Plugin.") log.error("The device you are trying to setup requires a binary plug-in. Some functionalities may not work as expected without plug-ins. Please run 'hp-plugin' as normal user to install plug-ins.Visit http://hplipopensource.com for more infomation.") clean_exit(1) ppds = cups.getSystemPPDs() default_model = utils.xstrip(model.replace('series', '').replace('Series', ''), '_') installed_print_devices = device.getSupportedCUPSDevices(['hp']) for d in list(installed_print_devices.keys()): for p in installed_print_devices[d]: log.debug("found print queue '%s'" % p) installed_fax_devices = device.getSupportedCUPSDevices(['hpfax']) for d in list(installed_fax_devices.keys()): for f in installed_fax_devices[d]: log.debug("found fax queue '%s'" % f) # ******************************* PRINT QUEUE SETUP if setup_print: tui.header("PRINT QUEUE SETUP")
def normalizeModelName(model): return utils.xstrip( model.replace(' ', '_').replace('__', '_').replace('~', '').replace('/', '_'), '_')
def normalizeModelName(model): return utils.xstrip(model.replace(' ', '_').replace('__', '_').replace('~','').replace('/', '_'), '_')