File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import logging
22import os
33from typing import Dict , List , Union
4- from io import StringIO , TextIOWrapper
4+ from io import StringIO , TextIOWrapper , BytesIO
5+ from functools import reduce
56
7+ import operator
68import requests
79
810from .base import DuetAPI
@@ -17,10 +19,13 @@ class DSFAPI(DuetAPI):
1719 """
1820 api_name = 'DSF_REST'
1921
20- def get_model (self , ** _ignored ) -> Dict :
22+ def get_model (self , key : str = None ) -> Dict :
2123 url = f'{ self .base_url } /machine/status'
2224 r = requests .get (url )
2325 j = r .json ()
26+ if key is not None :
27+ keys = key .split ('.' )
28+ return reduce (operator .getitem , keys , j )
2429 return j
2530
2631 def send_code (self , code : str ) -> Dict :
Original file line number Diff line number Diff line change 11import logging
22import os
33from typing import Dict , List , Union
4- from io import StringIO , TextIOWrapper
4+ from io import StringIO , TextIOWrapper , BytesIO
55
66import requests
77
You can’t perform that action at this time.
0 commit comments