コード例 #1
0
    def _get_tobe_activated_pkg_list(manager, device):
        """
           Get list of package which can be activated.
        """
        try:
            packages = manager.csm.software_packages
        except AttributeError:
            manager.error("No packages selected")

        added_pkgs = package_lib.NewPackage(packages)
        installed_inact = device.send("admin show install inactive summary")
        installed_act = device.send("admin show install active summary")

        inactive_pkgs = package_lib.OnboxPackage(installed_inact, "Inactive Packages")
        active_pkgs = package_lib.OnboxPackage(installed_act, "Active Packages")

        # Skip operation if to be activated packages are already active
        package_to_activate = package_lib.extra_pkgs(active_pkgs.pkg_list, added_pkgs.pkg_list)

        if package_to_activate:
            # Test If there is anything added but not inactive
            pkg_to_activate = package_lib.package_intersection(
                added_pkgs.pkg_list, inactive_pkgs.pkg_list)
            if not pkg_to_activate:
                # "explicit is better than implicit" being one of the mottos in "The Zen of Python"
                to_activate = " ".join(map(str, added_pkgs.pkg_list))
                state_of_packages = "\nTo activate :{} \nInactive: {} \nActive: {}".format(
                    to_activate, installed_inact, installed_act
                )
                manager.log(state_of_packages)
                manager.error('To be activated package is not in inactive packages list')
            else:
                return " ".join(pkg_to_activate)
コード例 #2
0
    def _get_tobe_deactivated_pkg_list(manager, device):
        """
        Produces a list of packaged to be deactivated
        """
        try:
            packages = manager.csm.software_packages
        except AttributeError:
            manager.error("No packages selected")

        added_pkgs = package_lib.NewPackage(packages)
        installed_inact = device.send("admin show install inactive summary")
        installed_act = device.send("admin show install active summary")

        inactive_pkgs = package_lib.OnboxPackage(installed_inact, "Inactive Packages")
        active_pkgs = package_lib.OnboxPackage(installed_act, "Active Packages")

        package_to_deactivate = package_lib.extra_pkgs(inactive_pkgs.pkg_list, added_pkgs.pkg_list)

        if package_to_deactivate:
            pkg_to_deactivate = package_lib.package_intersection(added_pkgs.pkg_list, active_pkgs.pkg_list)
            if not pkg_to_deactivate:
                to_deactivate = " ".join(map(str, added_pkgs.pkg_list))
                state_of_packages = "\nTo deactivate :{} \nInactive: {} \nActive: {}".format(
                    to_deactivate, installed_inact, installed_act
                )
                manager.log(state_of_packages)
                manager.error('To be deactivated package is not in inactive packages list')
            else:
                return " ".join(pkg_to_deactivate)
コード例 #3
0
    def _get_tobe_deactivated_pkg_list(manager, device):
        """
        Produces a list of packaged to be deactivated
        """
        try:
            packages = manager.csm.software_packages
        except AttributeError:
            manager.error("No packages selected")

        added_pkgs = package_lib.NewPackage(packages)
        installed_inact = device.send("admin show install inactive summary")
        installed_act = device.send("admin show install active summary")

        inactive_pkgs = package_lib.OnboxPackage(installed_inact,
                                                 "Inactive Packages")
        active_pkgs = package_lib.OnboxPackage(installed_act,
                                               "Active Packages")

        package_to_deactivate = package_lib.extra_pkgs(inactive_pkgs.pkg_list,
                                                       added_pkgs.pkg_list)

        if package_to_deactivate:
            pkg_to_deactivate = package_lib.package_intersection(
                added_pkgs.pkg_list, active_pkgs.pkg_list)
            if not pkg_to_deactivate:
                to_deactivate = " ".join(map(str, added_pkgs.pkg_list))
                state_of_packages = "\nTo deactivate :{} \nInactive: {} \nActive: {}".format(
                    to_deactivate, installed_inact, installed_act)
                manager.log(state_of_packages)
                manager.error(
                    'To be deactivated package is not in inactive packages list'
                )
            else:
                return " ".join(pkg_to_deactivate)
コード例 #4
0
ファイル: install_activate.py プロジェクト: kstaniek/csm
    def _get_tobe_activated_pkg_list(manager, device):
        """
           Get list of package which can be activated.
        """
        try:
            packages = manager.csm.software_packages
        except AttributeError:
            manager.error("No packages selected")

        added_pkgs = package_lib.NewPackage(packages)
        installed_inact = device.send("admin show install inactive summary")
        installed_act = device.send("admin show install active summary")

        inactive_pkgs = package_lib.OnboxPackage(installed_inact,
                                                 "Inactive Packages")
        active_pkgs = package_lib.OnboxPackage(installed_act,
                                               "Active Packages")

        # Skip operation if to be activated packages are already active
        package_to_activate = package_lib.extra_pkgs(active_pkgs.pkg_list,
                                                     added_pkgs.pkg_list)

        if package_to_activate:
            # Test If there is anything added but not inactive
            pkg_to_activate = package_lib.package_intersection(
                added_pkgs.pkg_list, inactive_pkgs.pkg_list)
            if not pkg_to_activate:
                # "explicit is better than implicit" being one of the mottos in "The Zen of Python"
                to_activate = " ".join(map(str, added_pkgs.pkg_list))
                state_of_packages = "\nTo activate :{} \nInactive: {} \nActive: {}".format(
                    to_activate, installed_inact, installed_act)
                manager.log(state_of_packages)
                manager.error(
                    'To be activated package is not in inactive packages list')
            else:
                return " ".join(pkg_to_activate)