def setupFax(self): QApplication.setOverrideCursor(QCursor(Qt.WaitCursor)) try: cups.setPasswordPrompt("You do not have permission to add a fax device.") if not os.path.exists(self.fax_ppd): status, status_str = cups.addPrinter(self.fax_name.encode('utf8'), self.fax_uri, self.fax_location, '', self.fax_ppd, self.fax_desc) else: status, status_str = cups.addPrinter(self.fax_name.encode('utf8'), self.fax_uri, self.fax_location, self.fax_ppd, '', self.fax_desc) log.debug("addPrinter() returned (%d, %s)" % (status, status_str)) self.installed_fax_devices = device.getSupportedCUPSDevices(['hpfax']) log.debug(self.installed_fax_devices) if self.fax_uri not in self.installed_fax_devices or \ self.fax_name not in self.installed_fax_devices[self.fax_uri]: QApplication.restoreOverrideCursor() FailureUI(self, self.__tr("<b>Fax queue setup failed.</b><p>Please restart CUPS and try again.")) else: pass # TODO: #service.sendEvent(self.hpssd_sock, EVENT_CUPS_QUEUES_CHANGED, device_uri=self.fax_uri) finally: QApplication.restoreOverrideCursor()
def setupPrinter(self): QApplication.setOverrideCursor(QCursor(Qt.WaitCursor)) try: cups.setPasswordPrompt("You do not have permission to add a printer.") if not os.path.exists(self.print_ppd[0]): # assume foomatic: or some such status, status_str = cups.addPrinter(self.printer_name.encode('utf8'), self.device_uri, self.print_location, '', self.print_ppd[0], self.print_desc) else: status, status_str = cups.addPrinter(self.printer_name.encode('utf8'), self.device_uri, self.print_location, self.print_ppd[0], '', self.print_desc) log.debug("addPrinter() returned (%d, %s)" % (status, status_str)) self.installed_print_devices = device.getSupportedCUPSDevices(['hp']) log.debug(self.installed_print_devices) if self.device_uri not in self.installed_print_devices or \ self.printer_name not in self.installed_print_devices[self.device_uri]: QApplication.restoreOverrideCursor() if os.geteuid!=0 and utils.addgroup()!=[]: FailureUI(self, self.__tr("<b>Printer queue setup failed. Could not connect to CUPS Server</b><p>Is user added to %s group(s)" %utils.list_to_string(utils.addgroup()))) else: # TODO: #service.sendEvent(self.hpssd_sock, EVENT_CUPS_QUEUES_CHANGED, device_uri=self.device_uri) pass finally: QApplication.restoreOverrideCursor()
def setupPrinter(self): QApplication.setOverrideCursor(QApplication.waitCursor) cups.setPasswordPrompt("You do not have permission to add a printer.") #if self.ppd_file.startswith("foomatic:"): if not os.path.exists(self.ppd_file): # assume foomatic: or some such status, status_str = cups.addPrinter(self.printer_name.encode('utf8'), self.device_uri, self.location, '', self.ppd_file, self.desc) else: status, status_str = cups.addPrinter(self.printer_name.encode('utf8'), self.device_uri, self.location, self.ppd_file, '', self.desc) log.debug("addPrinter() returned (%d, %s)" % (status, status_str)) self.installed_print_devices = device.getSupportedCUPSDevices(['hp']) log.debug(self.installed_print_devices) if self.device_uri not in self.installed_print_devices or \ self.printer_name not in self.installed_print_devices[self.device_uri]: self.FailureUI(self.__tr("<b>Printer queue setup failed.</b><p>Please restart CUPS and try again.")) else: # TODO: #service.sendEvent(self.hpssd_sock, EVENT_CUPS_QUEUES_CHANGED, device_uri=self.device_uri) pass QApplication.restoreOverrideCursor()
def setupFax(self): QApplication.setOverrideCursor(QApplication.waitCursor) back_end, is_hp, bus, model, serial, dev_file, host, zc, port = \ device.parseDeviceURI(self.device_uri) norm_model = models.normalizeModelName(model).lower() fax_ppd,fax_ppd_name, nick = cups.getFaxPPDFile(self.mq, norm_model) # Fax ppd not found if not fax_ppd: QApplication.restoreOverrideCursor() log.error("Fax PPD file not found.") if QMessageBox.warning(self, self.__tr("Unable to find HP fax PPD file."), self.__tr("The PPD file (%1.ppd) needed to setup the fax queue was not found.").arg(fax_ppd_name), self.__tr("Browse to file..."), # button 0 self.__tr("Quit") # button 1 ) == 0: # Browse while True: ppd_dir = sys_conf.get('dirs', 'ppd') fax_ppd = unicode(QFileDialog.getOpenFileName(ppd_dir, "HP Fax PPD Files (*.ppd *.ppd.gz);;All Files (*)", self, "open file dialog", "Choose the fax PPD file")) if not fax_ppd: # user hit cancel return if os.path.exists(fax_ppd): n = cups.getPPDDescription(fax_ppd) if n == nick: break else: self.FailureUI(self.__tr("<b>Incorrect fax PPD file.</b><p>The fax PPD file must have a nickname of '%1', not '%1'.").arg(nick).arg(n)) else: self.FailureUI(self.__tr("<b>File not found.</b><p>hp-setup cannot find the file %1").arg(fax_ppd)) else: # Quit return cups.setPasswordPrompt("You do not have permission to add a fax device.") if not os.path.exists(fax_ppd): status, status_str = cups.addPrinter(self.fax_name.encode('utf8'), self.fax_uri, self.fax_location, '', fax_ppd, self.fax_desc) else: status, status_str = cups.addPrinter(self.fax_name.encode('utf8'), self.fax_uri, self.fax_location, fax_ppd, '', self.fax_desc) log.debug("addPrinter() returned (%d, %s)" % (status, status_str)) self.installed_fax_devices = device.getSupportedCUPSDevices(['hpfax']) log.debug(self.installed_fax_devices) if self.fax_uri not in self.installed_fax_devices or \ self.fax_name not in self.installed_fax_devices[self.fax_uri]: self.FailureUI(self.__tr("<b>Fax queue setup failed.</b><p>Please restart CUPS and try again.")) else: # sending Event to add this device in hp-systray utils.sendEvent(EVENT_CUPS_QUEUES_CHANGED,self.fax_uri, self.fax_name) QApplication.restoreOverrideCursor()
def setupPrinter(self): QApplication.setOverrideCursor(QApplication.waitCursor) cups.setPasswordPrompt("You do not have permission to add a printer.") #if self.ppd_file.startswith("foomatic:"): if not os.path.exists(self.ppd_file): # assume foomatic: or some such status, status_str = cups.addPrinter(self.printer_name.encode('utf8'), self.device_uri, self.location, '', self.ppd_file, self.desc) else: status, status_str = cups.addPrinter(self.printer_name.encode('utf8'), self.device_uri, self.location, self.ppd_file, '', self.desc) log.debug("addPrinter() returned (%d, %s)" % (status, status_str)) self.installed_print_devices = device.getSupportedCUPSDevices(['hp']) log.debug(self.installed_print_devices) if self.device_uri not in self.installed_print_devices or \ self.printer_name not in self.installed_print_devices[self.device_uri]: self.FailureUI(self.__tr("<b>Printer queue setup failed.</b><p>Please restart CUPS and try again.")) else: # sending Event to add this device in hp-systray utils.sendEvent(EVENT_CUPS_QUEUES_CHANGED,self.device_uri, self.printer_name) QApplication.restoreOverrideCursor()
def setupFax(self): status = cups.IPP_BAD_REQUEST QApplication.setOverrideCursor(QApplication.waitCursor) back_end, is_hp, bus, model, serial, dev_file, host, zc, port = \ device.parseDeviceURI(self.device_uri) norm_model = models.normalizeModelName(model).lower() fax_ppd,fax_ppd_name, nick = cups.getFaxPPDFile(self.mq, norm_model) # Fax ppd not found if not fax_ppd: QApplication.restoreOverrideCursor() log.error("Fax PPD file not found.") if QMessageBox.warning(self, self.__tr("Unable to find HP fax PPD file."), self.__tr("The PPD file (%1.ppd) needed to setup the fax queue was not found.").arg(fax_ppd_name), self.__tr("Browse to file..."), # button 0 self.__tr("Quit") # button 1 ) == 0: # Browse while True: ppd_dir = sys_conf.get('dirs', 'ppd') fax_ppd = to_unicode(QFileDialog.getOpenFileName(ppd_dir, "HP Fax PPD Files (*.ppd *.ppd.gz);;All Files (*)", self, "open file dialog", "Choose the fax PPD file")) if not fax_ppd: # user hit cancel return if os.path.exists(fax_ppd): n = cups.getPPDDescription(fax_ppd) if n == nick: break else: self.FailureUI(self.__tr("<b>Incorrect fax PPD file.</b><p>The fax PPD file must have a nickname of '%1', not '%1'.").arg(nick).arg(n)) else: self.FailureUI(self.__tr("<b>File not found.</b><p>hp-setup cannot find the file %1").arg(fax_ppd)) else: # Quit return if not os.path.exists(fax_ppd): status, status_str = cups.addPrinter(self.fax_name.encode('utf8'), self.fax_uri, self.fax_location, '', fax_ppd, self.fax_desc) else: status, status_str = cups.addPrinter(self.fax_name.encode('utf8'), self.fax_uri, self.fax_location, fax_ppd, '', self.fax_desc) log.debug("addPrinter() returned (%d, %s)" % (status, status_str)) log.debug(device.getSupportedCUPSDevices(['hpfax'])) if status != cups.IPP_OK: self.FailureUI(self.__tr("<b>Fax queue setup failed.</b><p>Error : %s "%status_str)) else: # sending Event to add this device in hp-systray utils.sendEvent(EVENT_CUPS_QUEUES_ADDED,self.fax_uri, self.fax_name) QApplication.restoreOverrideCursor() return status
def setupFax(self): status = cups.IPP_BAD_REQUEST QApplication.setOverrideCursor(QCursor(Qt.WaitCursor)) try: if not os.path.exists(self.fax_ppd): status, status_str = cups.addPrinter(self.fax_name.encode('utf8'), self.fax_uri, self.fax_location, '', self.fax_ppd, self.fax_desc) else: status, status_str = cups.addPrinter(self.fax_name.encode('utf8'), self.fax_uri, self.fax_location, self.fax_ppd, '', self.fax_desc) log.debug(device.getSupportedCUPSDevices(['hpfax'])) if status != cups.IPP_OK: QApplication.restoreOverrideCursor() FailureUI(self, self.__tr("<b>Fax queue setup failed.</b><p>Error : %s"%status_str)) else: # sending Event to add this device in hp-systray utils.sendEvent(EVENT_CUPS_QUEUES_ADDED,self.fax_uri, self.fax_name) finally: QApplication.restoreOverrideCursor() return status
log.info("OK, done.") clean_exit(0) # TODO: Validate chars break log.info(log.bold("\nAdding fax queue to CUPS:")) log.info("Device URI: %s" % fax_uri) log.info("Queue name: %s" % fax_name) log.info("PPD file: %s" % fax_ppd) log.info("Location: %s" % location) log.info("Information: %s" % info) cups.setPasswordPrompt("You do not have permission to add a fax device.") if not os.path.exists(fax_ppd): # assume foomatic: or some such status, status_str = cups.addPrinter(fax_name, fax_uri, location, '', fax_ppd, info) else: status, status_str = cups.addPrinter(fax_name, fax_uri, location, fax_ppd, '', info) log.debug("addPrinter() returned (%d, %s)" % (status, status_str)) log.debug(device.getSupportedCUPSDevices(['hpfax'])) if status != cups.IPP_OK: log.error("Fax queue setup failed. Error : %s"%status_str) clean_exit(1) else: # sending Event to add this device in hp-systray utils.sendEvent(EVENT_CUPS_QUEUES_ADDED,fax_uri, fax_name)
def setupFax(self): QApplication.setOverrideCursor(QApplication.waitCursor) if self.mq.get('fax-type', FAX_TYPE_NONE) == FAX_TYPE_MARVELL: fax_ppd_name = "HP-Fax3-hplip" # Fixed width (2528 pixels) and 300dpi rendering nick = "HP Fax 3" if self.mq.get('fax-type', FAX_TYPE_NONE) == FAX_TYPE_SOAP or self.mq.get('fax-type', FAX_TYPE_NONE) == FAX_TYPE_LEDMSOAP: fax_ppd_name = "HP-Fax2-hplip" # Fixed width (2528 pixels) and 300dpi rendering nick = "HP Fax 2" if self.mq.get('fax-type', FAX_TYPE_NONE) == FAX_TYPE_LEDM: fax_ppd_name = "HP-Fax4-hplip" # Fixed width (1728 pixels) and 200dpi rendering nick = "HP Fax 4" else: fax_ppd_name = "HP-Fax-hplip" # Standard nick = "HP Fax" ppds = [] log.debug("Searching for fax file %s..." % fax_ppd_name) ppd_dir = sys_conf.get('dirs', 'ppd') for f in utils.walkFiles(ppd_dir, pattern="HP-Fax*.ppd*", abs_paths=True): ppds.append(f) for f in ppds: if f.find(fax_ppd_name) >= 0: fax_ppd = f log.debug("Found PDD file: %s" % fax_ppd) log.debug("Nickname: %s" % cups.getPPDDescription(fax_ppd)) break else: QApplication.restoreOverrideCursor() log.error("Fax PPD file not found.") if QMessageBox.warning(self, self.__tr("Unable to find HP fax PPD file."), self.__tr("The PPD file (%1.ppd) needed to setup the fax queue was not found.").arg(fax_ppd_name), self.__tr("Browse to file..."), # button 0 self.__tr("Quit") # button 1 ) == 0: # Browse while True: ppd_dir = sys_conf.get('dirs', 'ppd') fax_ppd = unicode(QFileDialog.getOpenFileName(ppd_dir, "HP Fax PPD Files (*.ppd *.ppd.gz);;All Files (*)", self, "open file dialog", "Choose the fax PPD file")) if not fax_ppd: # user hit cancel return if os.path.exists(fax_ppd): n = cups.getPPDDescription(fax_ppd) if n == nick: break else: self.FailureUI(self.__tr("<b>Incorrect fax PPD file.</b><p>The fax PPD file must have a nickname of '%1', not '%1'.").arg(nick).arg(n)) else: self.FailureUI(self.__tr("<b>File not found.</b><p>hp-setup cannot find the file %1").arg(fax_ppd)) else: # Quit return cups.setPasswordPrompt("You do not have permission to add a fax device.") if not os.path.exists(fax_ppd): status, status_str = cups.addPrinter(self.fax_name.encode('utf8'), self.fax_uri, self.fax_location, '', fax_ppd, self.fax_desc) else: status, status_str = cups.addPrinter(self.fax_name.encode('utf8'), self.fax_uri, self.fax_location, fax_ppd, '', self.fax_desc) log.debug("addPrinter() returned (%d, %s)" % (status, status_str)) self.installed_fax_devices = device.getSupportedCUPSDevices(['hpfax']) log.debug(self.installed_fax_devices) if self.fax_uri not in self.installed_fax_devices or \ self.fax_name not in self.installed_fax_devices[self.fax_uri]: self.FailureUI(self.__tr("<b>Fax queue setup failed.</b><p>Please restart CUPS and try again.")) else: pass # TODO: #service.sendEvent(self.hpssd_sock, EVENT_CUPS_QUEUES_CHANGED, device_uri=self.fax_uri) QApplication.restoreOverrideCursor()
log.info("Queue name: %s" % printer_name) log.info("PPD file: %s" % print_ppd) log.info("Location: %s" % location) log.info("Information: %s" % info) log.debug("Restarting CUPS...") status, output = utils.run(restart_cups()) log.debug("Restart CUPS returned: exit=%d output=%s" % (status, output)) time.sleep(3) cups.setPasswordPrompt( "You do not have permission to add a printer.") if not os.path.exists(print_ppd): # assume foomatic: or some such status, status_str = cups.addPrinter( printer_name.encode('utf8'), print_uri, location, '', print_ppd, info) else: status, status_str = cups.addPrinter( printer_name.encode('utf8'), print_uri, location, print_ppd, '', info) log.debug("addPrinter() returned (%d, %s)" % (status, status_str)) installed_print_devices = device.getSupportedCUPSDevices(['hp']) if print_uri not in installed_print_devices or \ printer_name not in installed_print_devices[print_uri]: log.error( "Printer queue setup failed. Please restart CUPS and try again."
log.info(log.bold("\nAdding print queue to CUPS:")) log.info("Device URI: %s" % print_uri) log.info("Queue name: %s" % printer_name) log.info("PPD file: %s" % print_ppd) log.info("Location: %s" % location) log.info("Information: %s" % info) log.debug("Restarting CUPS...") status, output = utils.run(restart_cups()) log.debug("Restart CUPS returned: exit=%d output=%s" % (status, output)) time.sleep(3) cups.setPasswordPrompt("You do not have permission to add a printer.") if not os.path.exists(print_ppd): # assume foomatic: or some such status, status_str = cups.addPrinter(printer_name.encode('utf8'), print_uri, location, '', print_ppd, info) else: status, status_str = cups.addPrinter(printer_name.encode('utf8'), print_uri, location, print_ppd, '', info) log.debug("addPrinter() returned (%d, %s)" % (status, status_str)) installed_print_devices = device.getSupportedCUPSDevices(['hp']) if print_uri not in installed_print_devices or \ printer_name not in installed_print_devices[print_uri]: log.error("Printer queue setup failed. Please restart CUPS and try again.") sys.exit(1) else: # sending Event to add this device in hp-systray
def setupFax(self): QApplication.setOverrideCursor(QApplication.waitCursor) if self.mq.get('fax-type', FAX_TYPE_NONE) == FAX_TYPE_MARVELL: fax_ppd_name = "HP-Fax3-hplip" # Fixed width (2528 pixels) and 300dpi rendering nick = "HP Fax 3" if self.mq.get('fax-type', FAX_TYPE_NONE) == FAX_TYPE_SOAP or self.mq.get( 'fax-type', FAX_TYPE_NONE) == FAX_TYPE_LEDMSOAP: fax_ppd_name = "HP-Fax2-hplip" # Fixed width (2528 pixels) and 300dpi rendering nick = "HP Fax 2" if self.mq.get('fax-type', FAX_TYPE_NONE) == FAX_TYPE_LEDM: fax_ppd_name = "HP-Fax4-hplip" # Fixed width (1728 pixels) and 200dpi rendering nick = "HP Fax 4" else: fax_ppd_name = "HP-Fax-hplip" # Standard nick = "HP Fax" ppds = [] log.debug("Searching for fax file %s..." % fax_ppd_name) ppd_dir = sys_conf.get('dirs', 'ppd') for f in utils.walkFiles(ppd_dir, pattern="HP-Fax*.ppd*", abs_paths=True): ppds.append(f) for f in ppds: if f.find(fax_ppd_name) >= 0: fax_ppd = f log.debug("Found PDD file: %s" % fax_ppd) log.debug("Nickname: %s" % cups.getPPDDescription(fax_ppd)) break else: QApplication.restoreOverrideCursor() log.error("Fax PPD file not found.") if QMessageBox.warning( self, self.__tr("Unable to find HP fax PPD file."), self.__tr( "The PPD file (%1.ppd) needed to setup the fax queue was not found." ).arg(fax_ppd_name), self.__tr("Browse to file..."), # button 0 self.__tr("Quit") # button 1 ) == 0: # Browse while True: ppd_dir = sys_conf.get('dirs', 'ppd') fax_ppd = unicode( QFileDialog.getOpenFileName( ppd_dir, "HP Fax PPD Files (*.ppd *.ppd.gz);;All Files (*)", self, "open file dialog", "Choose the fax PPD file")) if not fax_ppd: # user hit cancel return if os.path.exists(fax_ppd): n = cups.getPPDDescription(fax_ppd) if n == nick: break else: self.FailureUI( self.__tr( "<b>Incorrect fax PPD file.</b><p>The fax PPD file must have a nickname of '%1', not '%1'." ).arg(nick).arg(n)) else: self.FailureUI( self.__tr( "<b>File not found.</b><p>hp-setup cannot find the file %1" ).arg(fax_ppd)) else: # Quit return cups.setPasswordPrompt( "You do not have permission to add a fax device.") if not os.path.exists(fax_ppd): status, status_str = cups.addPrinter(self.fax_name.encode('utf8'), self.fax_uri, self.fax_location, '', fax_ppd, self.fax_desc) else: status, status_str = cups.addPrinter(self.fax_name.encode('utf8'), self.fax_uri, self.fax_location, fax_ppd, '', self.fax_desc) log.debug("addPrinter() returned (%d, %s)" % (status, status_str)) self.installed_fax_devices = device.getSupportedCUPSDevices(['hpfax']) log.debug(self.installed_fax_devices) if self.fax_uri not in self.installed_fax_devices or \ self.fax_name not in self.installed_fax_devices[self.fax_uri]: self.FailureUI( self.__tr( "<b>Fax queue setup failed.</b><p>Please restart CUPS and try again." )) else: pass # TODO: #service.sendEvent(self.hpssd_sock, EVENT_CUPS_QUEUES_CHANGED, device_uri=self.fax_uri) QApplication.restoreOverrideCursor()