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

« back to all changes in this revision

Viewing changes to ui4/filetable.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:
24
24
import sys
25
25
import os.path
26
26
import os
 
27
import subprocess
27
28
 
28
29
# Local
29
30
from base.g import *
30
31
from base import utils, magic
31
32
from prnt import cups
32
33
from base.codes import *
33
 
from ui_utils import *
34
 
 
 
34
from .ui_utils import *
 
35
from base.sixext import to_unicode, to_string_utf8
35
36
# Qt
36
37
from PyQt4.QtCore import *
37
38
from PyQt4.QtGui import *
38
39
 
39
40
# Other UI
40
 
from mimetypesdialog import MimeTypesDialog
 
41
from .mimetypesdialog import MimeTypesDialog
41
42
 
42
43
 
43
44
FILETABLE_TYPE_PRINT = 0
175
176
                        # Filename (basename)
176
177
                        i = QTableWidgetItem(os.path.basename(filename))
177
178
 
178
 
                    i.setData(Qt.UserRole, QVariant(filename))
 
179
                    i.setData(Qt.UserRole, to_unicode(filename))
179
180
                    i.setFlags(flags)
180
181
 
181
182
                    if self.selected_filename is not None and \
203
204
                        if num_pages < 1:
204
205
                            i = QTableWidgetItem(self.__tr("(unknown)"))
205
206
                        else:
206
 
                            i = QTableWidgetItem(unicode(num_pages))
 
207
                            i = QTableWidgetItem(to_unicode(num_pages))
207
208
                        i.setFlags(flags)
208
209
                        self.FileTable.setItem(row, col, i)
209
210
                        col += 1
262
263
        if self.typ == FILETABLE_TYPE_PRINT:
263
264
            s = self.__tr("Select File(s) to Print")
264
265
        else:
 
266
            stat = ''
 
267
            try :
 
268
                p = subprocess.Popen('getenforce', stdout=subprocess.PIPE, stderr=subprocess.PIPE)
 
269
                stat, err = p.communicate()
 
270
                stat = to_string_utf8(stat)
 
271
            except OSError :
 
272
                pass
 
273
            except :
 
274
                log.exception()
 
275
            if stat.strip('\n') == 'Enforcing' :
 
276
                FailureUI(self, self.__tr("<b>Unable to add file. Please disable SeLinux.</b><p>Either disable it manually or run hp-doctor from terminal.</p>"),
 
277
                    self.__tr("HP Device Manager"))
 
278
                return
 
279
 
265
280
            s = self.__tr("Select File(s) to Send")
266
281
 
267
282
        files = list(QFileDialog.getOpenFileNames(self, s,
268
283
            self.working_dir, self.__tr("All files (*)")))
269
284
 
270
 
        files = [unicode(f) for f in files]
 
285
        files = [to_unicode(f) for f in files]
271
286
 
272
287
        if files:
273
288
            self.addFileList(files)
294
309
                mime_type_desc = MIME_TYPES_DESC[mime_type][0]
295
310
            except KeyError:
296
311
                if self.typ == FILETABLE_TYPE_PRINT:
297
 
                    FailureUI(self, self.__tr("<b>You are trying to add a file '%1' that cannot be directly printed with this utility.</b><p>To print this file, use the print command in the application that created it.<p>Note: Click <i>Show Valid Types...</i> to view a list of compatible file types that can be directly printed from this utility.").arg(f),
 
312
                    FailureUI(self, self.__tr("<b>You are trying to add a file '%s' that cannot be directly printed with this utility.</b><p>To print this file, use the print command in the application that created it.<p>Note: Click <i>Show Valid Types...</i> to view a list of compatible file types that can be directly printed from this utility."%f),
298
313
                        self.__tr("HP Device Manager"))
299
314
                else:
300
 
                    FailureUI(self, self.__tr("<b>You are trying to add a file '%1' that cannot be directly faxed with this utility.</b><p>To fax this file, use the print command in the application that created it (using the appropriate fax print queue).<p>Note: Click <i>Show Valid Types...</i> to view a list of compatible file types that can be directly added to the fax file list in this utility.").arg(f),
 
315
                    FailureUI(self, self.__tr("<b>You are trying to add a file '%s' that cannot be directly faxed with this utility.</b><p>To fax this file, use the print command in the application that created it (using the appropriate fax print queue).<p>Note: Click <i>Show Valid Types...</i> to view a list of compatible file types that can be directly added to the fax file list in this utility."%f),
301
316
                        self.__tr("HP Device Manager"))
302
317
            else:
303
318
                if self.typ == FILETABLE_TYPE_PRINT:
305
320
                else:
306
321
                    self.fax_add_callback(f)
307
322
        else:
308
 
            FailureUI(self, self.__tr("<b>Unable to add file '%1' to file list (file not found or insufficient permissions).</b><p>Check the file name and try again.").arg(f),
 
323
            FailureUI(self, self.__tr("<b>Unable to add file '%s' to file list (file not found or insufficient permissions).</b><p>Check the file name and try again."%f),
309
324
                self.__tr("HP Device Manager"))
310
325
 
311
326
 
320
335
        i = self.FileTable.item(self.FileTable.currentRow(), 0)
321
336
        if i is None:
322
337
            return None
323
 
        return i.data(Qt.UserRole).toString()
 
338
        return value_str(i.data(Qt.UserRole))
324
339
 
325
340
 
326
341
    def RemoveFileButton_clicked(self):
395
410
 
396
411
 
397
412
    def FileTable_customContextMenuRequested(self, p):
398
 
        print p
 
413
        print(p)
399
414
 
400
415
 
401
416
    def __tr(self,s,c = None):