[PATCH 08/10] DNFPayload: initial version.

Vratislav Podzimek vpodzime at redhat.com
Mon Aug 19 16:00:39 UTC 2013


On Mon, 2013-08-19 at 15:19 +0200, akozumpl at redhat.com wrote:
> From: Ales Kozumplik <ales at redhat.com>
>
> +    def install(self):
> +        progressQ.send_message(_('Starting package installation process'))
> +        if self.install_device:
> +            self._setupMedia(self.install_device)
> +        try:
> +            self.checkSoftwareSelection()
> +        except errors.DependencyError:
> +            if errors.errorHandler.cb(e) == constants.ERROR_RAISE:
> +                progressQ.send_quit(1)
> +                sys.exit(1)
> +
> +        pkgs_to_download = self._base.transaction.install_set
> +        log.info('Downloading pacakges.')
                              typo ^^^

> +        self._base.download_packages(pkgs_to_download)
> +        log.info('Downloading packages finished.')
> +
> +        pre_msg = _("Preparing transaction from installation source")
> +        progressQ.send_message(pre_msg)
> +
> +        queue = multiprocessing.Queue()
> +        process = multiprocessing.Process(target=do_transaction,
> +                                          args=(self._base,queue))
> +        process.start()
> +        (token, msg) = queue.get()
> +        while token != 'post':
> +            if token == 'install':
> +                msg = _("Installing %s") % msg
> +                progressQ.send_message(msg)
> +            (token, msg) = queue.get()
> +
> +        post_msg = _("Performing post-installation setup tasks")
> +        progressQ.send_message(post_msg)
> +        process.join()
> +
> +    def isRepoEnabled(self, repo_id):
> +        try:
> +            return self._base.repos[repo_id].enabled
> +        except Exception:
> +            return super(YumPayload, self).isRepoEnabled(repo_id)
> +
> +    def preInstall(self, packages=None, groups=None):
> +        super(DNFPayload, self).preInstall()
> +        self._required_pkgs = packages
> +        self._required_groups = groups
> +
> +    def release(self):
> +        pass
> +
> +    def reset(self):
> +        super(DNFPayload, self).reset()
> +        self.txID = None
> +
> +    def setup(self, storage):
> +        # must end up with the base repo (and its metadata) ready
> +        super(DNFPayload, self).setup(storage)
> +        self.updateBaseRepo()
> +        self.gatherRepoMetadata()
> +
> +    @property
> +    def spaceRequired(self):
> +        if self._base.transaction is None:
> +            return Size(spec="3000 MB")
> +
> +        installed_sizes = [tsi.installed.installsize \
> +                               for tsi in self._base.transaction]
> +        size = reduce(operator.add, installed_sizes)
Why not use 'sum(installed_sizes)'? Or you could use generator
expression and this:

size = sum(tsi.installed.installsize for tsi in self._base.transaction)

Or use the temporary variable, but make it a generator by using
parentheses instead of square brackets. In either case, the backslash is
not needed since the newline is inside the brackets.

-- 
Vratislav Podzimek

Anaconda Rider | Red Hat, Inc. | Brno - Czech Republic



More information about the anaconda-patches mailing list