From patchwork Fri Jul 19 13:06:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Victor Huesca X-Patchwork-Id: 1134050 Return-Path: X-Original-To: incoming-buildroot@patchwork.ozlabs.org Delivered-To: patchwork-incoming-buildroot@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) 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=none (p=none dis=none) header.from=bootlin.com 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 45qrqr13mmz9sDQ for ; Fri, 19 Jul 2019 23:06:47 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 8AC0A86AE6; Fri, 19 Jul 2019 13:06:45 +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 xIfst14yx5jP; Fri, 19 Jul 2019 13:06:44 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by fraxinus.osuosl.org (Postfix) with ESMTP id 1446D866A9; Fri, 19 Jul 2019 13:06:44 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by ash.osuosl.org (Postfix) with ESMTP id 9AC251BF2A6 for ; Fri, 19 Jul 2019 13:06:39 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 9842B838D9 for ; Fri, 19 Jul 2019 13:06:39 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id U-ogl7gsdeJ1 for ; Fri, 19 Jul 2019 13:06:38 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net [217.70.183.193]) by whitealder.osuosl.org (Postfix) with ESMTPS id C83F387594 for ; Fri, 19 Jul 2019 13:06:37 +0000 (UTC) X-Originating-IP: 86.250.200.211 Received: from localhost.localdomain (lfbn-1-17395-211.w86-250.abo.wanadoo.fr [86.250.200.211]) (Authenticated sender: victor.huesca@bootlin.com) by relay1-d.mail.gandi.net (Postfix) with ESMTPSA id EA6D5240009; Fri, 19 Jul 2019 13:06:35 +0000 (UTC) From: Victor Huesca To: buildroot@buildroot.org Date: Fri, 19 Jul 2019 15:06:30 +0200 Message-Id: <20190719130630.9967-4-victor.huesca@bootlin.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190719130630.9967-1-victor.huesca@bootlin.com> References: <20190719130630.9967-1-victor.huesca@bootlin.com> MIME-Version: 1.0 Subject: [Buildroot] [PATCH v3 3/3] support/scripts/pkg-stats: factorize date and commit 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: Victor Huesca , thomas.petazzoni@bootlin.com Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" The 'dump_html' and 'dump_json' both include commit infos as well as the current date. It make more sense to retrieve these information once. This patch simply does this factorization. Signed-off-by: Victor Huesca --- support/scripts/pkg-stats | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/support/scripts/pkg-stats b/support/scripts/pkg-stats index 478f98fbc2..7dcb2b4cbd 100755 --- a/support/scripts/pkg-stats +++ b/support/scripts/pkg-stats @@ -678,24 +678,21 @@ def dump_html_stats(f, stats): f.write("\n") -def dump_gen_info(f): +def dump_gen_info(f, date, git_commit): # Updated on Mon Feb 19 08:12:08 CET 2018, Git commit aa77030b8f5e41f1c53eb1c1ad664b8c814ba032 - o = subprocess.check_output(["git", "log", "master", "-n", "1", "--pretty=format:%H"]) - git_commit = o.splitlines()[0] - f.write("

Updated on %s, git commit %s

\n" % - (str(datetime.datetime.utcnow()), git_commit)) + f.write("

Updated on %s, git commit %s

\n" % (str(date), git_commit)) -def dump_html(packages, stats, output): +def dump_html(packages, stats, date, commit, output): with open(output, 'w') as f: f.write(html_header) dump_html_all_pkgs(f, packages) dump_html_stats(f, stats) - dump_gen_info(f) + dump_gen_info(f, date, commit) f.write(html_footer) -def dump_json(packages, stats, output): +def dump_json(packages, stats, date, commit, output): # Format packages as a dictionnary instead of a list # Exclude local field that does not contains real date excluded_fields = ['url_worker', 'name'] @@ -717,8 +714,8 @@ def dump_json(packages, stats, output): o = subprocess.check_output(["git", "log", "master", "-n", "1", "--pretty=format:%H"]) final = {'packages': pkgs, 'stats': statistics, - 'commit': o.splitlines()[0], - 'date': str(datetime.datetime.utcnow())} + 'commit': commit, + 'date': str(date)} with open(output, 'w') as f: json.dump(final, f, indent=2, separators=(',', ': ')) @@ -749,6 +746,9 @@ def __main__(): package_list = args.packages.split(",") else: package_list = None + date = datetime.datetime.utcnow() + commit = subprocess.check_output(['git', 'log', 'master', '-n', '1', + '--pretty=format:%H']).splitlines()[0] print("Build package list ...") packages = get_pkglist(args.npackages, package_list) print("Getting package make info ...") @@ -770,10 +770,10 @@ def __main__(): stats = calculate_stats(packages) if args.html: print("Write HTML") - dump_html(packages, stats, args.html) + dump_html(packages, stats, date, commit, args.html) if args.json: print("Write JSON") - dump_json(packages, stats, args.json) + dump_json(packages, stats, date, commit, args.json) __main__()