mirror of
https://github.com/torvalds/linux.git
synced 2025-11-01 00:58:39 +02:00
scripts: test_doc_build.py: improve cmd.log logic
Simplify the logic which handles with new lines. Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org> Signed-off-by: Jonathan Corbet <corbet@lwn.net> Link: https://lore.kernel.org/r/2436f37ab7945673f26bcfc94c10e6e76b93c2d8.1750571906.git.mchehab+huawei@kernel.org
This commit is contained in:
parent
792bf0194c
commit
0e93f1244d
1 changed files with 11 additions and 8 deletions
|
|
@ -157,14 +157,16 @@ class AsyncCommands:
|
|||
self.fp = fp
|
||||
|
||||
def log(self, out, verbose, is_info=True):
|
||||
out = out.removesuffix('\n')
|
||||
|
||||
if verbose:
|
||||
if is_info:
|
||||
print(out.rstrip("\n"))
|
||||
print(out)
|
||||
else:
|
||||
print(out.rstrip("\n"), file=sys.stderr)
|
||||
print(out, file=sys.stderr)
|
||||
|
||||
if self.fp:
|
||||
self.fp.write(out.rstrip("\n") + "\n")
|
||||
self.fp.write(out + "\n")
|
||||
|
||||
async def _read(self, stream, verbose, is_info):
|
||||
"""Ancillary routine to capture while displaying"""
|
||||
|
|
@ -301,10 +303,10 @@ class SphinxVenv:
|
|||
make = ["make"] + args.make_args + ["htmldocs"]
|
||||
|
||||
if args.verbose:
|
||||
print(f". {bin_dir}/activate")
|
||||
cmd.log(f". {bin_dir}/activate", verbose=True)
|
||||
await cmd.run(make, env=env, check=True, verbose=True)
|
||||
if args.verbose:
|
||||
print("deactivate")
|
||||
cmd.log("deactivate", verbose=True)
|
||||
|
||||
end_time = time.time()
|
||||
elapsed_time = end_time - start_time
|
||||
|
|
@ -356,10 +358,11 @@ class SphinxVenv:
|
|||
python_bin)
|
||||
|
||||
if args.make:
|
||||
print()
|
||||
print("Summary:")
|
||||
cmd = AsyncCommands(fp)
|
||||
cmd.log("\nSummary:", verbose=True)
|
||||
for ver, elapsed_time in sorted(self.built_time.items()):
|
||||
print(f"\tSphinx {ver} elapsed time: {elapsed_time}")
|
||||
cmd.log(f"\tSphinx {ver} elapsed time: {elapsed_time}",
|
||||
verbose=True)
|
||||
|
||||
if fp:
|
||||
fp.close()
|
||||
|
|
|
|||
Loading…
Reference in a new issue