Fix: Duration ocr & late stop in assignment

This commit is contained in:
Zebartin 2023-07-11 00:07:55 +08:00 committed by LmeSzinc
parent d9f9b43b6f
commit 1c304f2baa
2 changed files with 4 additions and 1 deletions

View File

@ -283,7 +283,7 @@ class Duration(Ocr):
@cached_property @cached_property
def timedelta_regex(self): def timedelta_regex(self):
regex_str = { regex_str = {
'ch': r'\D*((?P<days>\d{1,2})天)?((?P<hours>\d{1,2})小时)?((?P<minutes>\d{1,2})分钟)?((?P<seconds>\d{1,2})秒})?', 'ch': r'\D*((?P<days>\d{1,2})天)?((?P<hours>\d{1,2})小时)?((?P<minutes>\d{1,2})分钟)?((?P<seconds>\d{1,2})秒)?',
'en': r'\D*((?P<days>\d{1,2})d\s*)?((?P<hours>\d{1,2})h\s*)?((?P<minutes>\d{1,2})m\s*)?((?P<seconds>\d{1,2})s)?' 'en': r'\D*((?P<days>\d{1,2})d\s*)?((?P<hours>\d{1,2})h\s*)?((?P<minutes>\d{1,2})m\s*)?((?P<seconds>\d{1,2})s)?'
}[self.lang] }[self.lang]
return re.compile(regex_str) return re.compile(regex_str)

View File

@ -26,6 +26,7 @@ class Assignment(AssignmentClaim, SynthesizeUI):
if duration is None: if duration is None:
duration = self.config.Assignment_Duration duration = self.config.Assignment_Duration
self.dispatched = dict()
self.ensure_scroll_top(page_menu) self.ensure_scroll_top(page_menu)
self.ui_ensure(page_assignment) self.ui_ensure(page_assignment)
# Iterate in user-specified order, return undispatched ones # Iterate in user-specified order, return undispatched ones
@ -103,6 +104,8 @@ class Assignment(AssignmentClaim, SynthesizeUI):
if self.appear(DISPATCHED): if self.appear(DISPATCHED):
self.dispatched[assignment] = datetime.now() + Duration( self.dispatched[assignment] = datetime.now() + Duration(
OCR_ASSIGNMENT_TIME).ocr_single_line(self.device.image) OCR_ASSIGNMENT_TIME).ocr_single_line(self.device.image)
if total == len(self.dispatched):
return remain
continue continue
break break
return remain return remain