MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / monitor_log_file

Function monitor_log_file

tools/targets/keil.py:330–347  ·  view source on GitHub ↗
(log_file_path)

Source from the content-addressed store, hash-verified

328import threading
329import time
330def monitor_log_file(log_file_path):
331 if not os.path.exists(log_file_path):
332 open(log_file_path, 'w').close()
333 empty_line_count = 0
334 with open(log_file_path, 'r') as log_file:
335 while True:
336 line = log_file.readline()
337 if line:
338 print(line.strip())
339 if 'Build Time Elapsed' in line:
340 break
341 empty_line_count = 0
342 else:
343 empty_line_count += 1
344 time.sleep(1)
345 if empty_line_count > 30:
346 print("Timeout reached or too many empty lines, exiting log monitoring thread.")
347 break
348def MDK5Project(env, target, script):
349
350 if os.path.isfile('template.uvprojx') is False:

Callers

nothing calls this directly

Calls 2

sleepMethod · 0.80
openFunction · 0.50

Tested by

no test coverage detected