blob: 679008d01a75f29a1c9dfc9d8868a4d616f27b84 (
plain) (
blame)
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
|
from unit.control import Control
class Status:
_status = None
control = Control()
def _check_zeros():
status = Status.control.conf_get('/status')
assert status['connections'] == {
'accepted': 0,
'active': 0,
'idle': 0,
'closed': 0,
}
assert status['requests'] == {'total': 0}
assert status['applications'] == {}
def init(status=None):
Status._status = (
status if status is not None else Status.control.conf_get('/status')
)
def diff():
def find_diffs(d1, d2):
if isinstance(d1, dict) and isinstance(d2, dict):
return {
k: find_diffs(d1.get(k, 0), d2.get(k, 0))
for k in d1
if k in d2
}
if isinstance(d1, str) or isinstance(d1, list):
return d1 == d2
return d1 - d2
return find_diffs(Status.control.conf_get('/status'), Status._status)
def get(path='/'):
path_lst = path.split('/')[1:]
diff = Status.diff()
for part in path_lst:
diff = diff[part]
return diff
|