2 # -*- coding: utf-8 -*-
4 # (c) Copyright 2003-2008 Hewlett-Packard Development Company, L.P.
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 __title__ = 'Printer Cartridge Cleaning Utility'
26 __doc__ = "Cartridge cleaning utility for HPLIP supported inkjet printers."
38 from base import device, utils, maint, tui, module
44 ok = tui.continue_prompt("Ready to perform level %d cleaning (Note: Wait for previous print to finish)." % level)
60 if d.isIdleAndNoError():
67 log.error("Timeout waiting for print to finish.")
78 log.note("Please wait for page to complete printing before continuing.")
79 log.info("\nLevel 1 cleaning complete. If the printout looks OK, enter 'q' to quit or <enter> to do a level 2 cleaning.")
84 log.note("Please wait for page to complete printing before continuing.")
85 log.info("\nLevel 2 cleaning complete. If the printout looks OK, enter 'q' to quit or <enter> to do a level 3 cleaning.")
86 log.warn("Level 3 uses a lot of ink.")
90 log.info("\nLevel 3 cleaning complete. Check this page to see if the problem was fixed. If the test page was not printed OK, replace the print cartridge(s).")
94 mod = module.Module(__mod__, __title__, __version__, __doc__, None,
95 (INTERACTIVE_MODE, GUI_MODE), (UI_TOOLKIT_QT4,))
97 mod.setUsage(module.USAGE_FLAG_DEVICE_ARGS,
98 see_also_list=['hp-align', 'hp-clean', 'hp-linefeedcal',
101 opts, device_uri, printer_name, mode, ui_toolkit, lang = \
104 device_uri = mod.getDeviceUri(device_uri, printer_name,
105 filter={'clean-type': (operator.ne, CLEAN_TYPE_NONE)})
108 if not utils.canEnterGUIMode4():
109 log.error("%s -u/--gui requires Qt4 GUI support. Entering interactive mode." % __mod__)
110 mode = INTERACTIVE_MODE
112 if mode == INTERACTIVE_MODE:
114 d = device.Device(device_uri, printer_name)
116 log.error("Unable to open device: %s" % e.msg)
123 log.error("Unable to print to printer. Please check device and try again.")
126 if d.isIdleAndNoError():
127 clean_type = d.mq.get('clean-type', CLEAN_TYPE_NONE)
128 log.debug("Clean type=%d" % clean_type)
132 if clean_type == CLEAN_TYPE_UNSUPPORTED:
133 log.error("Cleaning through HPLIP not supported for this printer. Please use the printer's front panel to perform cartridge cleaning.")
135 elif clean_type == CLEAN_TYPE_PCL:
136 maint.cleaning(d, clean_type, maint.cleanType1, maint.primeType1,
137 maint.wipeAndSpitType1, tui.load_paper_prompt,
138 CleanUI1, CleanUI2, CleanUI3,
141 elif clean_type == CLEAN_TYPE_LIDIL:
142 maint.cleaning(d, clean_type, maint.cleanType2, maint.primeType2,
143 maint.wipeAndSpitType2, tui.load_paper_prompt,
144 CleanUI1, CleanUI2, CleanUI3,
147 elif clean_type == CLEAN_TYPE_PCL_WITH_PRINTOUT:
148 maint.cleaning(d, clean_type, maint.cleanType1, maint.primeType1,
149 maint.wipeAndSpitType1, tui.load_paper_prompt,
150 CleanUI1, CleanUI2, CleanUI3,
154 log.error("Cleaning not needed or supported on this device.")
157 log.error("An error occured: %s" % e[0])
160 log.error("Device is busy or in an error state. Please check device and try again.")
167 from PyQt4.QtGui import QApplication
168 from ui4.cleandialog import CleanDialog
170 log.error("Unable to load Qt4 support. Is it installed?")
176 app = QApplication(sys.argv)
178 dlg = CleanDialog(None, device_uri)
181 log.debug("Starting GUI loop...")
183 except KeyboardInterrupt:
190 except KeyboardInterrupt:
191 log.error("User exit")