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

Function handle_device_commands

ios.py:371–443  ·  view source on GitHub ↗

Handle iOS device-related commands. Returns: True if a device command was handled (should exit), False otherwise.

(args)

Source from the content-addressed store, hash-verified

369
370
371def handle_device_commands(args) -> bool:
372 """
373 Handle iOS device-related commands.
374
375 Returns:
376 True if a device command was handled (should exit), False otherwise.
377 """
378 conn = XCTestConnection(wda_url=args.wda_url)
379
380 # Handle --list-devices
381 if args.list_devices:
382 devices = list_devices()
383 if not devices:
384 print("No iOS devices connected.")
385 print("\nTroubleshooting:")
386 print(" 1. Connect device via USB")
387 print(" 2. Unlock device and trust this computer")
388 print(" 3. Run: idevice_id -l")
389 else:
390 print("Connected iOS devices:")
391 print("-" * 70)
392 for device in devices:
393 conn_type = device.connection_type.value
394 model_info = f"{device.model}" if device.model else "Unknown"
395 ios_info = f"iOS {device.ios_version}" if device.ios_version else ""
396 name_info = device.device_name or "Unnamed"
397
398 print(f" ✓ {name_info}")
399 print(f" UDID: {device.device_id}")
400 print(f" Model: {model_info}")
401 print(f" OS: {ios_info}")
402 print(f" Connection: {conn_type}")
403 print("-" * 70)
404 return True
405
406 # Handle --pair
407 if args.pair:
408 print("Pairing with iOS device...")
409 success, message = conn.pair_device(args.device_id)
410 print(f"{'✓' if success else '✗'} {message}")
411 return True
412
413 # Handle --wda-status
414 if args.wda_status:
415 print(f"Checking WebDriverAgent status at {args.wda_url}...")
416 print("-" * 50)
417
418 if conn.is_wda_ready():
419 print("✓ WebDriverAgent is running")
420
421 status = conn.get_wda_status()
422 if status:
423 print(f"\nStatus details:")
424 value = status.get("value", {})
425 print(f" Session ID: {status.get('sessionId', 'N/A')}")
426 print(f" Build: {value.get('build', {}).get('time', 'N/A')}")
427
428 current_app = value.get("currentApp", {})

Callers 1

mainFunction · 0.70

Calls 5

pair_deviceMethod · 0.95
is_wda_readyMethod · 0.95
get_wda_statusMethod · 0.95
XCTestConnectionClass · 0.90
list_devicesFunction · 0.90

Tested by

no test coverage detected