1
0
mirror of https://github.com/0O0o0oOoO00/Alas.git synced 2026-05-14 14:29:26 +08:00

Fix: Catch Xpath time_out to run following codes

This commit is contained in:
ZuoSiZhu
2025-02-27 22:55:54 +08:00
parent ad5564cf2f
commit be9b00e938
3 changed files with 35 additions and 13 deletions

View File

@@ -59,16 +59,21 @@ class ChangeAttribute(ModuleBase):
logger.info("Click confirm")
self.device.sleep(0.5)
_confirmed = True
self.d.wait_timeout = deep_get(self.config.data, "GameManager.ChangeAttribute.Timeout")
if _confirmed:
self.d.wait_timeout = deep_get(self.config.data, "GameManager.ChangeAttribute.Timeout")
logger.info(f'Xpath timeout set to {self.d.wait_timeout} seconds')
if _set and _confirmed:
try:
self.d.xpath('//*[@text="确定"]').click()
logger.info("Click confirm")
self.device.sleep(0.5)
self.d.xpath('//*[@text="确定"]').click()
finally:
logger.info("Click confirm")
except Exception as e:
pass
self.d.wait_timeout = 3
logger.info(f'Xpath timeout set to {self.d.wait_timeout} seconds')
if _set and _confirmed:
break
else:

View File

@@ -117,16 +117,21 @@ class ChangeShip(ModuleBase):
logger.info("Click confirm")
self.device.sleep(0.5)
_confirmed = True
self.d.wait_timeout = deep_get(self.config.data, "GameManager.ChangeShip.Timeout")
if _confirmed:
self.d.wait_timeout = deep_get(self.config.data, "GameManager.ChangeShip.Timeout")
logger.info(f'Xpath timeout set to {self.d.wait_timeout} seconds')
if _set and _confirmed:
try:
self.d.xpath('//*[@text="确定"]').click()
logger.info("Click confirm")
self.device.sleep(0.5)
self.d.xpath('//*[@text="确定"]').click()
finally:
logger.info("Click confirm")
except Exception as e:
pass
self.d.wait_timeout = 3
logger.info(f'Xpath timeout set to {self.d.wait_timeout} seconds')
if _set and _confirmed:
break
else:

View File

@@ -17,6 +17,7 @@ class GGU2(Base):
self.d = u2.connect(self.device.serial)
self.gg_package_name = deep_get(self.config.data, keys='GameManager.GGHandler.GGPackageName')
self.d.wait_timeout = 10.0
logger.info(f'Xpath timeout set to {self.d.wait_timeout} seconds')
def exit(self):
self.d.app_stop(f'{self.gg_package_name}')
@@ -129,7 +130,8 @@ class GGU2(Base):
logger.info('Click Restart')
self.device.sleep(0.3)
continue
finally:
except Exception as e:
pass
def change_type(self):
@@ -137,9 +139,9 @@ class GGU2(Base):
ShipChanger.PushLua()
ShipChanger.ChangeShipType()
try:
self.d.xpath('//*[@text="确定"]').click()
GGData(self.config).set_data(target='gg_on', value=True)
finally:
self.d.xpath('//*[@text="确定"]').click()
except Exception as e:
pass
GGData(self.config).set_data(target='gg_type', value=True)
# self.d.app_stop(self.gg_package_name)
@@ -151,9 +153,9 @@ class GGU2(Base):
AttributeChanger.PushLua()
AttributeChanger.ChangeAttribute()
try:
self.d.xpath('//*[@text="确定"]').click()
GGData(self.config).set_data(target='gg_on', value=True)
finally:
self.d.xpath('//*[@text="确定"]').click()
except Exception as e:
pass
# self.d.app_stop(self.gg_package_name)
return 1
@@ -211,18 +213,21 @@ class GGU2(Base):
logger.info("Click confirm")
self.device.sleep(0.5)
_confirmed = True
self.d.wait_timeout = 90.0
if _confirmed:
self.d.wait_timeout = deep_get(self.config.data, "GameManager.GGHandler.Timeout")
logger.info(f'Xpath timeout set to {self.d.wait_timeout} seconds')
if _set and _confirmed:
try:
self.d.xpath('//*[@text="确定"]').click()
GGData(self.config).set_data(target='gg_on', value=True)
finally:
self.d.xpath('//*[@text="确定"]').click()
except Exception as e:
pass
GGData(self.config).set_data(target='gg_on', value=True)
logger.attr('GG', 'Enabled')
logger.info("Close the script")
self.d.wait_timeout = 3
logger.info(f'Xpath timeout set to {self.d.wait_timeout} seconds')
if _set and _confirmed:
break
else:
@@ -238,4 +243,11 @@ if __name__ == '__main__':
config = AzurLaneConfig('主号')
device = Device(config)
GGU2(config, device).set_on()
ggu2 = GGU2(config, device)
try:
ggu2.set_on(func='change_type')
except Exception as e:
pass
print(GGData(config).get_data())