glances_api 0.5.1__tar.gz → 0.7.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.7.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,19 @@ 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"]
158
+ # New name of network sensors in Glances v4
159
+ rx = network.get("bytes_recv_rate_per_sec")
160
+ tx = network.get("bytes_sent_rate_per_sec")
161
+ # Compatibility with Glances v3
162
+ if rx is None and (rx_bytes := network.get("rx")) is not None:
163
+ rx = round(rx_bytes / time_since_update)
164
+ if tx is None and (tx_bytes := network.get("tx")) is not None:
165
+ tx = round(tx_bytes / time_since_update)
156
166
  sensor_data["network"][network["interface_name"]] = {
157
167
  "is_up": network.get("is_up"),
158
- "rx": round(network["rx"] / 1024, 1),
159
- "tx": round(network["tx"] / 1024, 1),
168
+ "rx": rx,
169
+ "tx": tx,
160
170
  "speed": round(network["speed"] / 1024**3, 1),
161
171
  }
162
172
  data = self.data.get("dockers") or self.data.get("containers")
@@ -182,11 +192,18 @@ class Glances:
182
192
  if data := self.data.get("gpu"):
183
193
  sensor_data["gpu"] = {}
184
194
  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,
195
+ sensor_data["gpu"][f"{sensor['name']} (GPU {sensor['gpu_id']})"] = {
196
+ "temperature": sensor.get("temperature", 0),
197
+ "mem": sensor.get("mem", 0),
198
+ "proc": sensor.get("proc", 0),
199
+ "fan_speed": sensor.get("fan_speed", 0),
200
+ }
201
+ if data := self.data.get("diskio"):
202
+ sensor_data["diskio"] = {}
203
+ for disk in data:
204
+ time_since_update = disk["time_since_update"]
205
+ sensor_data["diskio"][disk["disk_name"]] = {
206
+ "read": round(disk["read_bytes"] / time_since_update),
207
+ "write": round(disk["write_bytes"] / time_since_update),
191
208
  }
192
209
  return sensor_data
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "glances_api"
3
- version = "0.5.1"
3
+ version = "0.7.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