import datetime
|
import os
|
import shutil
|
|
import constant
|
from utils import tool
|
|
|
class LogUtil:
|
@classmethod
|
def extract_log_from_key(cls, key, path, target_path):
|
fw = open(target_path, mode='w', encoding="utf-8")
|
try:
|
with open(path, 'r', encoding="utf-8") as f:
|
lines = f.readlines()
|
for line in lines:
|
if line.find("{}".format(key)) > 0:
|
fw.write(line)
|
finally:
|
fw.close()
|
|
|
def __analyse_pricess_time():
|
date = datetime.datetime.now().strftime("%Y-%m-%d")
|
file_path = f"{constant.get_path_prefix()}/logs/gp/l2/l2_process.{date}.log"
|
with open(file_path, encoding="utf-8") as f:
|
line = f.readline()
|
while line:
|
time_ = line.split(":")[-1]
|
if int(time_) > 150:
|
print(line)
|
line = f.readline()
|
|
|
# 读取看盘消息
|
def get_kp_msg_list(date=None):
|
if not date:
|
date = datetime.datetime.now().strftime("%Y-%m-%d")
|
path_str = f"{constant.get_path_prefix()}/logs/gp/kp/kp_msg.{date}.log"
|
msg_list = []
|
if os.path.exists(path_str):
|
with open(path_str, mode='r', encoding="utf-8") as f:
|
while True:
|
line = f.readline()
|
if not line:
|
break
|
msg_list.append(line)
|
return msg_list
|