Пример #1
0
    def dist_upgrade(self):
        action_type = ACTION_UPGRADE
        action_id = '%s_%s' % (self.get_unique_id(), action_type)
        self.update_signal([("ready-download-start", (action_id, action_type))
                            ])

        dist_upgrade_changes = self.pkg_cache.get_dist_upgrade_changes()
        # detect and prevent the system components from being uninstalled
        pkg_in_white_list = []
        download_pkgs = []
        self.all_upgrade_pkg_names = []
        for pkg in dist_upgrade_changes["delete"]:
            name = pkg.name
            if name in SYS_PKG_WHITE_LIST:
                pkg_in_white_list.append(name)
        if len(pkg_in_white_list) > 0:
            self.update_signal([("remove-pkgs-in-white-list",
                                 (json.dumps(pkg_in_white_list), action_type))
                                ])
            logger.error("found remove system packages: %s" %
                         json.dumps(pkg_in_white_list))
        else:
            for status in dist_upgrade_changes:
                for pkg in dist_upgrade_changes[status]:
                    self.all_upgrade_pkg_names.append(pkg.name)
                    if status == "delete" or status == "keep":
                        continue
                    if not parse_pkg.pkg_file_has_exist(pkg):
                        download_pkgs.append(pkg)

            self.update_signal([("ready-download-finish", (action_id,
                                                           action_type))])
            if len(download_pkgs) == 0:
                global_event.emit("download-finish", action_id, action_type,
                                  self.all_upgrade_pkg_names)
            else:
                names = []
                download_urls = []
                download_hash_infos = []
                pkg_sizes = []
                for pkg in download_pkgs:
                    names.append(pkg.name)
                    download_urls.append(pkg.candidate.uri)
                    download_hash_infos.append(pkg.candidate.md5)
                    pkg_sizes.append(pkg.candidate.size)
                self.download_manager.add_download(
                    action_id,
                    action_type,
                    download_urls,
                    download_sizes=pkg_sizes,
                    download_md5s=download_hash_infos,
                    all_task_names=names,
                    all_change_pkgs=self.all_upgrade_pkg_names,
                    file_save_dir=self.download_dir)
Пример #2
0
    def dist_upgrade(self):
        action_type = ACTION_UPGRADE
        action_id = '%s_%s' % (self.get_unique_id(), action_type)
        self.update_signal([(
            "ready-download-start", (action_id, action_type))])

        dist_upgrade_changes = self.pkg_cache.get_dist_upgrade_changes()
        # detect and prevent the system components from being uninstalled
        pkg_in_white_list = []
        download_pkgs = []
        self.all_upgrade_pkg_names = []
        for pkg in dist_upgrade_changes["delete"]:
            name = pkg.name
            if name in SYS_PKG_WHITE_LIST:
                pkg_in_white_list.append(name)
        if len(pkg_in_white_list) > 0:
            self.update_signal([(
                "remove-pkgs-in-white-list",
                (json.dumps(pkg_in_white_list), action_type))])
            logger.error("found remove system packages: %s" %
                json.dumps(pkg_in_white_list))
        else:
            for status in dist_upgrade_changes:
                for pkg in dist_upgrade_changes[status]:
                    self.all_upgrade_pkg_names.append(pkg.name)
                    if status == "delete" or status == "keep":
                        continue
                    if not parse_pkg.pkg_file_has_exist(pkg):
                        download_pkgs.append(pkg)

            self.update_signal([("ready-download-finish", (action_id, action_type))])
            if len(download_pkgs) == 0:
                global_event.emit("download-finish", action_id, action_type,
                        self.all_upgrade_pkg_names)
            else:
                names = []
                download_urls = []
                download_hash_infos = []
                pkg_sizes = []
                for pkg in download_pkgs:
                    names.append(pkg.name)
                    download_urls.append(pkg.candidate.uri)
                    download_hash_infos.append(pkg.candidate.md5)
                    pkg_sizes.append(pkg.candidate.size)
                self.download_manager.add_download(
                    action_id,
                    action_type,
                    download_urls,
                    download_sizes=pkg_sizes,
                    download_md5s=download_hash_infos,
                    all_task_names=names,
                    all_change_pkgs=self.all_upgrade_pkg_names,
                    file_save_dir=self.download_dir
                    )
Пример #3
0
 def RequestUpgradeStatus(self):
     if self.in_update_list:
         return ("cache-updating", json.dumps([]))
     elif self.is_upgrading:
         return ("upgrading", json.dumps([]))
     else:
         dist_upgrade_changes = self.pkg_cache.get_dist_upgrade_changes()
         return_infos = []
         for status in dist_upgrade_changes:
             for pkg in dist_upgrade_changes[status]:
                 return_infos.append(
                     dict(status=status,
                          name=pkg.name,
                          version=pkg.candidate.version,
                          size=pkg.candidate.size,
                          downloaded=parse_pkg.pkg_file_has_exist(pkg)))
         return ("normal", json.dumps(return_infos))
Пример #4
0
 def RequestUpgradeStatus(self):
     if self.in_update_list:
         return ("cache-updating", json.dumps([]))
     elif self.is_upgrading:
         return ("upgrading", json.dumps([]))
     else:
         dist_upgrade_changes = self.pkg_cache.get_dist_upgrade_changes()
         return_infos = []
         for status in dist_upgrade_changes:
             for pkg in dist_upgrade_changes[status]:
                 return_infos.append(dict(
                     status=status,
                     name=pkg.name,
                     version=pkg.candidate.version,
                     size=pkg.candidate.size,
                     downloaded=parse_pkg.pkg_file_has_exist(pkg)
                     ))
         return ("normal", json.dumps(return_infos))