| 19 | |
| 20 | |
| 21 | def 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 | |
| 47 | def push_msg(echo, channel, keyword, name): |