diff --git a/module/gg_handler/change_attribute.py b/module/gg_handler/change_attribute.py index ff1a93798..fecd077c4 100644 --- a/module/gg_handler/change_attribute.py +++ b/module/gg_handler/change_attribute.py @@ -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: diff --git a/module/gg_handler/change_ship.py b/module/gg_handler/change_ship.py index 1f491fb70..b22c00fb0 100644 --- a/module/gg_handler/change_ship.py +++ b/module/gg_handler/change_ship.py @@ -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: diff --git a/module/gg_handler/gg_u2.py b/module/gg_handler/gg_u2.py index 6285b1348..f35b0990d 100644 --- a/module/gg_handler/gg_u2.py +++ b/module/gg_handler/gg_u2.py @@ -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()) + +