コード例 #1
0
ファイル: processfile.py プロジェクト: alkaupp/tifpdf
class Process(QThread):
    """ Process tries to identify paper size, image color and amount of pages.
    It is a QThread for the purpose of avoiding freezing the GUI."""
    processed = Signal(list)

    def __init__(self, filelist, parent=None):
        super(Process, self).__init__(parent)
        self.filelist = filelist
        self.image_data = []
        self.files_not_processed = []
        self.progressbar = Progressbar(len(self.filelist))

    def run(self):
        """ Files are filtered to process_pdf() and process_tif() method which
        will return a list of image data to be appended to self.image_data.
        Files that raised an exception are added into self.files_not_processed
        that will be presented via ErrorDialog."""

        self.progressbar.show()
        progress_counter = 0

        for filePathObj in self.filelist:
            try:
                if filePathObj.lower().endswith('.tif'):
                    self.image_data.append(self.process_tif(filePathObj))
                elif filePathObj.lower().endswith('.pdf'):
                    self.image_data.append(self.process_pdf(filePathObj))

                progress_counter += 1
                self.progressbar.tick(progress_counter)

            except Exception, e:
                print "Virhe tiedostossa:", filePathObj
                self.files_not_processed.append(filePathObj)

        if len(self.files_not_processed) > 0:
            self.error_dialog = ErrorDialog(self.files_not_processed)
            self.error_dialog.exec_()
            self.progressbar.close()

        return self.processed.emit(self.image_data)
コード例 #2
0
ファイル: processfile.py プロジェクト: alkaupp/tifpdf
 def __init__(self, filelist, parent=None):
     super(Process, self).__init__(parent)
     self.filelist = filelist
     self.image_data = []
     self.files_not_processed = []
     self.progressbar = Progressbar(len(self.filelist))