Beispiel #1
0
    def execute(self, ns, _allow_duplicates=False):
        installed_nevras = None
        if software.get_backend(ns) == software.BACKEND_PACKAGEKIT:
            installed_nevras = set(software.get_package_nevra(p)
                for p in software.list_installed_packages(ns))

        for pkg in software.find_package(ns,
                allow_duplicates=_allow_duplicates):
            yield (software.get_package_nevra(pkg), )
Beispiel #2
0
    def execute(self, ns, _allow_duplicates=False):
        installed_nevras = None
        if software.get_backend(ns) == software.BACKEND_PACKAGEKIT:
            installed_nevras = set(
                software.get_package_nevra(p)
                for p in software.list_installed_packages(ns))

        for pkg in software.find_package(ns,
                                         allow_duplicates=_allow_duplicates):
            yield (software.get_package_nevra(pkg), )
Beispiel #3
0
 def execute(self,
             ns,
             package_array,
             _allow_duplicates=False,
             _installed=False,
             _available=False,
             _repoid=None):
     if _installed or _available:
         _installed = not _available
     else:
         _installed = None
     if _installed is None:
         yield ('NEVRA', 'Installed', 'Summary')
     else:
         yield ('NEVRA', 'Summary')
     for pkg_spec in package_array:
         for pkg in software.find_package(
                 ns,
                 allow_duplicates=_allow_duplicates,
                 exact_match=False,
                 installed=_installed,
                 pkg_spec=pkg_spec,
                 repoid=_repoid):
             inst = pkg.to_instance()
             nevra = software.get_package_nevra(inst)
             if _installed is None:
                 yield (nevra, 'Yes' if software.is_package_installed(inst)
                        else 'No', inst.Caption)
             else:
                 yield (nevra, inst.Caption)
Beispiel #4
0
def for_each_package_specs(ns,
                           pkg_specs,
                           info,
                           func,
                           repoid=None,
                           just_on_installed=True):
    """
    Iterate over package specification strings, find them on remote host,
    make them into ``LMI_SoftwareIdentity``, and pass them to given function.

    :param list pkg_specs: Package specification strings.
    :param string info: What is done with package. This is used in log messages.
    :param callable func: Any callable taking instance of
        ``LMI_SoftwareIdentity`` as the first and only argument.
    :param string repoid: Optional repository id used in a search
        for corresponding software identity.
    :param boolean just_on_installed: Skip uninstalled software identities
        found.
    :returns: Pair with list containing a subset of ``pkg_specs`` with items,
        that were processed successfuly and a list of errors for other packages.
    :rtype: tuple
    """
    done_on = []
    failed = []
    for pkg_spec in pkg_specs:
        if just_on_installed:
            identities = [
                i.to_instance() for i in software.find_package(
                    ns, pkg_spec=pkg_spec, repoid=repoid)
            ]

            identities = [
                p for p in identities if software.is_package_installed(p)
            ]
        else:
            identities = list(
                software.find_package(ns, pkg_spec=pkg_spec, repoid=repoid))
        if len(identities) < 1:
            if just_on_installed:
                msg = 'No such installed package "%s".' % pkg_spec
            else:
                msg = 'Failed to find package "%s".' % pkg_spec
            LOG().warn(msg + ' Skipping.')
            failed.append(msg)
            continue
        if len(identities) > 1:
            LOG().debug(
                'More than one package found for "%s": %s', pkg_spec,
                ', '.join(software.get_package_nevra(i) for i in identities))
        try:
            func(identities[-1])
            done_on.append(pkg_spec)
        except errors.LmiFailed as err:
            failed.append(err)
    return done_on, failed
Beispiel #5
0
def for_each_package_specs(ns, pkg_specs, info, func,
        repoid=None, just_on_installed=True):
    """
    Iterate over package specification strings, find them on remote host,
    make them into ``LMI_SoftwareIdentity``, and pass them to given function.

    :param list pkg_specs: Package specification strings.
    :param string info: What is done with package. This is used in log messages.
    :param callable func: Any callable taking instance of
        ``LMI_SoftwareIdentity`` as the first and only argument.
    :param string repoid: Optional repository id used in a search
        for corresponding software identity.
    :param boolean just_on_installed: Skip uninstalled software identities
        found.
    :returns: Pair with list containing a subset of ``pkg_specs`` with items,
        that were processed successfuly and a list of errors for other packages.
    :rtype: tuple
    """
    done_on = []
    failed = []
    for pkg_spec in pkg_specs:
        if just_on_installed:
            identities = [
                        i.to_instance()
                    for i in software.find_package(ns,
                        pkg_spec=pkg_spec, repoid=repoid)]

            identities = [p for p in identities if p.InstallDate is not None]
        else:
            identities = list(software.find_package(ns,
                pkg_spec=pkg_spec, repoid=repoid))
        if len(identities) < 1:
            if just_on_installed:
                msg = 'No such installed package "%s".' % pkg_spec
            else:
                msg = 'Failed to find package "%s".' % pkg_spec
            LOG().warn(msg + ' Skipping.')
            failed.append(msg)
            continue
        if len(identities) > 1:
            LOG().debug('More than one package found for "%s": %s',
                    pkg_spec,
                    ', '.join(software.get_package_nevra(i)
                        for i in identities))
        try:
            func(identities[-1])
            done_on.append(pkg_spec)
        except errors.LmiFailed as err:
            LOG().warn('Failed to %s "%s": %s', info, pkg_spec, err)
            failed.append(err)
    return done_on, failed
Beispiel #6
0
def for_each_package_specs(ns, pkg_specs, info, func,
        repoid=None, just_on_installed=True):
    """
    Iterate over package specification strings, find them on remote host,
    make them into ``LMI_SoftwareIdentity``, and pass them to given function.
    
    :param pkg_specs: (``list``) List of package specification strings.
    :param info: (``str``) What is done with package. This is used in log
        messages.
    :param func: (``callable``) Any callable taking instance of
        ``LMI_SoftwareIdentity`` as the first and only argument.
    :param repoid: (``str``) Optional repository id used in a search
        for corresponding software identity.
    :param just_on_installed: (``bool``) Skip uninstalled software identities
        found.
    :rtype: (``list``) List containing a subset of ``pkg_specs`` with items,
        that were processed successfuly.
    """
    done_on = []
    for pkg_spec in pkg_specs:
        if just_on_installed:
            identities = [
                        i.to_instance()
                    for i in software.find_package(ns,
                        pkg_spec=pkg_spec, repoid=repoid)]

            identities = [p for p in identities if p.InstallDate is not None]
        else:
            identities = list(software.find_package(ns,
                pkg_spec=pkg_spec, repoid=repoid))
        if len(identities) < 1:
            LOG().warn('failed to find any matching package for "%s",'
                ' skipping', pkg_spec)
            continue
        if len(identities) > 1:
            LOG().warn('more than one package found for "%s": %s',
                    pkg_spec,
                    ', '.join(software.get_package_nevra(i)
                        for i in identities))
        try:
            func(identities[-1])
            done_on.append(pkg_spec)
        except errors.LmiFailed as err:
            LOG().warn('failed to %s "%s": %s', info, pkg_spec, err)
    return done_on
Beispiel #7
0
def for_each_package_specs(ns, pkg_specs, info, func,
        repoid=None, just_on_installed=True):
    """
    Iterate over package specification strings, find them on remote host,
    make them into ``LMI_SoftwareIdentity``, and pass them to given function.
    
    :param pkg_specs: (``list``) List of package specification strings.
    :param info: (``str``) What is done with package. This is used in log
        messages.
    :param func: (``callable``) Any callable taking instance of
        ``LMI_SoftwareIdentity`` as the first and only argument.
    :param repoid: (``str``) Optional repository id used in a search
        for corresponding software identity.
    :param just_on_installed: (``bool``) Skip uninstalled software identities
        found.
    :rtype: (``list``) List containing a subset of ``pkg_specs`` with items,
        that were processed successfuly.
    """
    done_on = []
    for pkg_spec in pkg_specs:
        if just_on_installed:
            identities = [
                        i.to_instance()
                    for i in software.find_package(ns,
                        pkg_spec=pkg_spec, repoid=repoid)]

            identities = [p for p in identities if p.InstallDate is not None]
        else:
            identities = list(software.find_package(ns,
                pkg_spec=pkg_spec, repoid=repoid))
        if len(identities) < 1:
            LOG().warn('failed to find any matching package for "%s",'
                ' skipping', pkg_spec)
            continue
        if len(identities) > 1:
            LOG().warn('more than one package found for "%s": %s',
                    pkg_spec,
                    ', '.join(software.get_package_nevra(i)
                        for i in identities))
        try:
            func(identities[-1])
            done_on.append(pkg_spec)
        except errors.LmiFailed as err:
            LOG().warn('failed to %s "%s": %s', info, pkg_spec, err)
    return done_on
Beispiel #8
0
 def execute(self, ns, package_array, _allow_duplicates=False, _installed=False, _available=False, _repoid=None):
     if _installed or _available:
         _installed = not _available
     else:
         _installed = None
     if _installed is None:
         yield ("NEVRA", "Installed", "Summary")
     else:
         yield ("NEVRA", "Summary")
     for pkg_spec in package_array:
         for pkg in software.find_package(
             ns,
             allow_duplicates=_allow_duplicates,
             exact_match=False,
             installed=_installed,
             pkg_spec=pkg_spec,
             repoid=_repoid,
         ):
             inst = pkg.to_instance()
             nevra = software.get_package_nevra(inst)
             if _installed is None:
                 yield (nevra, "Yes" if software.is_package_installed(inst) else "No", inst.Caption)
             else:
                 yield (nevra, inst.Caption)