From 67fe20c41ea7e61e8ee66230d7a63ae9f4c65a43 Mon Sep 17 00:00:00 2001 From: andrewkreuzer Date: Sat, 25 Mar 2023 10:41:58 -0400 Subject: [PATCH] Add get_logs function to client to return system logs --- sagemcom_api/client.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/sagemcom_api/client.py b/sagemcom_api/client.py index 4c90681..a732f05 100644 --- a/sagemcom_api/client.py +++ b/sagemcom_api/client.py @@ -396,6 +396,25 @@ async def get_port_mappings(self) -> List[PortMapping]: return port_mappings + async def get_logs(self) -> List[str]: + """ + Retrieve system logs. + """ + + actions = { + "id": 0, + "method": "getVendorLogDownloadURI", + "xpath": urllib.parse.quote("Device/DeviceInfo/VendorLogFiles/VendorLogFile[@uid='1']"), + } + + response = await self.__api_request_async([actions], False) + log_path = response["reply"]["actions"][0]["callbacks"][0]["parameters"]["uri"] + + log_uri = f"{self.protocol}://{self.host}{log_path}" + response = await self.session.get(log_uri, timeout=10) + + return await response.text() + async def reboot(self): """Reboot Sagemcom F@st device.""" action = {