Opt: Reduce status; Restart when recovered

This commit is contained in:
Horizon101011 2022-07-22 12:12:19 +08:00
parent 70f1a68e94
commit d6952ef025
2 changed files with 3 additions and 18 deletions

View File

@ -85,7 +85,7 @@ class AzurLaneAutoScript:
self.device.sleep(10)
return False
except GamePageUnknownError:
logger.info('Game server may be under maintenance, check server status now')
logger.info('Game server may be under maintenance or network may be broken, check server status now')
self.checker.check_now()
if self.checker.is_available():
logger.critical('Game page unknown')
@ -427,9 +427,8 @@ class AzurLaneAutoScript:
# So update it once recovered
if 'config' in self.__dict__:
del self.__dict__['config']
if self.checker.is_maintenance_over():
logger.info('Server maintenance is over. Restart game client to update.')
self.run('restart')
logger.info('Server or network is recovered. Restart game client')
self.run('restart')
if self.stop_event is not None:
if self.stop_event.is_set():

View File

@ -30,7 +30,6 @@ class ServerChecker:
# Status flags
self._recover: bool = False
self._maintained: bool = False
self.check_now()
@ -60,7 +59,6 @@ class ServerChecker:
logger.info(f'Server "{self._server}" is available.')
else:
self._state.append(False)
self._maintained = True
logger.info(f'Server "{self._server}" is under maintenance.')
# Check if API server was died
@ -130,7 +128,6 @@ class ServerChecker:
self._expired = 0
self._timer.limit = 0
self._recover = False
self._maintained = False
def is_available(self) -> bool:
"""
@ -157,14 +154,3 @@ class ServerChecker:
return True
return False
def is_maintenance_over(self) -> bool:
"""
Returns:
bool: True if server maintenance is over.
"""
if self._maintained:
self._maintained = False
return True
return False