예제 #1
0
    def __download_update(self, game: Game = None) -> None:
        Config.set("current_download", game.id)
        GLib.idle_add(self.__update_to_state, game.state.UPDATE_QUEUED, game)
        download_info = self.api.get_download_info(game)

        # Start the download for all files
        game.downloads = []
        download_path = game.update_path
        finish_func = self.__update
        for key, file_info in enumerate(download_info['files']):
            if key > 0:
                download_path = "{}-{}.bin".format(self.update_path, key)
            download = Download(url=self.api.get_real_download_link(
                file_info["downlink"]),
                                save_location=download_path,
                                finish_func=finish_func,
                                finish_func_args=game,
                                progress_func=self.set_progress,
                                progress_func_args=game,
                                cancel_func=self.__cancel_update,
                                cancel_func_args=game,
                                number=key + 1,
                                out_of_amount=len(download_info['files']))
            game.downloads.append(download)

        DownloadManager.download(game.downloads)
예제 #2
0
    def __download_file(self, game: Game, operating_system=None) -> None:
        Config.set("current_download", game.id)
        GLib.idle_add(self.__update_to_state, game.state.QUEUED, game)

        current_os = platform.system()
        if current_os == "Linux":
            current_os = "linux"
        elif current_os == "Windows":
            current_os = "windows"
        elif current_os == "Darwin":
            current_os = "mac"
        # pick current os if none was passed
        if operating_system is None:
            operating_system = current_os
        if game.platform is None:
            game.platform = operating_system

        download_info = self.api.get_download_info(
            game, operating_system=operating_system)

        # Start the download for all files
        game.downloads = []
        download_path = game.download_path
        finish_func = self.__install
        for key, file_info in enumerate(download_info['files']):
            if key > 0:
                download_path = "{}-{}.bin".format(self.download_path, key)
            download = Download(url=self.api.get_real_download_link(
                file_info["downlink"]),
                                title=download_info["name"],
                                associated_object=game,
                                save_location=download_path,
                                number=key + 1,
                                file_size=download_info["total_size"],
                                out_of_amount=len(download_info['files']))
            download.register_finish_function(finish_func, game)
            download.register_progress_function(self.set_progress, game)
            download.register_cancel_function(self.__cancel_download, game)
            game.downloads.append(download)

        DownloadManager.download(game.downloads)