コード例 #1
0
ファイル: update.py プロジェクト: cburgmer/eclectus
    def downloadPage(self):
        tempFile = KTemporaryFile()
        tempFile.setPrefix('eclectus/' + self.DOWNLOADER_NAME + '_downloadpage')
        tempFileName = tempFile.fileName()

        if KIO.NetAccess.download(KUrl(self.getDownloadPageLink()),
            tempFileName, self.parentWidget):
            self.lastError = None

            try:
                f = codecs.open(tempFileName, 'r', 'utf8')
                self.downloadPageContent = f.read()
                f.close()
            except IOError, e:
                self.lastError = unicode(e)
                return False

            return True
コード例 #2
0
ファイル: update.py プロジェクト: cburgmer/eclectus
    def download(self):
        tempFile = KTemporaryFile()
        tempFile.setAutoRemove(False)
        tempFile.setPrefix('eclectus/' + self.DOWNLOADER_NAME)
        tempFileName = tempFile.fileName()

        if KIO.NetAccess.download(KUrl(self.getDownloadLink()), tempFileName,
            self.parentWidget):
            self.lastError = None

            _, _, onlinePath, _, _ = urlparse.urlsplit(
                self.getDownloadLink())
            fileType = None
            matchObj = re.search('\.(zip|tar|tar\.bz2|tar\.gz|gz|txt)$',
                onlinePath)
            if matchObj:
                fileType = matchObj.group(0)

            return tempFileName, fileType
        else:
            self.lastError = unicode(KIO.NetAccess.lastErrorString())
            return None, None