~ubuntu-branches/ubuntu/vivid/hplip/vivid-security

« back to all changes in this revision

Viewing changes to ui4/printdialog.py

  • Committer: Package Import Robot
  • Author(s): Till Kamppeter
  • Date: 2015-02-04 21:18:00 UTC
  • mfrom: (1.8.2)
  • Revision ID: package-import@ubuntu.com-20150204211800-3ahjuezv75ah97zz
Tags: 3.15.2-0ubuntu1
* New upstream release
  - Python3 support for HPLIP
  - Doesn't build against libjpeg-turbo 1.3.90 (LP: #1388126)
  - hpcups crashes if DEVICE_URI not set in environment (LP: #1395676)
  - Incorrect call to hpmudext.device_open (LP: #1388007)
  - plugin download fails if python links to python3 (LP: #1187055)
  - Incorrect IEEE 1284 Device IDs for many models (LP: #802999)
* debian/patches/85_rebuild_python_ui.dpatch: Manually updated to apply to new
  upstream source code.
* debian/patches/hp_photosmart_pro_b9100_support.dpatch,
  debian/patches/simple-scan-as-default.dpatch,
  debian/patches/hpfax-bug-function-used-before-importing-log.dpatch,
  debian/patches/hp-systray-make-menu-title-visible-in-sni-qt-indicator.dpatch,
  debian/patches/hp-systray-make-menu-appear-in-sni-qt-indicator-with-kde.dpatch,
  debian/patches/hpaio-option-duplex.diff,
  debian/patches/musb-c-do-not-crash-on-usb-failure.patch,
  debian/patches/process-events-for-systray.patch: Refreshed with quilt.
* debian/rules: Force Python3 build using PYTHON=python3 ./configure option
* debian/rules: Use py3versions to get system's Python3 interpreter version
* debian/rules: Use relative symlink for /usr/sbin/hpssd, so that shebang
  correction works.
* debian/rules: Make sure that the Python interpreter paths in all executables
  use python3.
* debian/rules: Use dh_python3 instead of dh_python2.
* debian/control: Replaced all Python-related dependencies by their
  Python3 equivalent.

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
from base import device, utils
26
26
from prnt import cups
27
27
from base.codes import *
28
 
from ui_utils import *
 
28
from .ui_utils import *
29
29
 
30
30
# Qt
31
31
from PyQt4.QtCore import *
32
32
from PyQt4.QtGui import *
33
33
 
34
34
# Ui
35
 
from printdialog_base import Ui_Dialog
36
 
from filetable import FileTable, FILETABLE_TYPE_PRINT
37
 
from printernamecombobox import PRINTERNAMECOMBOBOX_TYPE_PRINTER_ONLY
 
35
from .printdialog_base import Ui_Dialog
 
36
from .filetable import FileTable, FILETABLE_TYPE_PRINT
 
37
from .printernamecombobox import PRINTERNAMECOMBOBOX_TYPE_PRINTER_ONLY
38
38
 
39
39
#signal
40
40
import signal
140
140
            num_files = len(self.Files.file_list)
141
141
 
142
142
            if  num_files > 1:
143
 
                self.NextButton.setText(self.__tr("Print %1 Files").arg(num_files))
 
143
                self.NextButton.setText(self.__tr("Print %s Files"%num_files))
144
144
            else:
145
145
                self.NextButton.setText(self.__tr("Print File"))
146
146
 
173
173
            log.debug(cmd)
174
174
            status, output = utils.run(cmd)
175
175
            if status != 0:
176
 
                FailureUI(self, self.__tr("<b>Print command failed with status code %1.</b><p>%2</p>").arg(status).arg(cmd))
 
176
                FailureUI(self, self.__tr("<b>Print command failed with status code %s.</b><p>%s</p>"%(status,cmd)))
177
177
 
178
178
        self.close()
179
179
        #print file('/home/dwelch/.cups/lpoptions', 'r').read()
207
207
 
208
208
 
209
209
    def updateStepText(self, p):
210
 
        self.StepText.setText(self.__tr("Step %1 of %2").arg(p+1).arg(PAGE_MAX+1))
 
210
        self.StepText.setText(self.__tr("Step %d of %d" %(p+1, PAGE_MAX+1)))
211
211
 
212
212
 
213
213
    def __tr(self,s,c = None):
215
215
 
216
216
 
217
217
 
218
 
"""
219
 
   def printButton_clicked(self):
220
 
        if self.invalid_page_range:
221
 
            self.form.FailureUI(self.__tr("<b>Cannot print: Invalid page range: %1</b><p>A valid page range is a list of pages or ranges of pages separated by commas (e.g., 1-2,4,6-7)").arg(self.pageRangeEdit.text()))
222
 
            return
223
 
 
224
 
        try:
225
 
            try:
226
 
                self.cur_device.open()
227
 
            except Error:
228
 
                self.form.FailureUI(self.__tr("<b>Cannot print: Device is busy or not available.</b><p>Please check device and try again."))
229
 
                return
230
 
 
231
 
            if 1: # Go ahead and allow - print will be queued in CUPS if not rejecting
232
 
                printers = cups.getPrinters()
233
 
                for p in printers:
234
 
                    if p.name == self.cur_printer:
235
 
                        break
236
 
 
237
 
                if p.state == cups.IPP_PRINTER_STATE_STOPPED:
238
 
                    self.form.FailureUI(self.__tr("<b>Cannot print: Printer is stopped.</b><p>Please START the printer to continue this print. Job will begin printing once printer is started."))
239
 
 
240
 
                if not p.accepting:
241
 
                    self.form.FailureUI(self.__tr("<b>Cannot print: Printer is not accepting jobs.</b><p>Please set the printer to ACCEPTING JOBS to continue printing."))
242
 
                    return
243
 
 
244
 
                copies = int(self.copiesSpinBox.value())
245
 
                all_pages = self.pages_button_group == 0
246
 
                page_range = unicode(self.pageRangeEdit.text())
247
 
                page_set = int(self.pageSetComboBox.currentItem())
248
 
 
249
 
                cups.resetOptions()
250
 
                cups.openPPD(self.cur_printer)
251
 
                current_options = dict(cups.getOptions())
252
 
                cups.closePPD()
253
 
 
254
 
                nup = int(current_options.get("number-up", 1))
255
 
 
256
 
                for p, t, d in self.file_list:
257
 
 
258
 
                    alt_nup = (nup > 1 and t == 'application/postscript' and utils.which('psnup'))
259
 
 
260
 
                    if utils.which('lpr'):
261
 
                        if alt_nup:
262
 
                            cmd = ' '.join(['psnup', '-%d' % nup, ''.join(['"', p, '"']), '| lpr -P', self.cur_printer])
263
 
                        else:
264
 
                            cmd = ' '.join(['lpr -P', self.cur_printer])
265
 
 
266
 
                        if copies > 1:
267
 
                            cmd = ' '.join([cmd, '-#%d' % copies])
268
 
 
269
 
                    else:
270
 
                        if alt_nup:
271
 
                            cmd = ' '.join(['psnup', '-%d' % nup, ''.join(['"', p, '"']), '| lp -c -d', self.cur_printer])
272
 
                        else:
273
 
                            cmd = ' '.join(['lp -c -d', self.cur_printer])
274
 
 
275
 
                        if copies > 1:
276
 
                            cmd = ' '.join([cmd, '-n%d' % copies])
277
 
 
278
 
 
279
 
                    if not all_pages and len(page_range) > 0:
280
 
                        cmd = ' '.join([cmd, '-o page-ranges=%s' % page_range])
281
 
 
282
 
                    if page_set > 0:
283
 
                        if page_set == 1:
284
 
                            cmd = ' '.join([cmd, '-o page-set=even'])
285
 
                        else:
286
 
                            cmd = ' '.join([cmd, '-o page-set=odd'])
287
 
 
288
 
 
289
 
                    # Job Storage
290
 
                    # self.job_storage_mode = (0=Off, 1=P&H, 2=PJ, 3=QC, 4=SJ)
291
 
                    # self.job_storage_pin = u"" (dddd)
292
 
                    # self.job_storage_use_pin = True|False
293
 
                    # self.job_storage_username = u""
294
 
                    # self.job_storage_auto_username = True|False
295
 
                    # self.job_storage_jobname = u""
296
 
                    # self.job_storage_auto_jobname = True|False
297
 
                    # self.job_storage_job_exist = (0=replace, 1=job name+(1-99))
298
 
 
299
 
                    if self.job_storage_avail:
300
 
                        if self.job_storage_mode: # On
301
 
 
302
 
                            if self.job_storage_mode == 1: # Proof and Hold
303
 
                                cmd = ' '.join([cmd, '-o HOLD=PROOF'])
304
 
 
305
 
                            elif self.job_storage_mode == 2: # Private Job
306
 
                                if self.job_storage_use_pin:
307
 
                                    cmd = ' '.join([cmd, '-o HOLD=ON'])
308
 
                                    cmd = ' '.join([cmd, '-o HOLDTYPE=PRIVATE'])
309
 
                                    cmd = ' '.join([cmd, '-o HOLDKEY=%s' % self.job_storage_pin.encode('ascii')])
310
 
                                else:
311
 
                                    cmd = ' '.join([cmd, '-o HOLD=PROOF'])
312
 
                                    cmd = ' '.join([cmd, '-o HOLDTYPE=PRIVATE'])
313
 
 
314
 
                            elif self.job_storage_mode == 3: # Quick Copy
315
 
                                cmd = ' '.join([cmd, '-o HOLD=ON'])
316
 
                                cmd = ' '.join([cmd, '-o HOLDTYPE=PUBLIC'])
317
 
 
318
 
                            elif self.job_storage_mode == 4: # Store Job
319
 
                                if self.job_storage_use_pin:
320
 
                                    cmd = ' '.join([cmd, '-o HOLD=STORE'])
321
 
                                    cmd = ' '.join([cmd, '-o HOLDTYPE=PRIVATE'])
322
 
                                    cmd = ' '.join([cmd, '-o HOLDKEY=%s' % self.job_storage_pin.encode('ascii')])
323
 
                                else:
324
 
                                    cmd = ' '.join([cmd, '-o HOLD=STORE'])
325
 
 
326
 
                            cmd = ' '.join([cmd, '-o USERNAME=%s' % self.job_storage_username.encode('ascii')\
327
 
                                .replace(" ", "_")])
328
 
 
329
 
                            cmd = ' '.join([cmd, '-o JOBNAME=%s' % self.job_storage_jobname.encode('ascii')\
330
 
                                .replace(" ", "_")])
331
 
 
332
 
                            if self.job_storage_job_exist == 1:
333
 
                                cmd = ' '.join([cmd, '-o DUPLICATEJOB=APPEND'])
334
 
                            else:
335
 
                                cmd = ' '.join([cmd, '-o DUPLICATEJOB=REPLACE'])
336
 
 
337
 
                        else: # Off
338
 
                            cmd = ' '.join([cmd, '-o HOLD=OFF'])
339
 
 
340
 
 
341
 
                    if not alt_nup:
342
 
                        cmd = ''.join([cmd, ' "', p, '"'])
343
 
 
344
 
                    log.debug("Printing: %s" % cmd)
345
 
 
346
 
                    code = os.system(cmd)
347
 
                    if code != 0:
348
 
                        log.error("Print command failed.")
349
 
                        self.form.FailureUI(self.__tr("Print command failed with error code %1").arg(code))
350
 
 
351
 
                self.form.close()
352
 
 
353
 
        finally:
354
 
            self.cur_device.close()
355
 
 
356
 
"""