glances_api 0.5.1__tar.gz → 0.6.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: glances_api
3
- Version: 0.5.1
3
+ Version: 0.6.0
4
4
  Summary: Python API for interacting with Glances
5
5
  Home-page: https://github.com/home-assistant-ecosystem/python-glances-api
6
6
  License: MIT
@@ -1,4 +1,5 @@
1
1
  """Client to interact with the Glances API."""
2
+
2
3
  from __future__ import annotations
3
4
 
4
5
  import logging
@@ -153,10 +154,11 @@ class Glances:
153
154
  if networks := self.data.get("network"):
154
155
  sensor_data["network"] = {}
155
156
  for network in networks:
157
+ time_since_update = network["time_since_update"]
156
158
  sensor_data["network"][network["interface_name"]] = {
157
159
  "is_up": network.get("is_up"),
158
- "rx": round(network["rx"] / 1024, 1),
159
- "tx": round(network["tx"] / 1024, 1),
160
+ "rx": round(network["rx"] / time_since_update),
161
+ "tx": round(network["tx"] / time_since_update),
160
162
  "speed": round(network["speed"] / 1024**3, 1),
161
163
  }
162
164
  data = self.data.get("dockers") or self.data.get("containers")
@@ -182,11 +184,18 @@ class Glances:
182
184
  if data := self.data.get("gpu"):
183
185
  sensor_data["gpu"] = {}
184
186
  for sensor in data:
185
- sensor_data["gpu"][f"GPU_{sensor['gpu_id']}__{sensor['name']}"] = {
186
- "name": sensor["name"],
187
- "temperature": sensor["temperature"],
188
- "mem": sensor["mem"],
189
- "proc": sensor["proc"],
190
- "fan_speed": sensor["fan_speed"] if "fan_speed" in sensor else 0,
187
+ sensor_data["gpu"][f"{sensor['name']} (GPU {sensor['gpu_id']})"] = {
188
+ "temperature": sensor.get("temperature", 0),
189
+ "mem": sensor.get("mem", 0),
190
+ "proc": sensor.get("proc", 0),
191
+ "fan_speed": sensor.get("fan_speed", 0),
192
+ }
193
+ if data := self.data.get("diskio"):
194
+ sensor_data["diskio"] = {}
195
+ for disk in data:
196
+ time_since_update = disk["time_since_update"]
197
+ sensor_data["diskio"][disk["disk_name"]] = {
198
+ "read": round(disk["read_bytes"] / time_since_update),
199
+ "write": round(disk["write_bytes"] / time_since_update),
191
200
  }
192
201
  return sensor_data
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "glances_api"
3
- version = "0.5.1"
3
+ version = "0.6.0"
4
4
  description = "Python API for interacting with Glances"
5
5
  authors = ["Fabian Affolter <fabian@affolter-engineering.ch>"]
6
6
  homepage = "https://github.com/home-assistant-ecosystem/python-glances-api"
@@ -22,8 +22,8 @@ python = "^3.11"
22
22
  httpx = ">=0.23,<1"
23
23
 
24
24
  [tool.poetry.dev-dependencies]
25
- black = "^23.3"
26
- pytest = "^7.3.0"
25
+ black = "^24.3"
26
+ pytest = "^8"
27
27
  pytest-httpx = ">0.15,<1"
28
28
  pytest-asyncio = "^0.16.0"
29
29
  isort = "^5.10.0"
File without changes
File without changes