-
Notifications
You must be signed in to change notification settings - Fork 93
/
allwatcher.py
37 lines (28 loc) · 914 Bytes
/
allwatcher.py
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
# Copyright 2023 Canonical Ltd.
# Licensed under the Apache V2, see LICENCE file for details.
"""
This example:
1. Connects to the current model
2. Starts an AllWatcher
3. Prints all changes received from the AllWatcher
4. Runs forever (kill with Ctrl-C)
"""
import logging
from juju import jasyncio
from juju.client import client
from juju.model import Model
async def watch():
model = Model()
await model.connect()
allwatcher = client.AllWatcherFacade.from_connection(model.connection())
while True:
change = await allwatcher.Next()
for delta in change.deltas:
print(delta.deltas)
if __name__ == '__main__':
logging.basicConfig(level=logging.DEBUG)
ws_logger = logging.getLogger('websockets.protocol')
ws_logger.setLevel(logging.INFO)
# Run loop until the process is manually stopped (watch will loop
# forever).
jasyncio.run(watch())