From patchwork Sat Mar 7 07:56:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiko Thiery X-Patchwork-Id: 1250839 Return-Path: X-Original-To: incoming-buildroot@patchwork.ozlabs.org Delivered-To: patchwork-incoming-buildroot@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=busybox.net (client-ip=140.211.166.137; helo=fraxinus.osuosl.org; envelope-from=buildroot-bounces@busybox.net; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=qLlPmuQr; dkim-atps=neutral Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48ZGz26rXYz9sPR for ; Sat, 7 Mar 2020 18:56:46 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 51C2686EFF; Sat, 7 Mar 2020 07:56:44 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 7O5PLBb8U61k; Sat, 7 Mar 2020 07:56:43 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by fraxinus.osuosl.org (Postfix) with ESMTP id 7B81686EDD; Sat, 7 Mar 2020 07:56:43 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by ash.osuosl.org (Postfix) with ESMTP id 1B0ED1BF42C for ; Sat, 7 Mar 2020 07:56:42 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 1822387E07 for ; Sat, 7 Mar 2020 07:56:42 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Gzh7bRrEeXJ4 for ; Sat, 7 Mar 2020 07:56:40 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-wr1-f67.google.com (mail-wr1-f67.google.com [209.85.221.67]) by hemlock.osuosl.org (Postfix) with ESMTPS id 872A987D9C for ; Sat, 7 Mar 2020 07:56:40 +0000 (UTC) Received: by mail-wr1-f67.google.com with SMTP id v11so4928160wrm.9 for ; Fri, 06 Mar 2020 23:56:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=WJoIOr8zl6kKt8h4OxGy4NyIQVyIm8l0DUARGur6fZc=; b=qLlPmuQr5m3mkkKUP1g7tfEXNzcZg5S9GSge3fK+QybjpfNrjO6HuzTO2/ibwr6QBv 360L167Go6GfEoOJCeo8a1A1TJkzVwc+17JxHw4fpgxpQTYnqdA6KanE7XXrzZhv4oPM xmR8fRUkQkqVpWw65zl1Gn/2vpuKKnr1rlKY24o7ip9VlRE2ndd+CvW6iVH+x66UEdmh hktQcmOmZq0IeJvqSClqS9EURgMYUKoPzkkPB+kxgfxXTqa/+P5JvL9kyWCTm0t0/FCs gItJgeGG8OJpb2eymttesbUmj5pOQeoPedW8fZTg6FMAVPTSM3fgMciUwqW/SxOXIOFx 5QMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=WJoIOr8zl6kKt8h4OxGy4NyIQVyIm8l0DUARGur6fZc=; b=phxCeoH33sb3HMLXdAW2l3WVmIxaR0P68H8tSCcOwob8pDFfNz/61JrhwqwIBzflHU eFfFSINt1IYi6dfcxGTmHWRqbSR0WAClhqkXSQS2PiVICyIhhFESwCcUCO88ID+Krs8f GwNa+/tBKxxYMvGK0dSTBQ0QqdG3XTvTH5yhmjPEr9DR9khe0mrHf9mFyqy6d0z/eMTf Qy7u3KB+D+maRFnvXy3BjYSkUkjnaJSuaSKzkLH9p6EYtw19r3f56WugnZs+AeBuMSD2 eFIdXOS5+pdydddrDpgQYsMzaWNGsnxSx/nYGews1BRvkN3ENVC791ifOedBMjbLHJtU QgJQ== X-Gm-Message-State: ANhLgQ0ZsF5iJPZyJ4OG0uYmZ8kR/lBIX7BzJB/gHJnXLqLsW/BN9S64 /ULTcw2kLbeXWGD8bjZ7FIpnLp0j X-Google-Smtp-Source: ADFU+vvSXWJg8yZxkFiQzzMOW/W3JnbFA7O21EcYYS8VbALKTtHK0nMcC7N4xcl33H27I+4O+V9WIA== X-Received: by 2002:adf:df91:: with SMTP id z17mr7987660wrl.97.1583567798479; Fri, 06 Mar 2020 23:56:38 -0800 (PST) Received: from t450s.fritz.box (ip5f58981a.dynamic.kabel-deutschland.de. [95.88.152.26]) by smtp.gmail.com with ESMTPSA id g129sm19189071wmg.12.2020.03.06.23.56.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Mar 2020 23:56:38 -0800 (PST) From: Heiko Thiery To: buildroot@buildroot.org Date: Sat, 7 Mar 2020 08:56:22 +0100 Message-Id: <20200307075633.7514-2-heiko.thiery@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200307075633.7514-1-heiko.thiery@gmail.com> References: <20200307075633.7514-1-heiko.thiery@gmail.com> MIME-Version: 1.0 Subject: [Buildroot] [PATCH v5 01/12] support/scripts/pkg-stats: store latest version in a dict X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Heiko Thiery , Thomas Petazzoni , Titouan Christophe Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" This patch changes the type of the latest_version variable to a dict. This is for better readability/usability of the data. With this the json output is more descriptive in later processing of the json output. Signed-off-by: Heiko Thiery --- support/scripts/pkg-stats | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/support/scripts/pkg-stats b/support/scripts/pkg-stats index 8a67e509e1..95ec9e86bd 100755 --- a/support/scripts/pkg-stats +++ b/support/scripts/pkg-stats @@ -71,7 +71,7 @@ class Package: self.url_status = None self.url_worker = None self.cves = list() - self.latest_version = (RM_API_STATUS_ERROR, None, None) + self.latest_version = {'status': RM_API_STATUS_ERROR, 'version': None, 'id': None} def pkgvar(self): return self.name.upper().replace("-", "_") @@ -462,9 +462,8 @@ def check_package_latest_version(packages): """ Fills in the .latest_version field of all Package objects - This field has a special format: - (status, version, id) - with: + This field is a dict and has the following keys: + - status: one of RM_API_STATUS_ERROR, RM_API_STATUS_FOUND_BY_DISTRO, RM_API_STATUS_FOUND_BY_PATTERN, RM_API_STATUS_NOT_FOUND @@ -480,7 +479,7 @@ def check_package_latest_version(packages): worker_pool = Pool(processes=64) results = worker_pool.map(check_package_latest_version_worker, (pkg.name for pkg in packages)) for pkg, r in zip(packages, results): - pkg.latest_version = r + pkg.latest_version = dict(zip(['status', 'version', 'id'], r)) worker_pool.terminate() del http_pool @@ -519,13 +518,13 @@ def calculate_stats(packages): stats["hash"] += 1 else: stats["no-hash"] += 1 - if pkg.latest_version[0] == RM_API_STATUS_FOUND_BY_DISTRO: + if pkg.latest_version['status'] == RM_API_STATUS_FOUND_BY_DISTRO: stats["rmo-mapping"] += 1 else: stats["rmo-no-mapping"] += 1 - if not pkg.latest_version[1]: + if not pkg.latest_version['version']: stats["version-unknown"] += 1 - elif pkg.latest_version[1] == pkg.current_version: + elif pkg.latest_version['version'] == pkg.current_version: stats["version-uptodate"] += 1 else: stats["version-not-uptodate"] += 1 @@ -691,29 +690,29 @@ def dump_html_pkg(f, pkg): f.write(" %s\n" % current_version) # Latest version - if pkg.latest_version[0] == RM_API_STATUS_ERROR: + if pkg.latest_version['status'] == RM_API_STATUS_ERROR: td_class.append("version-error") - if pkg.latest_version[1] is None: + if pkg.latest_version['version'] is None: td_class.append("version-unknown") - elif pkg.latest_version[1] != pkg.current_version: + elif pkg.latest_version['version'] != pkg.current_version: td_class.append("version-needs-update") else: td_class.append("version-good") - if pkg.latest_version[0] == RM_API_STATUS_ERROR: + if pkg.latest_version['status'] == RM_API_STATUS_ERROR: latest_version_text = "Error" - elif pkg.latest_version[0] == RM_API_STATUS_NOT_FOUND: + elif pkg.latest_version['status'] == RM_API_STATUS_NOT_FOUND: latest_version_text = "Not found" else: - if pkg.latest_version[1] is None: + if pkg.latest_version['version'] is None: latest_version_text = "Found, but no version" else: latest_version_text = "%s" % \ - (pkg.latest_version[2], str(pkg.latest_version[1])) + (pkg.latest_version['id'], str(pkg.latest_version['version'])) latest_version_text += "
" - if pkg.latest_version[0] == RM_API_STATUS_FOUND_BY_DISTRO: + if pkg.latest_version['status'] == RM_API_STATUS_FOUND_BY_DISTRO: latest_version_text += "found by distro" else: latest_version_text += "found by guess"