From cd04570670f172c923cafa5b265665f0aa16c96e Mon Sep 17 00:00:00 2001 From: Justin Wozniak Date: Thu, 23 Jan 2025 13:35:41 -0600 Subject: [PATCH] More output on error --- dev/conda/find-pkg.py | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/dev/conda/find-pkg.py b/dev/conda/find-pkg.py index c91b2c885..ef4e38f2f 100644 --- a/dev/conda/find-pkg.py +++ b/dev/conda/find-pkg.py @@ -5,8 +5,10 @@ # and reported to the user in repodata.json # We can also find the pkg name from the message # from 'conda build' saying "anaconda upload" +# NOTE: Logging output must go on stderr, +# stdout is captured by the shell script! -import argparse, json, os, sys +import argparse, json, os parser = argparse.ArgumentParser(description="Show the package name") parser.add_argument("filename", help="The repodata.json file") @@ -14,8 +16,12 @@ help="Make verbose") args = parser.parse_args() +def say(msg): + import sys + sys.stderr.write("find-pkg.py: " + str(msg) + "\n") + def fail(msg): - sys.stderr.write("find-pkg.py: " + msg + "\n") + say(msg) exit(1) if not os.path.exists(args.filename): @@ -24,14 +30,24 @@ def fail(msg): with open(args.filename, "r") as fp: J = json.load(fp) +# This was "packages" in older versions: +pkg_key = "packages.conda" + +def show_repodata(J): + say("full JSON:") + say(J) + say("key: '%s'" % pkg_key) + say(J[pkg_key]) + if args.v: - print(str(J)) - print(str(J["packages"])) + show_repodata(J) -P = J["packages"] +P = J[pkg_key] if len(P) != 1: - print("find-pkg.py: found packages: " + str(P)) - fail("package count is %i not 1!" % len(P)) + say("found packages: " + str(P)) + say("package count is %i not 1!" % len(P)) + show_repodata(J) + fail("FAIL.") pkg = list(P.keys())[0] print(pkg)