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

Function get_cron_log

script/shell_push.py:21–44  ·  view source on GitHub ↗
(echo)

Source from the content-addressed store, hash-verified

19
20
21def get_cron_log(echo):
22 log_path = "/www/server/cron/{}.log".format(echo)
23 if not os.path.exists(log_path): return (False, "")
24 logs = public.GetNumLines(log_path, 100)
25 if len(re.findall(r"(★\[.*?\])", logs)) < 2 and not len(logs.split('\n')) < 100:
26 logs = public.GetNumLines(log_path, 500)
27 logs = logs.split('\n')
28 logs.reverse()
29 pattern = r"(★\[.*?\])"
30 start = 0
31 end = 0
32 flag = 0
33 for i in range(len(logs)):
34 if re.findall(pattern, logs[i]):
35 if flag == 0:
36 start = i
37 flag = 1
38 else:
39 end = i
40 break
41 if end == 0: end = -1
42 logs = logs[start:end]
43 if not logs: return (False, "")
44 return (True, "\n".join(logs[start:end]))
45
46
47def push_msg(echo, channel, keyword, name):

Callers 1

push_msgFunction · 0.85

Calls 5

GetNumLinesMethod · 0.80
formatMethod · 0.45
existsMethod · 0.45
splitMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected