def select_build(self): build_select = gui.BuildSelectDialog(self.installed_build) build_select.doModal() self.selected_source = build_select.selected_source addon.set_setting('source_name', self.selected_source) log.log("Selected source: " + str(self.selected_source)) if not build_select: log.log("No build selected") sys.exit(0) selected_build = build_select.selected_build log.log("Selected build: " + str(selected_build)) build_str = utils.format_build(selected_build) msg = L10n(32003).format(utils.format_build(self.installed_build), build_str) if selected_build < self.installed_build: args = (L10n(32004), L10n(32005), msg) elif selected_build > self.installed_build: args = (L10n(32001), L10n(32002), msg) else: msg = L10n(32007).format(build_str) args = (L10n(32006), msg, L10n(32008)) if not utils.yesno(*args): sys.exit(0) self.selected_build = selected_build
def maybe_download(self): try: remote_file = self.selected_build.remote_file() except requests.RequestException as e: utils.url_error(self.selected_build.url, str(e)) sys.exit(1) filename = self.selected_build.filename tar_name = self.selected_build.tar_name size = self.selected_build.size self.download_path = os.path.join(TEMP_PATH, filename) self.temp_tar_path = os.path.join(TEMP_PATH, tar_name) self.update_tar_path = os.path.join(libreelec.UPDATE_DIR, tar_name) if self.archive: self.archive_tar_path = os.path.join(self.archive_dir, tar_name) if not self.copy_from_archive(): if (os.path.isfile(self.download_path) and os.path.getsize(self.download_path) == size): # Skip the download if the file exists with the correct size. log.log("Skipping download") else: try: log.log("Starting download of {} to {}".format( self.selected_build.url, self.download_path)) with progress.FileProgress(L10n(32014), remote_file, self.download_path, size, self.background) as downloader: downloader.start() log.log("Completed download") except script_exceptions.Canceled: sys.exit(0) except requests.RequestException as e: utils.url_error(self.selected_build.url, str(e)) sys.exit(1) except script_exceptions.WriteError as e: utils.write_error(self.download_path, str(e)) sys.exit(1) if self.selected_build.compressed: try: bf = open(self.download_path, 'rb') log.log("Starting decompression of " + self.download_path) with progress.DecompressProgress( L10n(32015), bf, self.temp_tar_path, size, self.background) as decompressor: decompressor.start() log.log("Completed decompression") except script_exceptions.Canceled: sys.exit(0) except script_exceptions.WriteError as e: utils.write_error(self.temp_tar_path, str(e)) sys.exit(1) except script_exceptions.DecompressError as e: utils.decompress_error(self.download_path, str(e)) sys.exit(1) finally: funcs.remove_file(self.download_path) self.maybe_copy_to_archive() log.log("Moving tar file to " + self.update_tar_path) os.renames(self.temp_tar_path, self.update_tar_path) addon.set_setting('update_pending', 'true')
def maybe_download(self): try: remote_file = self.selected_build.remote_file() except requests.RequestException as e: utils.url_error(self.selected_build.url, str(e)) sys.exit(1) filename = self.selected_build.filename tar_name = self.selected_build.tar_name size = self.selected_build.size self.download_path = os.path.join(TEMP_PATH, filename) self.temp_tar_path = os.path.join(TEMP_PATH, tar_name) self.update_tar_path = os.path.join(openelec.UPDATE_DIR, tar_name) if self.archive: self.archive_tar_path = os.path.join(self.archive_dir, tar_name) if not self.copy_from_archive(): if (os.path.isfile(self.download_path) and os.path.getsize(self.download_path) == size): # Skip the download if the file exists with the correct size. log.log("Skipping download") else: try: log.log("Starting download of {} to {}".format(self.selected_build.url, self.download_path)) with progress.FileProgress(L10n(32014), remote_file, self.download_path, size, self.background) as downloader: downloader.start() log.log("Completed download") except script_exceptions.Canceled: sys.exit(0) except requests.RequestException as e: utils.url_error(self.selected_build.url, str(e)) sys.exit(1) except script_exceptions.WriteError as e: utils.write_error(self.download_path, str(e)) sys.exit(1) if self.selected_build.compressed: try: bf = open(self.download_path, 'rb') log.log("Starting decompression of " + self.download_path) with progress.DecompressProgress(L10n(32015), bf, self.temp_tar_path, size, self.background) as decompressor: decompressor.start() log.log("Completed decompression") except script_exceptions.Canceled: sys.exit(0) except script_exceptions.WriteError as e: utils.write_error(self.temp_tar_path, str(e)) sys.exit(1) except script_exceptions.DecompressError as e: utils.decompress_error(self.download_path, str(e)) sys.exit(1) finally: funcs.remove_file(self.download_path) self.maybe_copy_to_archive() log.log("Moving tar file to " + self.update_tar_path) os.renames(self.temp_tar_path, self.update_tar_path) addon.set_setting('update_pending', 'true')