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" 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 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 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
tui.header("PRINT QUEUE SETUP") if not auto and print_uri in installed_print_devices: log.warning("One or more print queues already exist for this device: %s." % ', '.join(installed_print_devices[print_uri])) ok, setup_print = tui.enter_yes_no("\nWould you like to install another print queue for this device", 'n') if not ok: clean_exit(0) if setup_print: if auto: printer_name = default_model printer_default_model = default_model installed_printer_names = device.getSupportedCUPSPrinterNames(['hp']) # Check for duplicate names if (device_uri in installed_print_devices and printer_default_model in installed_print_devices[device_uri]) \ or (printer_default_model in installed_printer_names): i = 2 while True: t = printer_default_model + "_%d" % i if (t not in installed_printer_names) and(device_uri not in installed_print_devices or t not in installed_print_devices[device_uri]): printer_default_model += "_%d" % i break i += 1 if not auto: if printer_name is None: while True: printer_name = input(log.bold("\nPlease enter a name for this print queue (m=use model name:'%s'*, q=quit) ?" % printer_default_model))