Esempio n. 1
0
    def download(self):
        """Download Files.   """

        if self.is_downloading:
            return
        self.is_downloading = True
        self.buttonBox.setEnabled(False)

        try:
            is_skip_same = self.checkBoxSkipSame.isChecked()
            pool = Pool()
            for i in progress(self.files, '下载文件', parent=self):
                result = pool.apply_async(i.download,
                                          (Path(self.dir) / Path(i).name, ),
                                          dict(is_skip_same=is_skip_same))
                while not result.ready():
                    QCoreApplication.processEvents()
                if not result.successful():
                    raise RuntimeError('Download failed', i)
        finally:
            self.is_downloading = False
            self.buttonBox.setEnabled(True)
 def write(self, text):
     if not self.skip:
         stripped_text = text.rstrip('\n')
         self.write_fn(stripped_text)
         QCoreApplication.processEvents()
     self.skip = not self.skip