Skip to content

Commit

Permalink
Merge pull request #448 from EightyDollars/dev_shawn
Browse files Browse the repository at this point in the history
fix:补充上一次提交
  • Loading branch information
ZhaoZuohong authored Dec 19, 2023
2 parents e854f9e + dc73066 commit 5f4a4b8
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions arknights_mower/solvers/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from arknights_mower.utils.device import Device
from arknights_mower.data import __rootdir__
from arknights_mower.utils.digit_reader import DigitReader
from arknights_mower.utils.image import loadimg
from arknights_mower.utils.email import report_template
from arknights_mower.utils.log import logger
from arknights_mower.utils.path import get_path
from arknights_mower.utils.recognize import RecognizeError, Recognizer, Scene
Expand All @@ -30,13 +30,17 @@ def remove_blank(target: str):


class ReportSolver(BaseSolver):
def __init__(self, device: Device = None, recog: Recognizer = None) -> None:
def __init__(self, device: Device = None, recog: Recognizer = None,send_message_config={},send_report:bool=False) -> None:
super().__init__(device, recog)
self.record_path = get_path("@app/tmp/report.csv")
self.low_range_gray = (100, 100, 100)
self.high_range_gray = (255, 255, 255)
self.date = (datetime.datetime.now() - datetime.timedelta(hours=4)).date().__str__()
self.digitReader = DigitReader()
self.send_message_config = send_message_config
logger.info(self.send_message_config)

self.send_report=send_report
self.report_res = {
"作战录像": None,
"赤金": None,
Expand Down Expand Up @@ -141,8 +145,17 @@ def locate_report(self, img, template_name):

def record_report(self):
logger.info(f"存入{self.date}的数据{self.report_res}")
res_df = pd.DataFrame(self.report_res, index=[self.date])
res_df.to_csv(self.record_path, mode='a', header=not os.path.exists(self.record_path), encoding='gbk')
try:
res_df = pd.DataFrame(self.report_res, index=[self.date])
res_df.to_csv(self.record_path, mode='a', header=not os.path.exists(self.record_path), encoding='gbk')
except Exception as e:
logger.error(f"存入数据失败:{e}")
if self.send_report:
try:
self.send_message(report_template.render(report_data=self.report_res, title_text="基建报告"), "基建报告",
"html")
except Exception as e:
logger.error(f"基报邮件发送失败:{e}")

def has_record(self):
try:
Expand Down

0 comments on commit 5f4a4b8

Please sign in to comment.