获取下一个任务的名字, 大驼峰。 :return:
(self)
| 291 | return False |
| 292 | |
| 293 | def get_next_task(self) -> str: |
| 294 | """ |
| 295 | 获取下一个任务的名字, 大驼峰。 |
| 296 | :return: |
| 297 | """ |
| 298 | while 1: |
| 299 | task = self.config.get_next() |
| 300 | self.config.task = task |
| 301 | if self.state_queue: |
| 302 | self.state_queue.put({"schedule": self.config.get_schedule_data()}) |
| 303 | |
| 304 | # from module.base.resource import release_resources |
| 305 | # if self.config.task.command != 'Alas': |
| 306 | # release_resources(next_task=task.command) |
| 307 | |
| 308 | if task.next_run > datetime.now(): |
| 309 | logger.info(f'Wait until {task.next_run} for task `{task.command}`') |
| 310 | # self.is_first_task = False |
| 311 | method = self.config.script.optimization.when_task_queue_empty |
| 312 | if method == 'close_game': |
| 313 | logger.info('Close game during wait') |
| 314 | self.device.app_stop() |
| 315 | self.device.release_during_wait() |
| 316 | if not self.wait_until(task.next_run): |
| 317 | del_cached_property(self, 'config') |
| 318 | continue |
| 319 | self.run('Restart') |
| 320 | elif method == 'goto_main': |
| 321 | logger.info('Goto main page during wait') |
| 322 | self.run('GotoMain') |
| 323 | self.device.release_during_wait() |
| 324 | if not self.wait_until(task.next_run): |
| 325 | del_cached_property(self, 'config') |
| 326 | continue |
| 327 | else: |
| 328 | logger.warning(f'Invalid Optimization_WhenTaskQueueEmpty: {method}, fallback to stay_there') |
| 329 | self.device.release_during_wait() |
| 330 | if not self.wait_until(task.next_run): |
| 331 | del_cached_property(self, 'config') |
| 332 | continue |
| 333 | break |
| 334 | |
| 335 | return task.command |
| 336 | |
| 337 | def run(self, command: str) -> bool: |
| 338 | """ |
no test coverage detected