main.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:Electrify 作者: jyapayne 项目源码 文件源码
def download_file(self, path, setting):
        version_file = self.settings['base_url'].format(self.selected_version())

        location = self.get_setting('download_dir').value

        versions = re.findall('v(\d+)\.(\d+)\.(\d+)', path)[0]

        self.progress_text = u'Downloading {}'.format(path.replace(version_file, ''))

        path = self.get_redirected_url(path)

        url = QUrl(path)
        file_name = setting.save_file_path(self.selected_version(), location)

        archive_exists = QFile.exists(file_name)

        forced = self.get_setting('force_download').value

        if archive_exists and not forced:
            self.continue_downloading_or_extract()
            return

        self.out_file = QFile(file_name)
        if not self.out_file.open(QIODevice.WriteOnly):
            error = self.out_file.error().name
            self.show_error(u'Unable to save the file {}: {}.'.format(file_name,
                                                                     error))
            self.out_file = None
            self.enable_ui()
            return

        mode = QHttp.ConnectionModeHttps
        port = url.port()

        if port == -1:
            port = 0

        self.http.setHost(url.host(), mode, port)
        self.http_request_aborted = False

        # Download the file.
        self.http_get_id = self.http.get(path, to=self.out_file)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号