Ejemplo n.º 1
0
    def upgrade(self, requirements: UpgradeRequirements, root_password: str, watcher: ProcessWatcher) -> bool:
        flatpak_version = flatpak.get_version()
        for req in requirements.to_upgrade:
            watcher.change_status("{} {} ({})...".format(self.i18n['manage_window.status.upgrading'], req.pkg.name, req.pkg.version))
            related, deps = False, False
            ref = req.pkg.ref

            if req.pkg.partial and flatpak_version < '1.5':
                related, deps = True, True
                ref = req.pkg.base_ref

            try:
                res = ProcessHandler(watcher).handle(SystemProcess(subproc=flatpak.update(app_ref=ref,
                                                                                          installation=req.pkg.installation,
                                                                                          related=related,
                                                                                          deps=deps)))

                watcher.change_substatus('')
                if not res:
                    self.logger.warning("Could not upgrade '{}'".format(req.pkg.id))
                    return False
            except:
                watcher.change_substatus('')
                self.logger.error("An error occurred while upgrading '{}'".format(req.pkg.id))
                traceback.print_exc()
                return False

        watcher.change_substatus('')
        return True
Ejemplo n.º 2
0
    def upgrade(self, requirements: UpgradeRequirements, root_password: Optional[str], watcher: ProcessWatcher) -> bool:
        flatpak_version = flatpak.get_version()

        if not self._make_exports_dir(watcher):
            return False

        for req in requirements.to_upgrade:
            watcher.change_status("{} {} ({})...".format(self.i18n['manage_window.status.upgrading'], req.pkg.name, req.pkg.version))
            related, deps = False, False
            ref = req.pkg.ref

            if req.pkg.partial and flatpak_version < VERSION_1_5:
                related, deps = True, True
                ref = req.pkg.base_ref

            try:
                if req.pkg.update_component:
                    self.logger.info(f"Installing {req.pkg}")
                    res, _ = ProcessHandler(watcher).handle_simple(flatpak.install(app_id=ref,
                                                                                   installation=req.pkg.installation,
                                                                                   origin=req.pkg.origin,
                                                                                   version=flatpak_version))

                else:
                    self.logger.info(f"Updating {req.pkg}")
                    res, _ = ProcessHandler(watcher).handle_simple(flatpak.update(app_ref=ref,
                                                                                  installation=req.pkg.installation,
                                                                                  related=related,
                                                                                  deps=deps,
                                                                                  version=flatpak_version))

                watcher.change_substatus('')
                if not res:
                    self.logger.warning("Could not upgrade '{}'".format(req.pkg.id))
                    return False
            except:
                watcher.change_substatus('')
                self.logger.error("An error occurred while upgrading '{}'".format(req.pkg.id))
                traceback.print_exc()
                return False

        watcher.change_substatus('')
        return True
Ejemplo n.º 3
0
    def upgrade(self, requirements: UpgradeRequirements, root_password: Optional[str], watcher: ProcessWatcher) -> bool:
        not_upgraded = []

        for req in requirements.to_upgrade:
            watcher.change_status(f"{self.i18n['manage_window.status.upgrading']} {req.pkg.name} ({req.pkg.version})...")

            download_data = None

            if not req.pkg.imported:
                download_data = self._download(req.pkg, watcher)

                if not download_data:
                    not_upgraded.append(req.pkg)
                    watcher.change_substatus('')
                    continue

            if not self.uninstall(req.pkg, root_password, watcher).success:
                not_upgraded.append(req.pkg)
                watcher.change_substatus('')
                continue

            if not self._install(pkg=req.pkg, watcher=watcher, pre_downloaded_file=download_data).success:
                not_upgraded.append(req.pkg)
                watcher.change_substatus('')
                continue

            self.cache_to_disk(req.pkg, None, False)

        all_failed = len(not_upgraded) == len(requirements.to_upgrade)

        if not_upgraded:
            pkgs_str = ''.join((f'<li>{app.name}</li>' for app in not_upgraded))
            watcher.show_message(title=self.i18n['error' if all_failed else 'warning'].capitalize(),
                                 body=self.i18n['appimage.upgrade.failed'].format(apps=f'<ul>{pkgs_str}</ul>'),
                                 type_=MessageType.ERROR if all_failed else MessageType.WARNING)

        watcher.change_substatus('')
        return not all_failed
Ejemplo n.º 4
0
    def upgrade(self, requirements: UpgradeRequirements, root_password: str,
                watcher: ProcessWatcher) -> bool:
        for req in requirements.to_upgrade:
            watcher.change_status("{} {} ({})...".format(
                self.i18n['manage_window.status.upgrading'], req.pkg.name,
                req.pkg.version))

            if not self.uninstall(req.pkg, root_password, watcher):
                watcher.show_message(
                    title=self.i18n['error'],
                    body=self.i18n['appimage.error.uninstall_current_version'],
                    type_=MessageType.ERROR)
                watcher.change_substatus('')
                return False

            if not self.install(req.pkg, root_password, watcher):
                watcher.change_substatus('')
                return False

            self.cache_to_disk(req.pkg, None, False)

        watcher.change_substatus('')
        return True