INNER CODE UNIT · Python
update_tabs
balta2ar/brotab · brotab/main.py:266
def update_tabs(args):
"""
curl -X POST 'http://localhost:4626/update_tabs' --data '{"tab_id": 20, "properties": { "url": "https://www.google.com" }}'
"""
raw = read_stdin(timeout=0.01).strip()
if raw:
updates = loads(raw)
else:
d = vars(args)
if d['info'] is not None:
updates = [d['info']]
else:
updates = {k: v for k, v in d.items()
if v is not None and k not in ['func', 'info', 'target_hosts']}
if 'tabId' not in updates: raise ValueError('tabId is required')
updates = [make_update(**updates)]
brotab_logger.info('Updating tabs: %s', updates)
api = MultipleMediatorsAPI(create_clients(args.target_hosts))