File: test.py

package info (click to toggle)
python-agent-py 0.0.23-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 112 kB
  • sloc: python: 397; makefile: 6
file content (71 lines) | stat: -rw-r--r-- 1,540 bytes parent folder | download
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import unittest
import aiohttp

from agent import a
from agent.device import TimePeriod


import asyncio

async def Test (url):
	tc = a.Agent(url)
	sess = aiohttp.ClientSession()
	tc2 = a.Agent(url,sess)

	await tc.update()
	print(tc.is_available)
	print(await tc.get_profiles())
	print(await tc.get_active_profile())
	print(tc.is_armed)
	print(tc.unique)
	await tc.arm()
	await tc.disarm()
	print(tc.name)
	print(tc.version)
	print(tc.raw_result)
	print(tc.remote_access)
	print(tc.device_count)

	m= await tc.get_devices()
	for o in m:
		print(o.name)
		print(o._client._server_url)
		print(o.id)
		print(o.typeID)
		print(o.mjpeg_image_url)
		print(o.still_image_url)
		print(o.mp4_url)
		print(o.webm_url)
		print(o.recording)
		print(o.location)
		print(o.width)
		print(o.height)
		print(o.mjpegStreamWidth)
		print(o.mjpegStreamHeight)
		print(o.alerted)
		print(o.online)
		print(o.detector_active)
		print(o.alerts_active)
		print(o.connected)
		print(o.has_ptz)
		print(o.raw_result)
		await o.snapshot()
		await o.alerts_on()
		await o.alerts_off()
		print(await o.get_events(TimePeriod.HOUR))
		await o.update()

	print(await tc.get_profiles())
	await tc.set_active_profile('home')
	print(await tc.get_active_profile())
	await tc.set_active_profile('away')
	print(await tc.get_active_profile())

	await tc.close()
	await tc2.close()
	await sess.close()

	print("end")

loop = asyncio.get_event_loop()
loop.run_until_complete(Test("http://localhost:8090/"))