Example #1
0
    def NextButton_clicked(self):
        beginWaitCursor()
        try:
            if self.Error_msg == QUEUES_SMART_INSTALL_ENABLED:
                self.disable_smart_install()

            elif self.Error_msg == QUEUES_PAUSED:
                cups.enablePrinter(self.printerName)
                msg = "'" + self.printerName + "' is enabled successfully"
                SuccessUI(self, self.__tr(msg))

            else:
                status, status_str = cups.cups_operation(
                    cups.delPrinter, GUI_MODE, 'qt4', self, self.printerName)

                if status != cups.IPP_OK:
                    msg = "Failed to remove ' " + self.printerName + " ' queue.\nRemove using hp-toolbox..."
                    FailureUI(self, self.__tr(msg))
                else:
                    msg = "' " + self.printerName + " ' removed successfully.\nRe-configuring this printer by hp-setup..."
                    log.debug(msg)
                    path = utils.which('hp-setup')
                    if path:
                        log.debug("Starting hp-setup")
                        utils.run('hp-setup --gui')

        finally:
            endWaitCursor()
        self.result = True
        self.close()
Example #2
0
    def NextButton_clicked(self):
        beginWaitCursor()
        try:
            if self.Error_msg ==  QUEUES_SMART_INSTALL_ENABLED:
                self.disable_smart_install()

            elif  self.Error_msg == QUEUES_PAUSED:
                cups.enablePrinter(self.printerName)
                msg ="'"+self.printerName+"' is enabled successfully"
                SuccessUI(self, self.__tr(msg))

            else:
                status, status_str = cups.cups_operation(cups.delPrinter, GUI_MODE, 'qt4', self, self.printerName)

                if status != cups.IPP_OK:
                    msg="Failed to remove ' "+self.printerName+" ' queue.\nRemove using hp-toolbox..."
                    FailureUI(self, self.__tr(msg))
                else:
                    msg="' "+self.printerName+" ' removed successfully.\nRe-configuring this printer by hp-setup..."
                    log.debug(msg)
                    path = utils.which('hp-setup')
                    if path:
                        log.debug("Starting hp-setup")
                        utils.run('hp-setup --gui')

        finally:
            endWaitCursor()
        self.result = True
        self.close()
Example #3
0
    def setupPrinter(self):
        status = cups.IPP_BAD_REQUEST
        QApplication.setOverrideCursor(QApplication.waitCursor)

        #if self.ppd_file.startswith("foomatic:"):
        if not os.path.exists(self.ppd_file):  # assume foomatic: or some such
            add_prnt_args = (self.printer_name.encode('utf8'), self.device_uri,
                             self.location, '', self.ppd_file, self.desc)
        else:
            add_prnt_args = (self.printer_name.encode('utf8'), self.device_uri,
                             self.location, self.ppd_file, '', self.desc)

        status, status_str = cups.cups_operation(cups.addPrinter, GUI_MODE,
                                                 'qt3', self, *add_prnt_args)

        log.debug("addPrinter() returned (%d, %s)" % (status, status_str))
        log.debug(device.getSupportedCUPSDevices(['hp']))

        if status != cups.IPP_OK:
            self.FailureUI(
                self.__tr("<b>Printer 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.device_uri,
                            self.printer_name)

        QApplication.restoreOverrideCursor()
        return status
Example #4
0
    def setupPrinter(self):
        status = cups.IPP_BAD_REQUEST
        QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
        try:
            if not os.path.exists(self.print_ppd[0]): # assume foomatic: or some such
                add_prnt_args = (self.printer_name.encode('utf8'), self.device_uri, self.print_location, '', self.print_ppd[0], self.print_desc)
            else:
                add_prnt_args = (self.printer_name.encode('utf8'), self.device_uri, self.print_location, self.print_ppd[0], '', self.print_desc)

            status, status_str = cups.cups_operation(cups.addPrinter, GUI_MODE, 'qt4', self, *add_prnt_args)
            log.debug(device.getSupportedCUPSDevices(['hp']))

            if status != cups.IPP_OK:
                QApplication.restoreOverrideCursor()
                FailureUI(self, self.__tr("<b>Printer 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.device_uri, self.printer_name)

        finally:
            QApplication.restoreOverrideCursor()
        return status
Example #5
0
    def setupPrinter(self):
        status = cups.IPP_BAD_REQUEST
        QApplication.setOverrideCursor(QApplication.waitCursor)

        # if self.ppd_file.startswith("foomatic:"):
        if not os.path.exists(self.ppd_file):  # assume foomatic: or some such
            add_prnt_args = (self.printer_name, self.device_uri, self.location, "", self.ppd_file, self.desc)
        else:
            add_prnt_args = (self.printer_name, self.device_uri, self.location, self.ppd_file, "", self.desc)

        status, status_str = cups.cups_operation(cups.addPrinter, GUI_MODE, "qt3", self, *add_prnt_args)

        log.debug("addPrinter() returned (%d, %s)" % (status, status_str))
        log.debug(device.getSupportedCUPSDevices(["hp"]))

        if status != cups.IPP_OK:
            self.FailureUI(self.__tr("<b>Printer 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.device_uri, self.printer_name)

        QApplication.restoreOverrideCursor()
        return status
Example #6
0
    try:
        try:
            from base import password
        except ImportError:
            log.warn("Failed to import Password Object")
        else:
            cups.setPasswordCallback(password.showPasswordPrompt)

        #Removing Queue
        if remove:
            tui.header("REMOVING PRINT/FAX QUEUE")
            sts, printer_name, device_uri = mod.getPrinterName(selected_device_name,None,['hp','hpfax'])
            selected_device_name = printer_name
            log.info (log.bold("Removing '%s : %s' Queue"%(printer_name, device_uri)))

            status, status_str = cups.cups_operation(cups.delPrinter, INTERACTIVE_MODE, '', None, selected_device_name)

            if cups.IPP_OK == status:
                log.info("Successfully deleted %s Print/Fax queue"%selected_device_name)
                utils.sendEvent(EVENT_CUPS_QUEUES_REMOVED,device_uri, printer_name)
                clean_exit(0)
            else:
                log.error("Failed to delete %s Print/Fax queue. Error : %s"%(selected_device_name,status_str))
                clean_exit(1)

        if not auto:
            log.info("(Note: Defaults for each question are maked with a '*'. Press <enter> to accept the default.)")
            log.info("")

        # ******************************* MAKEURI
        if param:
Example #7
0
def reconfigure_Queue(que, mode, dialog=None, app=None):
    global Error_Found
    Error_msg = None
    if mode == INTERACTIVE_MODE:
        if 'hp' in que.DeviceType or 'hpfax' in que.DeviceType:
            if que.PPDFileError == False:
                log.debug("'%s' is configured correctly." % (que.PrinterName))
            else:
                Error_msg = "PPD file for '%s' is not correct. Need to choose correct PPD file." % (
                    que.PrinterName)
        else:
            Error_msg = "'%s' is not configured using HPLIP. Need to remove and re-cofigure using hp-setup." % (
                que.PrinterName)

        if Error_msg != None:
            Error_Found = True
            log.error(Error_msg)
            response, value = tui.enter_yes_no(
                "Do you want to remove and re-configure?")
            if response == False:
                log.debug("User Exit")
                sys.exit(1)
            elif value == True:
                status, status_str = cups.cups_operation(
                    cups.delPrinter, INTERACTIVE_MODE, '', None,
                    que.PrinterName)

                if status != cups.IPP_OK:
                    log.error(
                        "Failed to remove '%s' queue.\nRemove using hp-toolbox."
                        % que.PrinterName)
                else:
                    log.info(
                        "' %s' removed successfully.\nRe-configuring this printer by hp-setup..."
                        % que.PrinterName)
                    if utils.which('hp-setup'):
                        cmd = 'hp-setup -i'
                        os_utils.execute(cmd)

        elif que.IsEnabled == False:
            Error_Found = True
            responce, value = tui.enter_yes_no(
                "'%s Queue is paused. Do you want to enable queue?" %
                (que.PrinterName))
            if responce == False:
                log.debug("User Exit")
                sys.exit(1)
            elif value == True:
                cups.enablePrinter(que.PrinterName)
                log.info("'%s' is enabled successfully" % que.PrinterName)
            else:
                log.info("Manually enable '%s'." % que.PrinterName)
    else:
        if 'hp' in que.DeviceType or 'hpfax' in que.DeviceType:
            if que.PPDFileError == False:
                log.debug("'%s' is configured correctly." % (que.PrinterName))
            else:
                log.error(
                    "PPD file for '%s' is not correct. Need to choose correct PPD file."
                    % (que.PrinterName))
                Error_msg = QUEUES_INCORRECT_PPD
        else:
            log.error(
                "'%s' is not configured using HPLIP. Need to remove and re-cofigure using hp-setup."
                % (que.PrinterName))
            Error_msg = QUEUES_CONFIG_ERROR

        if Error_msg == None and que.IsEnabled == False:
            Error_msg = QUEUES_PAUSED

        if Error_msg and dialog and app:
            Error_Found = True
            dialog.init(que.PrinterName, que.DeviceURI, Error_msg)
            dialog.show()
            log.debug("Starting GUI loop...")
            app.exec_()
Example #8
0
def reconfigure_Queue(que, mode, dialog= None,app=None):
    global Error_Found
    Error_msg =None
    if mode == INTERACTIVE_MODE:
        if 'hp' in que.DeviceType or 'hpfax' in que.DeviceType:
            if que.PPDFileError ==  False:
                log.debug("'%s' is configured correctly." %(que.PrinterName))
            else:
                Error_msg = "PPD file for '%s' is not correct. Need to choose correct PPD file." %(que.PrinterName)
        else:
            Error_msg ="'%s' is not configured using HPLIP. Need to remove and re-cofigure using hp-setup." %(que.PrinterName)


        if Error_msg != None:
            Error_Found = True
            log.error(Error_msg)
            response, value = tui.enter_yes_no("Do you want to remove and re-configure?")
            if response == False:
                log.debug("User Exit")
                sys.exit(1)
            elif value == True:
                status, status_str = cups.cups_operation(cups.delPrinter, INTERACTIVE_MODE, '', None, que.PrinterName)

                if status != cups.IPP_OK:
                    log.error("Failed to remove '%s' queue.\nRemove using hp-toolbox."%que.PrinterName)
                else:
                    log.info("' %s' removed successfully.\nRe-configuring this printer by hp-setup..."%que.PrinterName)
                    if utils.which('hp-setup'):
                        cmd = 'hp-setup -i'
                        os_utils.execute(cmd)

        elif que.IsEnabled == False:
            Error_Found = True
            responce, value =tui.enter_yes_no("'%s Queue is paused. Do you want to enable queue?"%(que.PrinterName))
            if responce == False:
                log.debug("User Exit")
                sys.exit(1)
            elif value == True:
                cups.enablePrinter(que.PrinterName)
                log.info("'%s' is enabled successfully"%que.PrinterName)
            else:
                log.info("Manually enable '%s'."%que.PrinterName)
    else:
        if 'hp' in que.DeviceType or 'hpfax' in que.DeviceType:
            if que.PPDFileError ==  False:
                log.debug("'%s' is configured correctly." %(que.PrinterName))
            else:
                log.error("PPD file for '%s' is not correct. Need to choose correct PPD file." %(que.PrinterName))
                Error_msg = QUEUES_INCORRECT_PPD
        else:
            log.error("'%s' is not configured using HPLIP. Need to remove and re-cofigure using hp-setup." %(que.PrinterName))
            Error_msg =QUEUES_CONFIG_ERROR

        if Error_msg == None and que.IsEnabled == False:
            Error_msg = QUEUES_PAUSED

        if Error_msg and dialog and app:
            Error_Found = True
            dialog.init(que.PrinterName, que.DeviceURI, Error_msg)
            dialog.show()
            log.debug("Starting GUI loop...")
            app.exec_()
Example #9
0
    def NextButton_clicked(self):
        p = self.StackedWidget.currentIndex()
        if p == PAGE_DISCOVERY:
            self.manual = self.ManualGroupBox.isChecked()
            self.param = unicode(self.ManualParamLineEdit.text())
            self.jd_port = self.JetDirectSpinBox.value()
            self.search = unicode(self.SearchLineEdit.text())
            self.device_desc = int(self.DeviceTypeComboBox.itemData(self.DeviceTypeComboBox.currentIndex()).toInt()[0])
            self.discovery_method = self.NetworkDiscoveryMethodComboBox.currentIndex()

            if self.WirelessButton.isChecked():
                dlg = WifiSetupDialog(self, device_uri=None, standalone=False)
                dlg.exec_()

                if dlg.success == SUCCESS_CONNECTED:
                    self.manual = True
                    self.param = dlg.hn
                    self.bus = 'net'
            if not self.WirelessButton.isChecked():
                self.showDevicesPage()
           
        elif p == PAGE_DEVICES:
            row = self.DevicesTableWidget.currentRow()
            self.device_uri = self.DevicesTableWidget.item(row, 0).device_uri
            self.mq = device.queryModelByURI(self.device_uri)
            back_end, is_hp, bus, model, serial, dev_file, host, zc, port = device.parseDeviceURI(self.device_uri)
            self.model = models.normalizeModelName(model).lower()
            self.showAddPrinterPage()

        elif p == PAGE_ADD_PRINTER:
            self.print_test_page = self.SendTestPageCheckBox.isChecked()
            self.print_desc = unicode(self.PrinterDescriptionLineEdit.text()).encode('utf8')
            self.print_location = unicode(self.PrinterLocationLineEdit.text()).encode('utf8')
            self.fax_setup = self.SetupFaxGroupBox.isChecked()
            self.fax_desc = unicode(self.FaxDescriptionLineEdit.text())
            self.fax_location = unicode(self.FaxLocationLineEdit.text())
            self.fax_name_company = unicode(self.NameCompanyLineEdit.text())
            self.fax_number = unicode(self.FaxNumberLineEdit.text())
            self.addPrinter()

        elif p == PAGE_REMOVE:
            for row in xrange(self.RemoveDevicesTableWidget.rowCount()):
                widget = self.RemoveDevicesTableWidget.cellWidget(row, 0)
                if widget.checkState() == Qt.Checked:
                    item = self.RemoveDevicesTableWidget.item(row, 1)
                    printer = unicode(item.data(Qt.UserRole).toString()).encode('utf-8')
                    uri = device.getDeviceURIByPrinterName(printer)
                    log.debug("Removing printer: %s" % printer)
                    status, status_str = cups.cups_operation(cups.delPrinter, GUI_MODE, 'qt4', self, printer)

                    if  status != cups.IPP_OK:
                        FailureUI(self, self.__tr("<b>Unable to delete '%s' queue. </b><p>Error : %s"%(printer,status_str)))
                        if status == cups.IPP_FORBIDDEN or status == cups.IPP_NOT_AUTHENTICATED or status == cups.IPP_NOT_AUTHORIZED:
                            break
                    else:
                        # sending Event to add this device in hp-systray
                        utils.sendEvent(EVENT_CUPS_QUEUES_REMOVED, uri, printer)

            self.close()

        else:
            log.error("Invalid page!") # shouldn't happen!