|
59 | 59 | # region suffix (Google_Pixel_9_Pro_XL_15_real_sjc1). |
60 | 60 | DEFAULT_DEVICE = "Google_Pixel_9_Pro_XL" |
61 | 61 |
|
| 62 | +ALL_REGIONS = ("us-west-1", "eu-central-1", "us-east-4") |
| 63 | + |
62 | 64 |
|
63 | 65 | class SauceError(Exception): |
64 | 66 | pass |
@@ -103,6 +105,13 @@ def device_catalog(self): |
103 | 105 | ) |
104 | 106 | return response.json() |
105 | 107 |
|
| 108 | + def device_statuses(self): |
| 109 | + """Device availability, which is a separate endpoint from the catalog.""" |
| 110 | + response = requests.get(f"{self.rda}/devices/status", auth=self.auth, timeout=60) |
| 111 | + if response.status_code != 200: |
| 112 | + return f"HTTP {response.status_code}: {response.text[:200]}" |
| 113 | + return response.json() |
| 114 | + |
106 | 115 | # --- app storage ------------------------------------------------------- |
107 | 116 |
|
108 | 117 | def upload_app(self, apk): |
@@ -367,6 +376,21 @@ def main(): |
367 | 376 | sys.exit(f"Real Device Access API probe failed: {error}") |
368 | 377 |
|
369 | 378 | print(describe_catalog(catalog, args.device_name)) |
| 379 | + |
| 380 | + # An empty catalog answers 200 just like a populated one, so distinguish "no devices |
| 381 | + # entitled to this API" from "wrong region" before concluding the API is unusable. |
| 382 | + if not catalog: |
| 383 | + statuses = device.device_statuses() |
| 384 | + count = len(statuses) if isinstance(statuses, list) else statuses |
| 385 | + print(f"{args.region}: /devices/status -> {count}") |
| 386 | + for region in ALL_REGIONS: |
| 387 | + if region == args.region: |
| 388 | + continue |
| 389 | + other = RealDeviceSession(region, username, access_key) |
| 390 | + try: |
| 391 | + print(f"{region}: {len(other.device_catalog())} device(s) in the catalog") |
| 392 | + except SauceError as error: |
| 393 | + print(f"{region}: {error}") |
370 | 394 | matches = matching_devices(catalog, args.device_name) |
371 | 395 | # Checked before --probe-only returns, so the probe fails loudly on a device name that |
372 | 396 | # matches nothing rather than passing and letting the real run discover it. |
|
0 commit comments