(interface)
| 429 | # A device updated from the UI may not have finished (or may have missed) |
| 430 | # background tool provisioning, and the old behaviour was to just error out |
| 431 | # telling the user to run the installer. Install it here so the button works. |
| 432 | if not _have('speedtest-cli') and not _have('speedtest'): |
| 433 | do_install_tool('speedtest-cli') |
| 434 | |
| 435 | kind, exe = _speedtest_client() |
| 436 | if not kind: |
| 437 | return {'success': False, **meta, |
| 438 | 'error': 'speedtest is not installed. Click Install to add it.', |
| 439 | 'missing_tool': 'speedtest-cli'} |
| 440 | |
| 441 | if kind == 'ookla': |
| 442 | cmd = [exe, '--format=json', '--accept-license', '--accept-gdpr'] |
| 443 | if bind: |
| 444 | cmd += ['--interface', iface] # a real device bind |
| 445 | res = _run(cmd, timeout=120) |
| 446 | if res['rc'] == 0: |
| 447 | try: |
| 448 | d = json.loads(res['out']) |
| 449 | dl = d.get('download', {}).get('bandwidth', 0) * 8 / 1e6 |
no test coverage detected