@@ -101,7 +101,8 @@ async def wait(
101
101
except asyncio .TimeoutError :
102
102
command_string = " " .join (self .command )
103
103
print (
104
- f"Timeout: The process: '{ command_string } ' didn't complete within { timeout } seconds."
104
+ "Timeout: The process: '%s' didn't complete within %s seconds."
105
+ % (command_string , timeout )
105
106
)
106
107
107
108
async def run (self ):
@@ -128,7 +129,7 @@ async def run(self):
128
129
self .run_called = True
129
130
return self .process
130
131
except Exception as e :
131
- print (f "Error starting subprocess: { e } " )
132
+ print ("Error starting subprocess: %s" % e )
132
133
await self .cleanup ()
133
134
134
135
async def stream_logs (
@@ -145,7 +146,8 @@ async def stream_logs(
145
146
146
147
if stream not in self .log_files :
147
148
raise ValueError (
148
- f"No log file found for '{ stream } ', valid values are: { list (self .log_files .keys ())} "
149
+ "No log file found for '%s', valid values are: %s"
150
+ % (stream , list (self .log_files .keys ()))
149
151
)
150
152
151
153
log_file = self .log_files [stream ]
@@ -167,7 +169,8 @@ async def stream_logs(
167
169
line = await asyncio .wait_for (f .readline (), timeout_per_line )
168
170
except asyncio .TimeoutError as e :
169
171
raise LogReadTimeoutError (
170
- f"Timeout while reading a line from the log file for the stream: { stream } "
172
+ "Timeout while reading a line from the log file for the stream: %s"
173
+ % stream
171
174
) from e
172
175
173
176
# when we encounter an empty line
@@ -209,7 +212,8 @@ async def kill(self, termination_timeout: float = 5):
209
212
self .process .kill ()
210
213
else :
211
214
print (
212
- f"Process has already terminated with return code: { self .process .returncode } "
215
+ "Process has already terminated with return code: %s"
216
+ % self .process .returncode
213
217
)
214
218
else :
215
219
print ("No process to kill." )
@@ -259,7 +263,7 @@ async def main():
259
263
interesting_position = position
260
264
break
261
265
262
- print (f "ended streaming at: { interesting_position } " )
266
+ print ("ended streaming at: %s" % interesting_position )
263
267
264
268
# wait / do some other processing while the process runs in background
265
269
# if the process finishes before this sleep period, the streaming of logs
@@ -268,7 +272,8 @@ async def main():
268
272
269
273
# this blocks till the process completes unless we uncomment the `time.sleep` above..
270
274
print (
271
- f"resuming streaming from: { interesting_position } while process is still running..."
275
+ "resuming streaming from: %s while process is still running..."
276
+ % interesting_position
272
277
)
273
278
async for position , line in command_obj .stream_logs (
274
279
stream = "stdout" , position = interesting_position
@@ -292,12 +297,12 @@ async def main():
292
297
# two parallel streams for stdout
293
298
tasks = [
294
299
command_obj .emit_logs (
295
- stream = "stdout" , custom_logger = lambda x : print (f "[STREAM A]: { x } " )
300
+ stream = "stdout" , custom_logger = lambda x : print ("[STREAM A]: %s" % x )
296
301
),
297
302
# this can be another 'command_obj' too, in which case
298
303
# we stream logs from 2 different subprocesses in parallel :)
299
304
command_obj .emit_logs (
300
- stream = "stdout" , custom_logger = lambda x : print (f "[STREAM B]: { x } " )
305
+ stream = "stdout" , custom_logger = lambda x : print ("[STREAM B]: %s" % x )
301
306
),
302
307
]
303
308
await asyncio .gather (* tasks )
0 commit comments