MCPcopy
hub / github.com/zai-org/Open-AutoGLM / list_devices

Method list_devices

phone_agent/xctest/connection.py:57–113  ·  view source on GitHub ↗

List all connected iOS devices. Returns: List of DeviceInfo objects. Note: Requires libimobiledevice to be installed. Install on macOS: brew install libimobiledevice

(self)

Source from the content-addressed store, hash-verified

55 self.wda_url = wda_url.rstrip("/")
56
57 def list_devices(self) -> list[DeviceInfo]:
58 """
59 List all connected iOS devices.
60
61 Returns:
62 List of DeviceInfo objects.
63
64 Note:
65 Requires libimobiledevice to be installed.
66 Install on macOS: brew install libimobiledevice
67 """
68 try:
69 # Get list of device UDIDs
70 result = subprocess.run(
71 ["idevice_id", "-ln"],
72 capture_output=True,
73 text=True,
74 timeout=5,
75 )
76
77 devices = []
78 for line in result.stdout.strip().split("\n"):
79 udid = line.strip()
80 if not udid:
81 continue
82
83 # Determine connection type (network devices have specific format)
84 conn_type = (
85 ConnectionType.NETWORK
86 if "-" in udid and len(udid) > 40
87 else ConnectionType.USB
88 )
89
90 # Get detailed device info
91 device_info = self._get_device_details(udid)
92
93 devices.append(
94 DeviceInfo(
95 device_id=udid,
96 status="connected",
97 connection_type=conn_type,
98 model=device_info.get("model"),
99 ios_version=device_info.get("ios_version"),
100 device_name=device_info.get("name"),
101 )
102 )
103
104 return devices
105
106 except FileNotFoundError:
107 print(
108 "Error: idevice_id not found. Install libimobiledevice: brew install libimobiledevice"
109 )
110 return []
111 except Exception as e:
112 print(f"Error listing devices: {e}")
113 return []
114

Callers 3

get_device_infoMethod · 0.95
is_connectedMethod · 0.95
list_devicesFunction · 0.95

Calls 3

_get_device_detailsMethod · 0.95
DeviceInfoClass · 0.70
runMethod · 0.45

Tested by

no test coverage detected