blob: 884230ba832ae731e798df22a4c46cf011e86721 [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():
Adam Israelc3e6c2e2018-03-01 09:31:50 -050019 conn = await Connection.connect()
Adam Israeldcdf82b2017-08-15 15:26:43 -040020 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())