MCPcopy Index your code
hub / github.com/Tencent/CodeAnalysis / _read_tail_lines

Method _read_tail_lines

client/node/common/task.py:60–78  ·  view source on GitHub ↗

读取文件末尾的1024字节

(self, filepath)

Source from the content-addressed store, hash-verified

58 self._task_expired_time = None
59
60 def _read_tail_lines(self, filepath):
61 """读取文件末尾的1024字节
62 """
63 try:
64 with open(filepath, 'r') as fh:
65 fh.seek(0, os.SEEK_END)
66 size = fh.tell()
67 pos = 1024
68 if size>pos:
69 fh.seek(size-pos, os.SEEK_SET)
70 lines = fh.readlines()
71 return lines[1:]
72 else:
73 fh.seek(0, os.SEEK_SET)
74 return fh.readlines()
75 except Exception as err:
76 message = "read file(%s) tail lines error: %s" % (filepath, str(err))
77 logger.error(message)
78 return message
79
80 def terminate(self):
81 """kill the task"""

Callers 1

_check_task_doneMethod · 0.95

Calls 1

errorMethod · 0.80

Tested by

no test coverage detected