MCPcopy Create free account
hub / github.com/aaPanel/BaoTa / last_lines

Method last_lines

class/projectModel/pythonModel.py:1563–1586  ·  view source on GitHub ↗
(filename, lines=1)

Source from the content-addressed store, hash-verified

1561
1562 @staticmethod
1563 def last_lines(filename, lines=1):
1564 block_size = 3145928
1565 block = ''
1566 nl_count = 0
1567 start = 0
1568 fsock = open(filename, 'rU')
1569 try:
1570 fsock.seek(0, 2)
1571 curpos = fsock.tell()
1572 while (curpos > 0):
1573 curpos -= (block_size + len(block))
1574 if curpos < 0: curpos = 0
1575 fsock.seek(curpos)
1576 try:
1577 block = fsock.read()
1578 except:
1579 continue
1580 nl_count = block.count('\n')
1581 if nl_count >= lines: break
1582 for n in range(nl_count - lines + 1):
1583 start = block.find('\n', start) + 1
1584 finally:
1585 fsock.close()
1586 return block[start:]
1587
1588 @staticmethod
1589 def _project_logfile(project_conf):

Callers 1

GetProjectLogMethod · 0.95

Calls 6

openFunction · 0.85
seekMethod · 0.80
readMethod · 0.45
countMethod · 0.45
findMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected