ecd6e82cd730bfde280f4991e651cccbe68f8edb
[osm/N2VC.git] / examples / allwatcher.py
1 """
2 This example:
3
4 1. Connects to the current model
5 2. Starts an AllWatcher
6 3. Prints all changes received from the AllWatcher
7 4. Runs forever (kill with Ctrl-C)
8
9 """
10 import asyncio
11 import logging
12
13 from juju.client.connection import Connection
14 from juju.client import watcher
15
16
17 async def watch():
18 allwatcher = watcher.AllWatcher()
19 allwatcher.connect(conn)
20 while True:
21 change = await allwatcher.Next()
22 for delta in change.deltas:
23 print(delta.deltas)
24
25
26 logging.basicConfig(level=logging.DEBUG)
27 loop = asyncio.get_event_loop()
28 conn = loop.run_until_complete(Connection.connect_current())
29 loop.run_until_complete(watch())