-
Notifications
You must be signed in to change notification settings - Fork 30
Expand file tree
/
Copy pathconnection_timeout.py
More file actions
36 lines (27 loc) · 994 Bytes
/
connection_timeout.py
File metadata and controls
36 lines (27 loc) · 994 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# Copyright (c) 2019 Cisco Systems
# Licensed under the MIT License
#
# Script to keep the audio volume level set to a maximum value
#
import xows
import aiohttp
import asyncio
async def task():
try:
async with xows.XoWSClient('192.168.1.3', username='localadmin', password='ciscopsdt') as client:
def callback(data, id):
print(f'New event received with id: ({id}): {data}')
print('Created subscription with number: ',
await client.subscribe(['Status', 'Audio', 'Volume'], callback, True))
await client.wait_until_closed()
except xows.XoWSError as error:
print('Timeout, could not connect to device. Exiting...')
print('error', error)
except TimeoutError:
print('TimeoutError')
except aiohttp.client_exceptions.ClientConnectorError:
print('ClientConnectorError')
try:
asyncio.run(task())
except KeyboardInterrupt:
print('Interrupted, exiting...')