/usr/share/hplip/ui4/printtestpagedialog.py is in hplip-data 3.14.3-0ubuntu3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 | # -*- coding: utf-8 -*-
#
# (c) Copyright 2001-2008 Hewlett-Packard Development Company, L.P.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# Author: Don Welch
#
# Local
from base.g import *
from base import device
from ui_utils import *
# Qt
from PyQt4.QtCore import *
from PyQt4.QtGui import *
import signal
# Ui
from printtestpagedialog_base import Ui_Dialog
class PrintTestPageDialog(QDialog, Ui_Dialog):
def __init__(self, parent, printer_name):
QDialog.__init__(self, parent)
self.printer_name = printer_name
self.device_uri = ''
self.setupUi(self)
self.initUi()
QTimer.singleShot(0, self.updateUi)
def initUi(self):
#print "PrintTestPageDialog.initUi()"
self.HPLIPTestPageRadioButton.setChecked(True)
self.LoadPaper.setButtonName(self.__tr("Print Test Page"))
self.connect(self.CancelButton, SIGNAL("clicked()"), self.CancelButton_clicked)
self.connect(self.PrintTestpageButton, SIGNAL("clicked()"), self.PrintTestpageButton_clicked)
self.connect(self.PrinterNameCombo, SIGNAL("PrinterNameComboBox_currentChanged"),
self.PrinterNameCombo_currentChanged)
self.connect(self.PrinterNameCombo, SIGNAL("PrinterNameComboBox_noPrinters"),
self.PrinterNameComboBox_noPrinters)
signal.signal(signal.SIGINT, signal.SIG_DFL)
if self.printer_name:
self.PrinterNameCombo.setInitialPrinter(self.printer_name)
# Application icon
self.setWindowIcon(QIcon(load_pixmap('hp_logo', '128x128')))
def updateUi(self):
self.PrinterNameCombo.updateUi()
self.LoadPaper.updateUi()
#self.updatePrintButton()
def PrinterNameComboBox_noPrinters(self):
FailureUI(self, self.__tr("<b>No printers found.</b><p>Please setup a printer and try again."))
self.close()
def updatePrintButton(self):
QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
self.PrintTestpageButton.setEnabled(False)
ok = False
try:
try:
d = device.Device(self.device_uri, self.printer_name)
except Error, e:
log.error("Device error (%s)." % e.msg)
else:
try:
d.open()
except Error:
log.error("Unable to print to printer. Please check device and try again.")
else:
ok = d.isIdleAndNoError()
self.PrintTestpageButton.setEnabled(ok)
if not ok:
QApplication.restoreOverrideCursor()
FailureUI(self, self.__tr("<b>Unable to communicate with printer %1.</b><p>Please check the printer and try again.").arg(self.printer_name))
d.close()
finally:
QApplication.restoreOverrideCursor()
def CancelButton_clicked(self):
self.close()
def PrinterNameCombo_currentChanged(self, device_uri, printer_name):
self.printer_name = printer_name
self.device_uri = device_uri
self.updatePrintButton()
#self.updateUi()
def PrintTestpageButton_clicked(self):
QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
ok = False
try:
try:
d = device.Device(self.device_uri, self.printer_name)
except Error, e:
log.error("Device error (%s)." % e.msg)
else:
try:
d.open()
except Error:
log.error("Unable to print to printer. Please check device and try again.")
else:
ok = d.isIdleAndNoError()
finally:
QApplication.restoreOverrideCursor()
if ok:
QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
try:
d.printTestPage(self.printer_name)
finally:
QApplication.restoreOverrideCursor()
self.close()
else:
FailureUI(self, self.__tr("<b>A error occured sending the test page to printer %1.</b><p>Please check the printer and try again.").arg(self.printer_name))
d.close()
def __tr(self, s, c=None):
return qApp.translate("PrintTestPageDialog", s, c)
|