mirror of
https://github.com/LmeSzinc/AzurLaneAutoScript.git
synced 2025-01-08 12:47:32 +08:00
Opt: Reduce status; Restart when recovered
This commit is contained in:
parent
70f1a68e94
commit
d6952ef025
7
alas.py
7
alas.py
@ -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():
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user