[projects/pld-ftp-admin] Report errors and warnings on stderr

arekm arekm at pld-linux.org
Sat Nov 21 10:43:57 CET 2026


commit 3bb81665ffcfbe9575d615cbdb5424858083d7f9
Author: Arkadiusz Miśkiewicz <arekm at maven.pl>
Date:   Sat Nov 21 02:10:03 2026 +0100

    Report errors and warnings on stderr
    
    ERR: and WARN: lines went to stdout, mixed with the results.
    clean-test.sh takes the names it needs from the findings of
    pfa-testmvpkg and passes on the rest, such as a locked tree.

 bin/pfa-from-incoming | 6 +++---
 modules/ftptree.py    | 7 ++++---
 wwwbin/clean-dups.py  | 2 +-
 wwwbin/clean-test.sh  | 4 +++-
 4 files changed, 11 insertions(+), 8 deletions(-)
---
diff --git a/bin/pfa-from-incoming b/bin/pfa-from-incoming
index 7e0efe4..9bdf124 100755
--- a/bin/pfa-from-incoming
+++ b/bin/pfa-from-incoming
@@ -120,7 +120,7 @@ def move_noarch(f, arch, rpmfile, dstpkg):
 try:
     ftpio.connect(f'from-incoming-pid-{os.getpid()}')
 except OSError:
-    print("Can't get ftpiod connection")
+    print("Can't get ftpiod connection", file=sys.stderr)
     sys.exit(1)
 
 ftptree = BaseFtpTree(cval['default_to'])
@@ -191,7 +191,7 @@ try:
                     except OSError as e:
                         l = f"Removing {dstfile}/{rpmfile} problem: {e}"
                         ftpio.log(l)
-                        print(l)
+                        print(l, file=sys.stderr)
 
             with open(default_to + 'SRPMS/.metadata/' + srpm + '.info', 'a') as f:
                 for rpmfile in srcpkg.files['ARCH']:
@@ -214,7 +214,7 @@ try:
                         except OSError as e:
                             l = f"Moving {srcfile} to {dstfile} problem: {e}"
                             ftpio.log(l)
-                            print(l)
+                            print(l, file=sys.stderr)
 
             rm(incoming_dir + arch + '/' + uploadinfo)
 finally:
diff --git a/modules/ftptree.py b/modules/ftptree.py
index 322a09d..b2cb649 100644
--- a/modules/ftptree.py
+++ b/modules/ftptree.py
@@ -6,6 +6,7 @@ import multiprocessing
 import os
 import re
 import signal
+import sys
 import urllib.request
 
 import config
@@ -84,7 +85,7 @@ class SomeError(Exception):
 
 def bailoutonerror():
     if errnum != 0:
-        print(f"{errnum} error(s) encountered... aborting")
+        print(f"{errnum} error(s) encountered... aborting", file=sys.stderr)
         raise SomeError()
 
 def pinfo(msg):
@@ -93,10 +94,10 @@ def pinfo(msg):
 def perror(msg):
     global errnum
     errnum = errnum + 1
-    print('ERR: ' + msg)
+    print('ERR: ' + msg, file=sys.stderr)
 
 def pwarning(msg):
-    print('WARN: ' + msg)
+    print('WARN: ' + msg, file=sys.stderr)
 
 def rm(file, test = False):
     if test:
diff --git a/wwwbin/clean-dups.py b/wwwbin/clean-dups.py
index 1e2e2a9..1962b84 100755
--- a/wwwbin/clean-dups.py
+++ b/wwwbin/clean-dups.py
@@ -36,7 +36,7 @@ def find_old(tree, groups):
         # an order with an unreadable src.rpm in it is arbitrary and could drop the newest version
         bad = [unreadable[nvr] for nvr in nvrs if nvr in unreadable]
         if bad:
-            print(f"{'; '.join(bad)}; keeping {' '.join(nvrs)}")
+            print(f"{'; '.join(bad)}; keeping {' '.join(nvrs)}", file=sys.stderr)
             continue
         old += sorted(nvrs, key=functools.cmp_to_key(lambda a, b: rpm.labelCompare(evr[b], evr[a])))[1:]
     return old
diff --git a/wwwbin/clean-test.sh b/wwwbin/clean-test.sh
index cc3575f..cd3c866 100755
--- a/wwwbin/clean-test.sh
+++ b/wwwbin/clean-test.sh
@@ -11,6 +11,8 @@ remove() {
 	done
 }
 
-remove $(find . -name '*.info' -mtime +1 -printf '%P\0' | xargs -0 -r ~/pld-ftp-admin/bin/pfa-testmvpkg test ready | awk '/has only src.rpm built/ { print $2 }')
+# names of src.rpm only packages; the per-package findings of pfa-testmvpkg are dropped, the rest (a locked tree, the queue down) goes to stderr
+remove $(find . -name '*.info' -mtime +1 -printf '%P\0' | xargs -0 -r ~/pld-ftp-admin/bin/pfa-testmvpkg test ready 2>&1 >/dev/null |
+	awk '/has only src.rpm built/ { print $2; next } !/^(ERR|WARN): [^ ]+-[^ -]+-[^ -]+ / { print > "/dev/stderr" }')
 
 remove $(find . -name '*.info' -mtime +100 -printf '%P\n')
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/projects/pld-ftp-admin.git/commitdiff/a049a512859eaede288d71649a2320e16c959476



More information about the pld-cvs-commit mailing list