MCPcopy Create free account
hub / github.com/apache/solr / tail_file

Function tail_file

dev-tools/scripts/releaseWizard.py:1429–1448  ·  view source on GitHub ↗
(file, lines)

Source from the content-addressed store, hash-verified

1427
1428
1429def tail_file(file, lines):
1430 bufsize = 8192
1431 fsize = os.stat(file).st_size
1432 with open(file) as f:
1433 if bufsize >= fsize:
1434 bufsize = fsize
1435 idx = 0
1436 while True:
1437 idx += 1
1438 seek_pos = fsize - bufsize * idx
1439 if seek_pos < 0:
1440 seek_pos = 0
1441 f.seek(seek_pos)
1442 data = []
1443 data.extend(f.readlines())
1444 if len(data) >= lines or f.tell() == 0 or seek_pos == 0:
1445 if not seek_pos == 0:
1446 print("Tailing last %d lines of file %s" % (lines, file))
1447 print(''.join(data[-lines:]))
1448 break
1449
1450
1451def run_with_log_tail(command, cwd, logfile=None, tail_lines=10, tee=False, live=False, shell=None, capture_output=False):

Callers 1

run_with_log_tailFunction · 0.85

Calls 2

seekMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…