blob: c78d689fe9d18588791bbfb8cf15b4f8e5617aa0 [file] [log] [blame]
Adam Israeldcdf82b2017-08-15 15:26:43 -04001"""
2This example:
3
41. Connects to the current model
52. Starts an AllWatcher
63. Prints all changes received from the AllWatcher
74. Runs forever (kill with Ctrl-C)
8
9"""
10import asyncio
11import logging
12
13from juju.client.connection import Connection
14from juju.client import client
15from juju import loop
16
17
18async def watch():
19 conn = await Connection.connect_current()
20 allwatcher = client.AllWatcherFacade.from_connection(conn)
21 while True:
22 change = await allwatcher.Next()
23 for delta in change.deltas:
24 print(delta.deltas)
25
26
27if __name__ == '__main__':
28 logging.basicConfig(level=logging.DEBUG)
29 # Run loop until the process is manually stopped (watch will loop
30 # forever).
31 loop.run(watch())