Ejemplo n.º 1
0
 def check_archive(self):
     self.archive = addon.get_bool_setting('archive')
     if self.archive:
         archive_root = addon.get_setting('archive_root')
         self.archive_root = utils.ensure_trailing_slash(archive_root)
         self.archive_tar_path = None
         self.archive_dir = os.path.join(self.archive_root, str(self.selected_source))
         log.log("Archive builds to " + self.archive_dir)
         if not xbmcvfs.exists(self.archive_root):
             log.log("Unable to access archive")
             utils.ok(L10n(32009), L10n(32010).format(self.archive_root), L10n(32011))
             addon.open_settings()
             sys.exit(1)
         elif not xbmcvfs.mkdir(self.archive_dir):
             log.log("Unable to create directory in archive")
             utils.ok(L10n(32009), L10n(32012).format(self.archive_dir), L10n(32013))
             sys.exit(1)
Ejemplo n.º 2
0
    def maybe_verify(self):
        if not self.verify_files:
            return

        log.log("Verifying update file")
        with closing(tarfile.open(self.update_tar_path, 'r')) as tf:
            tar_names = tf.getnames()

            for update_image in libreelec.UPDATE_IMAGES:
                path_in_tar = next(
                    name for name in tar_names
                    if name.endswith(os.path.join('target', update_image)))
                ti = tf.extractfile(path_in_tar)
                temp_image_path = os.path.join(TEMP_PATH, update_image)
                try:
                    with progress.FileProgress(L10n(32018), ti,
                                               temp_image_path, ti.size,
                                               self.background) as extractor:
                        extractor.start()
                    log.log("Extracted " + temp_image_path)
                except script_exceptions.Canceled:
                    return
                except script_exceptions.WriteError as e:
                    utils.write_error(temp_image_path, str(e))
                    return

                md5sum = tf.extractfile(path_in_tar + '.md5').read().split()[0]
                log.log("{}.md5 file = {}".format(update_image, md5sum))

                if not progress.md5sum_verified(md5sum, temp_image_path,
                                                self.background):
                    log.log("{} md5 mismatch!".format(update_image))
                    utils.ok(
                        L10n(32019).format(update_image),
                        self.selected_build.filename,
                        L10n(32020).format(update_image), L10n(32021))
                    utils.remove_update_files()
                    return
                else:
                    log.log("{} md5 is correct".format(update_image))

                funcs.remove_file(temp_image_path)
Ejemplo n.º 3
0
 def check_archive(self):
     self.archive = addon.get_bool_setting('archive')
     if self.archive:
         archive_root = addon.get_setting('archive_root')
         self.archive_root = utils.ensure_trailing_slash(archive_root)
         self.archive_tar_path = None
         self.archive_dir = os.path.join(self.archive_root,
                                         str(self.selected_source))
         log.log("Archive builds to " + self.archive_dir)
         if not xbmcvfs.exists(self.archive_root):
             log.log("Unable to access archive")
             utils.ok(L10n(32009),
                      L10n(32010).format(self.archive_root), L10n(32011))
             addon.open_settings()
             sys.exit(1)
         elif not xbmcvfs.mkdir(self.archive_dir):
             log.log("Unable to create directory in archive")
             utils.ok(L10n(32009),
                      L10n(32012).format(self.archive_dir), L10n(32013))
             sys.exit(1)
Ejemplo n.º 4
0
    def maybe_verify(self):
        if not self.verify_files:
            return

        log.log("Verifying update file")
        with closing(tarfile.open(self.update_tar_path, 'r')) as tf:
            tar_names = tf.getnames()

            for update_image in openelec.UPDATE_IMAGES:
                path_in_tar = next(name for name in tar_names
                                   if name.endswith(os.path.join('target', update_image)))
                ti = tf.extractfile(path_in_tar)
                temp_image_path = os.path.join(TEMP_PATH, update_image)
                try:
                    with progress.FileProgress(L10n(32018), ti, temp_image_path, ti.size,
                                               self.background) as extractor:
                        extractor.start()
                    log.log("Extracted " + temp_image_path)
                except script_exceptions.Canceled:
                    return
                except script_exceptions.WriteError as e:
                    utils.write_error(temp_image_path, str(e))
                    return

                md5sum = tf.extractfile(path_in_tar + '.md5').read().split()[0]
                log.log("{}.md5 file = {}".format(update_image, md5sum))
        
                if not progress.md5sum_verified(md5sum, temp_image_path,
                                                self.background):
                    log.log("{} md5 mismatch!".format(update_image))
                    utils.ok(L10n(32019).format(update_image),
                             self.selected_build.filename,
                             L10n(32020).format(update_image), L10n(32021))
                    utils.remove_update_files()
                    return
                else:
                    log.log("{} md5 is correct".format(update_image))

                funcs.remove_file(temp_image_path)