From cc99d9f10bfc005fc9f9b6b4ad678ba6b36fb62d Mon Sep 17 00:00:00 2001 From: wangsong Date: Sun, 26 Sep 2021 11:27:07 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=8C=85=E7=9A=84=E7=BB=86?= =?UTF-8?q?=E8=8A=82=E4=BF=A1=E6=81=AF=E5=8C=85=E4=B8=8B=E8=BD=BD=E5=AE=89?= =?UTF-8?q?=E8=A3=85=E5=A4=A7=E5=B0=8F=EF=BC=8C=E5=80=99=E9=80=89=E7=89=88?= =?UTF-8?q?=E6=9C=AC=E5=BD=93=E5=89=8D=E7=89=88=E6=9C=AC=E7=AD=89=E7=AD=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- UpdateManager/Core/UpdateList.py | 27 ++++++++++++++++++--------- kylin-system-updater | 1 - 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/UpdateManager/Core/UpdateList.py b/UpdateManager/Core/UpdateList.py index dea7d95..7160068 100644 --- a/UpdateManager/Core/UpdateList.py +++ b/UpdateManager/Core/UpdateList.py @@ -38,8 +38,6 @@ import glob import json from gi.repository import Gio -import shutil -from .utils import humanize_size from UpdateManager.Core import utils from UpdateManager.Core import filter @@ -509,21 +507,32 @@ class UpdateList(): return False,header,desc def _make_pkg_info_json(self,cache,pkgs_list): - size = 0 - total_size = 0 + total_download_size = 0 + total_installed_size = 0 pkgs_info_json = {} + for pkg_name in pkgs_list: try: pkg = cache[pkg_name] + #当前版本 + cur_version = pkg.installed.version + can_version = pkg.candidate.version #获取下载大小 - size = getattr(pkg.candidate, "size", 0) - total_size = total_size + size - pkgs_info_json.update({pkg_name:{"size":size}}) + download_size = getattr(pkg.candidate, "size", 0) + installed_size = getattr(pkg.candidate, "installed_size", 0) + + total_download_size = total_download_size + download_size + total_installed_size = total_installed_size + installed_size + + pkgs_info_json.update({pkg_name:{"cur_version":cur_version,"can_version":can_version,\ + "download_size":download_size,"installed_size":installed_size}}) + except Exception as e: logging.info("this package(%s) not in list and error mes:%s",pkg_name,e) - pass - pkgs_info_json.update({"total_size":total_size}) + + pkgs_info_json.update({"total_download_size":total_download_size}) + pkgs_info_json.update({"total_installed_size":total_installed_size}) return pkgs_info_json #检查包是否在cache中 返回新得列表 diff --git a/kylin-system-updater b/kylin-system-updater index a68ade4..d30c8f0 100755 --- a/kylin-system-updater +++ b/kylin-system-updater @@ -40,4 +40,3 @@ if __name__ == "__main__": loop = GLib.MainLoop() loop.run() - \ No newline at end of file