-
-
Notifications
You must be signed in to change notification settings - Fork 223
Add new methods to dump_devinfo #1373
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
029a42e
761a29e
bb9ba54
256e109
da498e7
1a0c6da
99d5cc0
78a8eb4
9fc8260
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,6 +50,8 @@ | |
"bssid": lambda _: "000000000000", | ||
"channel": lambda _: 0, | ||
"oem_id": lambda x: "REDACTED_" + x[9::], | ||
"hw_id": lambda x: "REDACTED_" + x[9::], | ||
"fw_id": lambda x: "REDACTED_" + x[9::], | ||
"setup_code": lambda x: re.sub(r"\w", "0", x), # matter | ||
"setup_payload": lambda x: re.sub(r"\w", "0", x), # matter | ||
"mfi_setup_code": lambda x: re.sub(r"\w", "0", x), # mfi_ for homekit | ||
|
@@ -183,18 +185,18 @@ async def _execute_multiple_query(self, requests: dict, retry_count: int) -> dic | |
multi_result: dict[str, Any] = {} | ||
smart_method = "multipleRequest" | ||
|
||
end = len(requests) | ||
# The SmartCamProtocol sends requests with a length 1 as a | ||
# multipleRequest. The SmartProtocol doesn't so will never | ||
# raise_on_error | ||
raise_on_error = end == 1 | ||
|
||
multi_requests = [ | ||
{"method": method, "params": params} if params else {"method": method} | ||
for method, params in requests.items() | ||
if method not in FORCE_SINGLE_REQUEST | ||
] | ||
|
||
end = len(multi_requests) | ||
# The SmartCamProtocol sends requests with a length 1 as a | ||
# multipleRequest. The SmartProtocol doesn't so will never | ||
# raise_on_error | ||
raise_on_error = end == 1 | ||
|
||
# Break the requests down as there can be a size limit | ||
step = self._multi_request_batch_size | ||
if step == 1: | ||
|
@@ -285,7 +287,9 @@ async def _execute_multiple_query(self, requests: dict, retry_count: int) -> dic | |
resp = await self._transport.send( | ||
self.get_smart_request(method, params) | ||
) | ||
self._handle_response_error_code(resp, method, raise_on_error=False) | ||
self._handle_response_error_code( | ||
resp, method, raise_on_error=raise_on_error | ||
) | ||
Comment on lines
+290
to
+292
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With |
||
multi_result[method] = resp.get("result") | ||
return multi_result | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -221,35 +221,38 @@ async def _send_request(self, request_dict: dict): | |
return {**result, "error_code": 0} | ||
else: | ||
return {"error_code": -1} | ||
elif method[:3] == "get": | ||
|
||
if method in info: | ||
params = request_dict.get("params") | ||
if method in info: | ||
result = copy.deepcopy(info[method]) | ||
sdb9696 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if "start_index" in result and "sum" in result: | ||
list_key = next( | ||
iter([key for key in result if isinstance(result[key], list)]) | ||
) | ||
start_index = ( | ||
start_index | ||
if (params and (start_index := params.get("start_index"))) | ||
else 0 | ||
) | ||
|
||
result[list_key] = result[list_key][ | ||
start_index : start_index + self.list_return_size | ||
] | ||
return {"result": result, "error_code": 0} | ||
if ( | ||
# FIXTURE_MISSING is for service calls not in place when | ||
# SMART fixtures started to be generated | ||
missing_result := self.FIXTURE_MISSING_MAP.get(method) | ||
) and missing_result[0] in self.components: | ||
# Copy to info so it will work with update methods | ||
info[method] = copy.deepcopy(missing_result[1]) | ||
result = copy.deepcopy(info[method]) | ||
return {"result": result, "error_code": 0} | ||
result = copy.deepcopy(info[method]) | ||
if "start_index" in result and "sum" in result: | ||
list_key = next( | ||
iter([key for key in result if isinstance(result[key], list)]) | ||
) | ||
start_index = ( | ||
start_index | ||
if (params and (start_index := params.get("start_index"))) | ||
else 0 | ||
) | ||
|
||
result[list_key] = result[list_key][ | ||
start_index : start_index + self.list_return_size | ||
] | ||
return {"result": result, "error_code": 0} | ||
|
||
if self.verbatim: | ||
return {"error_code": -1} | ||
Comment on lines
+243
to
244
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Both lines are added here even though the diff makes it look like only the |
||
|
||
if ( | ||
# FIXTURE_MISSING is for service calls not in place when | ||
# SMART fixtures started to be generated | ||
missing_result := self.FIXTURE_MISSING_MAP.get(method) | ||
) and missing_result[0] in self.components: | ||
# Copy to info so it will work with update methods | ||
info[method] = copy.deepcopy(missing_result[1]) | ||
result = copy.deepcopy(info[method]) | ||
return {"result": result, "error_code": 0} | ||
|
||
return {"error_code": -1} | ||
|
||
async def close(self) -> None: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With
FORCE_SINGLE_REQUEST
this needs to happen before building themulti_requests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, but why, when neither end nor raise_on_error is used in the comprehension?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
raise_on_error
is used to ensure that single requests always raise an error which is the default behaviour. When we introducedFORCE_SINGLE
I missed the fact that they will not error correctly becauseend = len(multi_requests)
gives zero.