diff mbox series

b4-wrapper-poky.py: output errors to stderr

Message ID 20250325-b4-poky-stderr-v1-1-85c23d0f950b@cherry.de
State Accepted, archived
Commit 225990c55a5cbf8498e2aa775e6406c27a4c0ea7
Headers show
Series b4-wrapper-poky.py: output errors to stderr | expand

Commit Message

Quentin Schulz March 25, 2025, 9:07 a.m. UTC
From: Quentin Schulz <quentin.schulz@cherry.de>

Print error messages to stderr instead of stdout.

The commands run as part of send-auto-cc-cmd and send-auto-to-cmd b4
commands will make b4 raise an Exception if they return a non-zero
return code and it will only print the content of stderr before that.

Because print defaults to stdout, b4 would raise the exception and not
tell the user why. This commit should now provide a hint to the user
about what went wrong.

Reported-by: Khem Raj <raj.khem@gmail.com>
Signed-off-by: Quentin Schulz <quentin.schulz@cherry.de>
---
 scripts/b4-wrapper-poky.py | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)


---
base-commit: 6edb7e77f1342cb63f11067c50f9a2b10f10b3b9
change-id: 20250325-b4-poky-stderr-8727cbbf3bb0

Best regards,
diff mbox series

Patch

diff --git a/scripts/b4-wrapper-poky.py b/scripts/b4-wrapper-poky.py
index ec6568eb9b7cab389178c08173a43caa2fc6bd48..f1170db06bf0d41c7251dca54cf43912c04ace7b 100755
--- a/scripts/b4-wrapper-poky.py
+++ b/scripts/b4-wrapper-poky.py
@@ -53,7 +53,7 @@  subject = None
 ref = None
 
 if not shutil.which("lsdiff"):
-    print("lsdiff missing from host, please install patchutils")
+    print("lsdiff missing from host, please install patchutils", file=sys.stderr)
     sys.exit(-1)
 
 try:
@@ -80,7 +80,7 @@  try:
                 break
 
         if not ref:
-            print("Failed to find ref to cover letter (References:)...")
+            print("Failed to find ref to cover letter (References:)...", file=sys.stderr)
             sys.exit(-2)
 
         ref = ref.group(1)
@@ -143,7 +143,8 @@  try:
 
     if cmd == "prep-perpatch-check-cmd":
         if len(projs) > 1:
-            print(f"Diff spans more than one project ({', '.join(sorted(projs))}), split into multiple commits...")
+            print(f"Diff spans more than one project ({', '.join(sorted(projs))}), split into multiple commits...",
+                  file=sys.stderr)
             sys.exit(-3)
 
         # No need to check other patches in the series as there aren't any
@@ -164,7 +165,8 @@  try:
         series_check.write_text('\n'.join(uniq_series_projs))
 
         if len(uniq_series_projs) > 1:
-            print(f"Series spans more than one project ({', '.join(sorted(uniq_series_projs))}), split into multiple series...")
+            print(f"Series spans more than one project ({', '.join(sorted(uniq_series_projs))}), split into multiple series...",
+                  file=sys.stderr)
             sys.exit(-4)
     else:  # send-auto-cc-cmd / send-auto-to-cmd
         ml_projs = {