mirror of
https://gitee.com/sui-feng-cb/AzurLaneAutoScript1
synced 2026-04-23 18:46:59 +08:00
Fix: Catch ConnectionResetError in iter_device()
This commit is contained in:
@@ -545,10 +545,10 @@ class Connection:
|
|||||||
return o
|
return o
|
||||||
|
|
||||||
@retry
|
@retry
|
||||||
def iter_device(self):
|
def list_device(self):
|
||||||
"""
|
"""
|
||||||
Returns:
|
Returns:
|
||||||
iter of AdbDevice
|
list[AdbDeviceWithStatus]:
|
||||||
"""
|
"""
|
||||||
|
|
||||||
class AdbDeviceWithStatus(AdbDevice):
|
class AdbDeviceWithStatus(AdbDevice):
|
||||||
@@ -561,6 +561,7 @@ class Connection:
|
|||||||
|
|
||||||
__repr__ = __str__
|
__repr__ = __str__
|
||||||
|
|
||||||
|
devices = []
|
||||||
with self.adb_client._connect() as c:
|
with self.adb_client._connect() as c:
|
||||||
c.send_command("host:devices")
|
c.send_command("host:devices")
|
||||||
c.check_okay()
|
c.check_okay()
|
||||||
@@ -569,7 +570,9 @@ class Connection:
|
|||||||
parts = line.strip().split("\t")
|
parts = line.strip().split("\t")
|
||||||
if len(parts) != 2:
|
if len(parts) != 2:
|
||||||
continue
|
continue
|
||||||
yield AdbDeviceWithStatus(self.adb_client, parts[0], parts[1])
|
device = AdbDeviceWithStatus(self.adb_client, parts[0], parts[1])
|
||||||
|
devices.append(device)
|
||||||
|
return devices
|
||||||
|
|
||||||
def detect_device(self):
|
def detect_device(self):
|
||||||
"""
|
"""
|
||||||
@@ -579,7 +582,7 @@ class Connection:
|
|||||||
logger.hr('Detect device')
|
logger.hr('Detect device')
|
||||||
logger.info('Here are the available devices, '
|
logger.info('Here are the available devices, '
|
||||||
'copy to Alas.Emulator.Serial to use it or set Alas.Emulator.Serial="auto"')
|
'copy to Alas.Emulator.Serial to use it or set Alas.Emulator.Serial="auto"')
|
||||||
devices = list(self.iter_device())
|
devices = self.list_device()
|
||||||
|
|
||||||
# Show available devices
|
# Show available devices
|
||||||
available = [d for d in devices if d.status == 'device']
|
available = [d for d in devices if d.status == 'device']
|
||||||
|
|||||||
Reference in New Issue
Block a user