-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmuster.py
27 lines (25 loc) · 824 Bytes
/
muster.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
from memory import Protocol
from memory import extract, Data, reduce
import logging
"""
Muster collects multiple requests for variables, dispatches the queries and
returns updated variables
"""
class Muster:
def __init__(self, protocol: Protocol=None):
self.__protocol = protocol or Protocol()
"""
Query the wire protocol for a list of Variables and update the values in the
variables
"""
def update(self, variables: list):
ranges = []
datas = []
for var in variables:
ranges.append(var.range)
for range in reduce(ranges):
logging.debug("query: %s" % range)
res = self.__protocol.query(range)
datas.append(Data(range, res))
for var in variables:
var.bytes = extract(var.range, datas).bytes