def FaxComboBox_currentChanged(self, device_uri): self.device_uri = device_uri self.updateCoverpageTab() if self.dev is not None: self.dev.close() try: self.dev = fax.getFaxDevice(self.device_uri) except Error: CheckDeviceUI(self) return self.updateHeaderTab()
if user_input == 'q': log.info("OK, done.") clean_exit(0) if not user_input: user_input = 'y' setup_fax = (user_input == 'y') if user_input in ('y', 'n', 'q'): break log.error("Please enter 'y' or 'n'") if setup_fax: d = fax.getFaxDevice(fax_uri, disable_dbus=True) try: d.open() except Error: log.error("Unable to communicate with the device. Please check the device and try again.") else: try: tries = 0 ok = True while True: tries += 1 try: current_phone_num = str(d.getPhoneNum())
def readwriteFaxInformation(self, read=True): try: QApplication.setOverrideCursor(QCursor(Qt.WaitCursor)) d = fax.getFaxDevice(self.fax_uri, disable_dbus=True) while True: try: d.open() except Error: error_text = self.__tr("Unable to communicate with the device. Please check the device and try again.") log.error(unicode(error_text)) if QMessageBox.critical(self, self.windowTitle(), error_text, QMessageBox.Retry | QMessageBox.Default, QMessageBox.Cancel | QMessageBox.Escape, QMessageBox.NoButton) == QMessageBox.Cancel: break else: try: tries = 0 ok = True while True: tries += 1 try: if read: self.fax_number = unicode(d.getPhoneNum()) self.fax_name_company = unicode(d.getStationName()) else: d.setStationName(self.fax_name_company) d.setPhoneNum(self.fax_number) except Error: error_text = self.__tr("<b>Device I/O Error</b><p>Could not communicate with device. Device may be busy.") log.error(unicode(error_text)) if QMessageBox.critical(self, self.windowTitle(), error_text, QMessageBox.Retry | QMessageBox.Default, QMessageBox.Cancel | QMessageBox.Escape, QMessageBox.NoButton) == QMessageBox.Cancel: break time.sleep(5) ok = False if tries > 12: break else: ok = True break finally: d.close() if ok and read: self.FaxNumberLineEdit.setText(self.fax_number) self.NameCompanyLineEdit.setText(self.fax_name_company) break finally: QApplication.restoreOverrideCursor()
log.debug("Magic=%s Ver=%d Pages=%d hDPI=%d vDPI=%d Size=%d Res=%d Enc=%d" % (mg, version, total_pages, hort_dpi, vert_dpi, page_size, resolution, encoding)) file_list.append((fax_file, mime_type, "", title, total_pages)) f.close() # # Insure that the device is in an OK state # dev = None log.debug("\nChecking device state...") try: dev = fax.getFaxDevice(device_uri, printer_name) try: dev.open() except Error as e: log.warn(e.msg) try: dev.queryDevice(quick=True) except Error as e: log.error("Query device error (%s)." % e.msg) dev.error_state = ERROR_STATE_ERROR if dev.error_state > ERROR_STATE_MAX_OK and \ dev.error_state not in (ERROR_STATE_LOW_SUPPLIES, ERROR_STATE_LOW_PAPER):
def executeSendFax(self): self.NextButton.setEnabled(False) self.BackButton.setEnabled(False) self.CheckTimer.stop() self.busy = True phone_num_list = [] ppd_file = cups.getPPD(self.printer_name) if ppd_file is not None and os.path.exists(ppd_file): if open(ppd_file, 'rb').read().find(b'HP Fax') == -1: FailureUI( self, self.__tr( "<b>Fax configuration error.</b><p>The CUPS fax queue for '%s' is incorrectly configured.<p>Please make sure that the CUPS fax queue is configured with the 'HPLIP Fax' Model/Driver." % self.printer_name)) self.close() return beginWaitCursor() mq = device.queryModelByURI(self.device_uri) self.dev = fax.getFaxDevice(self.device_uri, self.printer_name, None, mq['fax-type']) try: try: self.dev.open() except Error as e: log.warn(e.msg) try: self.dev.queryDevice(quick=True) except Error as e: log.error("Query device error (%s)." % e.msg) self.dev.error_state = ERROR_STATE_ERROR finally: self.dev.close() endWaitCursor() if self.dev.error_state > ERROR_STATE_MAX_OK and \ self.dev.error_state not in (ERROR_STATE_LOW_SUPPLIES, ERROR_STATE_LOW_PAPER): FailureUI( self, self.__tr( "<b>Device is busy or in an error state (code=%s)</b><p>Please wait for the device to become idle or clear the error and try again." % self.dev.status_code)) self.NextButton.setEnabled(True) return # Check to make sure queue in CUPS is idle self.cups_printers = cups.getPrinters() for p in self.cups_printers: if p.name == self.printer_name: if p.state == cups.IPP_PRINTER_STATE_STOPPED: FailureUI( self, self.__tr( "<b>The CUPS queue for '%s' is in a stopped or busy state.</b><p>Please check the queue and try again." % self.printer_name)) self.NextButton.setEnabled(False) return break log.debug("Recipient list:") for p in self.recipient_list: entry = self.db.get(p) phone_num_list.append(entry) log.debug("Name=%s Number=%s" % (entry["name"], entry["fax"])) log.debug("File list:") for f in self.file_list: log.debug(f) self.dev.sendEvent(EVENT_START_FAX_JOB, self.printer_name, 0, '') if not self.dev.sendFaxes( phone_num_list, self.file_list, self.cover_page_message, self.cover_page_re, self.cover_page_func, self.preserve_formatting, self.printer_name, self.update_queue, self.event_queue): FailureUI( self, self.__tr( "<b>Send fax is active.</b><p>Please wait for operation to complete." )) self.dev.sendEvent(EVENT_FAX_JOB_FAIL, self.printer_name, 0, '') self.busy = False self.send_fax_active = False #self.NextButton.setEnabled(False) self.setCancelCloseButton() return self.send_fax_active = True self.setCancelCloseButton() self.SendFaxTimer = QTimer(self) self.connect(self.SendFaxTimer, SIGNAL('timeout()'), self.SendFaxTimer_timeout) self.SendFaxTimer.start(1000) # 1 sec UI updates
def readwriteFaxInformation(self, read=True): try: QApplication.setOverrideCursor(QApplication.waitCursor) d = fax.getFaxDevice(self.fax_uri, disable_dbus=True) while True: try: d.open() except Error: error_text = self.__tr("Unable to communicate with the device. Please check the device and try again.") log.error(unicode(error_text)) if QMessageBox.critical(self, self.caption(), error_text, QMessageBox.Retry | QMessageBox.Default, QMessageBox.Cancel | QMessageBox.Escape, QMessageBox.NoButton) == QMessageBox.Cancel: break else: try: tries = 0 ok = True while True: tries += 1 try: if read: self.fax_number = unicode(d.getPhoneNum()) self.fax_name_company = unicode(d.getStationName()) else: d.setStationName(self.fax_name_company) d.setPhoneNum(self.fax_number) except Error: error_text = self.__tr("<b>Device I/O Error</b><p>Could not communicate with device. Device may be busy.") log.error(unicode(error_text)) if QMessageBox.critical(self, self.caption(), error_text, QMessageBox.Retry | QMessageBox.Default, QMessageBox.Cancel | QMessageBox.Escape, QMessageBox.NoButton) == QMessageBox.Cancel: break time.sleep(5) ok = False if tries > 12: break else: ok = True break finally: d.close() if ok and read: self.faxNumberLineEdit.setText(self.fax_number) self.faxNameCoLineEdit.setText(self.fax_name_company) break finally: QApplication.restoreOverrideCursor()
def executeSendFax(self): self.NextButton.setEnabled(False) self.BackButton.setEnabled(False) self.CheckTimer.stop() self.busy = True phone_num_list = [] ppd_file = cups.getPPD(self.printer_name) if ppd_file is not None and os.path.exists(ppd_file): if open(ppd_file, 'rb').read().find(b'HP Fax') == -1: FailureUI(self, self.__tr("<b>Fax configuration error.</b><p>The CUPS fax queue for '%s' is incorrectly configured.<p>Please make sure that the CUPS fax queue is configured with the 'HPLIP Fax' Model/Driver."%self.printer_name)) self.close() return beginWaitCursor() mq = device.queryModelByURI(self.device_uri) self.dev = fax.getFaxDevice(self.device_uri, self.printer_name, None, mq['fax-type']) try: try: self.dev.open() except Error as e: log.warn(e.msg) try: self.dev.queryDevice(quick=True) except Error as e: log.error("Query device error (%s)." % e.msg) self.dev.error_state = ERROR_STATE_ERROR finally: self.dev.close() endWaitCursor() if self.dev.error_state > ERROR_STATE_MAX_OK and \ self.dev.error_state not in (ERROR_STATE_LOW_SUPPLIES, ERROR_STATE_LOW_PAPER): FailureUI(self, self.__tr("<b>Device is busy or in an error state (code=%s)</b><p>Please wait for the device to become idle or clear the error and try again."%self.dev.status_code)) self.NextButton.setEnabled(True) return # Check to make sure queue in CUPS is idle self.cups_printers = cups.getPrinters() for p in self.cups_printers: if p.name == self.printer_name: if p.state == cups.IPP_PRINTER_STATE_STOPPED: FailureUI(self, self.__tr("<b>The CUPS queue for '%s' is in a stopped or busy state.</b><p>Please check the queue and try again."%self.printer_name)) self.NextButton.setEnabled(False) return break log.debug("Recipient list:") for p in self.recipient_list: entry = self.db.get(p) phone_num_list.append(entry) log.debug("Name=%s Number=%s" % (entry["name"], entry["fax"])) log.debug("File list:") for f in self.file_list: log.debug(f) self.dev.sendEvent(EVENT_START_FAX_JOB, self.printer_name, 0, '') if not self.dev.sendFaxes(phone_num_list, self.file_list, self.cover_page_message, self.cover_page_re, self.cover_page_func, self.preserve_formatting, self.printer_name, self.update_queue, self.event_queue): FailureUI(self, self.__tr("<b>Send fax is active.</b><p>Please wait for operation to complete.")) self.dev.sendEvent(EVENT_FAX_JOB_FAIL, self.printer_name, 0, '') self.busy = False self.send_fax_active = False #self.NextButton.setEnabled(False) self.setCancelCloseButton() return self.send_fax_active = True self.setCancelCloseButton() self.SendFaxTimer = QTimer(self) self.connect(self.SendFaxTimer, SIGNAL('timeout()'), self.SendFaxTimer_timeout) self.SendFaxTimer.start(1000) # 1 sec UI updates
def faxButton_clicked(self): self.check_timer.stop() phone_num_list = [] log.debug("Current printer=%s" % self.cur_printer) ppd_file = cups.getPPD(self.cur_printer) if ppd_file is not None and os.path.exists(ppd_file): if file(ppd_file, 'r').read().find('HP Fax') == -1: self.form.FailureUI(self.__tr("<b>Fax configuration error.</b><p>The CUPS fax queue for '%1' is incorrectly configured.<p>Please make sure that the CUPS fax queue is configured with the 'HPLIP Fax' Model/Driver.").arg(self.cur_printer)) return QApplication.setOverrideCursor(QApplication.waitCursor) self.dev = fax.getFaxDevice(self.cur_device.device_uri, self.cur_printer, None, self.cur_device.mq['fax-type']) try: try: self.dev.open() except Error as e: log.warn(e.msg) try: self.dev.queryDevice(quick=True) except Error as e: log.error("Query device error (%s)." % e.msg) self.dev.error_state = ERROR_STATE_ERROR finally: self.dev.close() QApplication.restoreOverrideCursor() if self.dev.error_state > ERROR_STATE_MAX_OK and \ self.dev.error_state not in (ERROR_STATE_LOW_SUPPLIES, ERROR_STATE_LOW_PAPER): self.form.FailureUI(self.__tr("<b>Device is busy or in an error state (code=%1)</b><p>Please wait for the device to become idle or clear the error and try again.").arg(self.cur_device.status_code)) return # Check to make sure queue in CUPS is idle self.cups_printers = cups.getPrinters() for p in self.cups_printers: if p.name == self.cur_printer: if p.state == cups.IPP_PRINTER_STATE_STOPPED: self.form.FailureUI(self.__tr("<b>The CUPS queue for '%1' is in a stopped or busy state.</b><p>Please check the queue and try again.").arg(self.cur_printer)) return break log.debug("Recipient list:") for p in self.recipient_list: entry = self.db.get(p) phone_num_list.append(entry) log.debug("Name=%s Number=%s" % (entry["name"], entry["fax"])) log.debug("File list:") for f in self.file_list: log.debug(to_unicode(f)) self.busy = True self.dev.sendEvent(EVENT_START_FAX_JOB, self.cur_printer, 0, '') if not self.dev.sendFaxes(phone_num_list, self.file_list, self.cover_page_message, self.cover_page_re, self.cover_page_func, self.preserve_formatting, self.cur_printer, self.update_queue, self.event_queue): self.form.FailureUI(self.__tr("<b>Send fax is active.</b><p>Please wait for operation to complete.")) self.dev.sendEvent(EVENT_FAX_JOB_FAIL, self.cur_printer, 0, '') self.busy = False return self.waitdlg = WaitForm(0, self.__tr("Initializing..."), self.send_fax_canceled, self, modal=1) self.waitdlg.show() self.send_fax_timer = QTimer(self, "SendFaxTimer") self.connect(self.send_fax_timer, SIGNAL('timeout()'), self.send_fax_timer_timeout) self.send_fax_timer.start(1000) # 1 sec UI updates