Skip to content

Add get_logs function to client to return system logs #2

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

Merged
merged 1 commit into from
Apr 10, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions sagemcom_api/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down