From: Simon Marchi <simon.marchi@efficios.com>
To: "Arsen Arsenović" <arsen@aarsen.me>
Cc: buildbot@sourceware.org
Subject: Re: [PATCH 7/8] autoregen.py: let subprocesses print to stdout/stderr
Date: Tue, 12 Mar 2024 11:40:45 -0400 [thread overview]
Message-ID: <d269f088-ac20-4e5c-b554-3455e2136e4e@efficios.com> (raw)
In-Reply-To: <87plvz7k10.fsf@aarsen.me>
It seems like Arsen didn't reply-all. Adding back the buildbot mailing list.
On 3/12/24 07:43, Arsen Arsenović wrote:
> Simon Marchi <simon.marchi@efficios.com> writes:
>
>> Use `subprocess.run` with `stdout=sys.stdout` and `stderr=sys.stderr`,
>> such that subprocesses print to the job's stdout and stderr directly.
>>
>> This is not expected to cause any change, as the current commands don't
>> output anything. But if they do, I think it's useful to have that
>> output in the buildbot's logs.
>> ---
>> builder/containers/autoregen.py | 10 +++++++++-
>> 1 file changed, 9 insertions(+), 1 deletion(-)
>>
>> diff --git a/builder/containers/autoregen.py b/builder/containers/autoregen.py
>> index ff6939b66105..437f0dabe2de 100755
>> --- a/builder/containers/autoregen.py
>> +++ b/builder/containers/autoregen.py
>> @@ -4,6 +4,7 @@ import os
>> import shutil
>> import subprocess
>> from pathlib import Path
>> +import sys
>>
>>
>> # On Gentoo, vanilla unpatched autotools are packaged separately.
>> @@ -47,7 +48,14 @@ SKIP_DIRS = [
>> def run_shell(cmd: str):
>> cmd = f"{ENV} {cmd}"
>> print(f"+ {cmd}")
>> - subprocess.check_output(f"{ENV} {cmd}", shell=True, encoding="utf8")
>> + res = subprocess.run(
>> + f"{ENV} {cmd}",
>> + shell=True,
>> + encoding="utf8",
>> + stdout=sys.stdout,
>> + stderr=sys.stderr,
>> + )
>> + res.check_returncode()
>
> The default behaviour of Python Popen (and hence subprocess.run) is not
> to touch the file descriptors on standard input, output and error.
> Leaving this as 'None' (the default) is hence better, IMO.
Oh ok, I didn't understand it properly when reading the doc.
Here's a patch that removes them.
From deaad76616d9210d5f53532f9159ce8db7035412 Mon Sep 17 00:00:00 2001
From: Simon Marchi <simon.marchi@efficios.com>
Date: Tue, 12 Mar 2024 11:01:14 -0400
Subject: [PATCH] autoregen.py: do not pass sys.stdout/sys.stderr to
subprocess.run
Arsen pointed out that this is unnecessary. If we don't pass an
stdout/stderr, the subprocess will use the same file descriptors as the
parent, which is what we want.
---
builder/containers/autoregen.py | 3 ---
1 file changed, 3 deletions(-)
diff --git a/builder/containers/autoregen.py b/builder/containers/autoregen.py
index ac16f54f6caa..20481b142d8a 100755
--- a/builder/containers/autoregen.py
+++ b/builder/containers/autoregen.py
@@ -4,7 +4,6 @@ import os
import shutil
import subprocess
from pathlib import Path
-import sys
# On Gentoo, vanilla unpatched autotools are packaged separately.
@@ -51,8 +50,6 @@ def run_shell(cmd: str):
f"{ENV} {cmd}",
shell=True,
encoding="utf8",
- stdout=sys.stdout,
- stderr=sys.stderr,
)
res.check_returncode()
base-commit: 3e013842366735c373ef19ec6dfc4a33d6f9c473
--
2.44.0
next prev parent reply other threads:[~2024-03-12 15:40 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-11 19:01 [PATCH 0/8] Some changes to autoregen.py Simon Marchi
2024-03-11 19:01 ` [PATCH 1/8] autoregen.py: re-format with black 24.2.0 Simon Marchi
2024-03-11 19:01 ` [PATCH 2/8] autoregen.py: fix a pyright `reportConstantRedefinition` warning Simon Marchi
[not found] ` <871q8f7jx5.fsf@aarsen.me>
2024-03-12 16:00 ` Simon Marchi
2024-03-13 8:58 ` Mark Wielaard
2024-03-18 17:36 ` Arsen Arsenović
2024-03-11 19:01 ` [PATCH 3/8] autoregen.py: add type annotation for config_folders Simon Marchi
2024-03-11 19:01 ` [PATCH 4/8] autoregen.py: capitalize some constant names Simon Marchi
2024-03-11 19:01 ` [PATCH 5/8] autoregen.py: add non-suffixed version of the tools Simon Marchi
2024-03-11 19:01 ` [PATCH 6/8] autoregen.py: print executed commands on stdout Simon Marchi
2024-03-11 19:01 ` [PATCH 7/8] autoregen.py: let subprocesses print to stdout/stderr Simon Marchi
[not found] ` <87plvz7k10.fsf@aarsen.me>
2024-03-12 15:40 ` Simon Marchi [this message]
2024-03-13 8:46 ` Mark Wielaard
2024-03-11 19:01 ` [PATCH 8/8] autoregen.py: be more verbose Simon Marchi
2024-03-11 21:04 ` [PATCH 0/8] Some changes to autoregen.py Sam James
2024-03-11 21:52 ` Mark Wielaard
2024-03-12 1:53 ` Simon Marchi
2024-03-12 10:17 ` Mark Wielaard
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d269f088-ac20-4e5c-b554-3455e2136e4e@efficios.com \
--to=simon.marchi@efficios.com \
--cc=arsen@aarsen.me \
--cc=buildbot@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).