41
41
from datetime import datetime as dt , timezone
42
42
from pathlib import Path
43
43
from string import Template
44
- from textwrap import indent
45
44
from time import perf_counter , sleep
46
45
from typing import Iterable , Literal
47
46
from urllib .parse import urljoin
@@ -217,7 +216,7 @@ def filter(languages, language_tags=None):
217
216
218
217
def run (cmd , cwd = None ) -> subprocess .CompletedProcess :
219
218
"""Like subprocess.run, with logging before and after the command execution."""
220
- cmd = [ str ( arg ) for arg in cmd ]
219
+ cmd = list ( map ( str , cmd ))
221
220
cmdstring = shlex .join (cmd )
222
221
logging .debug ("Run: '%s'" , cmdstring )
223
222
result = subprocess .run (
@@ -233,9 +232,9 @@ def run(cmd, cwd=None) -> subprocess.CompletedProcess:
233
232
if result .returncode :
234
233
# Log last 20 lines, those are likely the interesting ones.
235
234
logging .error (
236
- "Run: %r KO:\n %s" ,
235
+ "Run: '%s' KO:\n %s" ,
237
236
cmdstring ,
238
- indent ( "\n " .join (result .stdout .split ("\n " )[- 20 :]), " " ),
237
+ "\n " .join (f" { line } " for line in result .stdout .split ("\n " )[- 20 :]),
239
238
)
240
239
result .check_returncode ()
241
240
return result
@@ -244,7 +243,7 @@ def run(cmd, cwd=None) -> subprocess.CompletedProcess:
244
243
def run_with_logging (cmd , cwd = None ):
245
244
"""Like subprocess.check_call, with logging before the command execution."""
246
245
cmd = list (map (str , cmd ))
247
- logging .debug ("Run: %s " , shlex .join (cmd ))
246
+ logging .debug ("Run: '%s' " , shlex .join (cmd ))
248
247
with subprocess .Popen (
249
248
cmd ,
250
249
cwd = cwd ,
@@ -255,7 +254,7 @@ def run_with_logging(cmd, cwd=None):
255
254
) as p :
256
255
try :
257
256
for line in p .stdout or ():
258
- logging .debug (">>>> %s" , line .rstrip ())
257
+ logging .debug (">>>> %s" , line .rstrip ())
259
258
except :
260
259
p .kill ()
261
260
raise
0 commit comments