22 lines
642 B
Python
22 lines
642 B
Python
#!/usr/bin/env python3
|
|
"""Explicit test command, never a production backend mode."""
|
|
import json
|
|
import sys
|
|
import time
|
|
|
|
mode, action, *args = sys.argv[1:]
|
|
if mode == 'stall': time.sleep(10)
|
|
if mode == 'malformed':
|
|
print('not json', flush=True)
|
|
sys.exit(0)
|
|
if mode == 'failure':
|
|
print(json.dumps({'ok': False, 'error': 'Mock BlueZ NotReady'}), flush=True)
|
|
sys.exit(1)
|
|
if action == 'status':
|
|
print(json.dumps({'ok': True, 'adapterCount': 2}), flush=True)
|
|
elif action == 'discover':
|
|
print(json.dumps({'ok': True, 'event': 'started'}), flush=True)
|
|
time.sleep(10)
|
|
else:
|
|
print(json.dumps({'ok': True}), flush=True)
|