Пример #1
0
    def get_upgrade_requirements(
            self, pkgs: List[FlatpakApplication], root_password: str,
            watcher: ProcessWatcher) -> UpgradeRequirements:
        flatpak_version = flatpak.get_version()

        user_pkgs, system_pkgs = [], []

        for pkg in pkgs:
            if pkg.installation == 'user':
                user_pkgs.append(pkg)
            else:
                system_pkgs.append(pkg)

        for apps_by_install in ((user_pkgs, 'user'), (system_pkgs, 'system')):
            if apps_by_install[0]:
                sizes = flatpak.map_update_download_size(
                    [str(p.id) for p in apps_by_install[0]],
                    apps_by_install[1], flatpak_version)

                if sizes:
                    for p in apps_by_install[0]:
                        p.size = sizes.get(str(p.id))

        to_update = [
            UpgradeRequirement(pkg=p, extra_size=p.size, required_size=p.size)
            for p in self.sort_update_order(pkgs)
        ]
        return UpgradeRequirements(None, None, to_update, [])
Пример #2
0
    def test_map_update_download_size__for_flatpak_1_2(self, SimpleProcess: Mock, handle_simple: Mock):
        download_size = flatpak.map_update_download_size(app_ids={'org.xpto.Xnote'}, installation='user', version=VERSION_1_2)
        SimpleProcess.assert_called_once()
        handle_simple.assert_called_once()

        self.assertEqual({'org.xpto.Xnote': 4300000}, download_size)