glances_api 0.4.1__tar.gz → 0.4.3__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
  MIT License
2
2
 
3
- Copyright (c) 2017-2022 Fabian Affolter <fabian@affolter-engineering.ch>
3
+ Copyright (c) 2017-2023 Fabian Affolter <fabian@affolter-engineering.ch>
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -1,12 +1,12 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: glances-api
3
- Version: 0.4.1
3
+ Version: 0.4.3
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
7
7
  Author: Fabian Affolter
8
8
  Author-email: fabian@affolter-engineering.ch
9
- Requires-Python: >=3.8,<4.0
9
+ Requires-Python: >=3.9,<4.0
10
10
  Classifier: Development Status :: 3 - Alpha
11
11
  Classifier: Environment :: Console
12
12
  Classifier: Intended Audience :: Developers
@@ -15,9 +15,9 @@ Classifier: Operating System :: MacOS :: MacOS X
15
15
  Classifier: Operating System :: Microsoft :: Windows
16
16
  Classifier: Operating System :: POSIX
17
17
  Classifier: Programming Language :: Python :: 3
18
- Classifier: Programming Language :: Python :: 3.10
19
- Classifier: Programming Language :: Python :: 3.8
20
18
  Classifier: Programming Language :: Python :: 3.9
19
+ Classifier: Programming Language :: Python :: 3.10
20
+ Classifier: Programming Language :: Python :: 3.11
21
21
  Classifier: Topic :: Utilities
22
22
  Requires-Dist: httpx (>=0.23,<1)
23
23
  Project-URL: Repository, https://github.com/home-assistant-ecosystem/python-glances-api/releases
@@ -61,7 +61,7 @@ class Glances:
61
61
  raise exceptions.GlancesApiAuthorizationError(
62
62
  "Please check your credentials"
63
63
  )
64
-
64
+
65
65
  if response.status_code != httpx.codes.OK:
66
66
  raise exceptions.GlancesApiNoDataAvailable(
67
67
  f"endpoint: '{endpoint}' is not valid"
@@ -135,6 +135,15 @@ class Glances:
135
135
  }
136
136
  if data := self.data.get("quicklook"):
137
137
  sensor_data["cpu"] = {"cpu_use_percent": data["cpu"]}
138
+ if networks := self.data.get("network"):
139
+ sensor_data["network"] = {}
140
+ for network in networks:
141
+ sensor_data["network"][network["interface_name"]] = {
142
+ "is_up": network["is_up"],
143
+ "rx": round(network["rx"] / 1024, 1),
144
+ "tx": round(network["tx"] / 1024, 1),
145
+ "speed": round(network["speed"] / 1024**3, 1),
146
+ }
138
147
  if "docker" in self.data and (data := self.data["docker"].get("containers")):
139
148
  active_containers = [
140
149
  container for container in data if container["Status"] == "running"
@@ -142,12 +151,14 @@ class Glances:
142
151
  sensor_data["docker"] = {"docker_active": len(active_containers)}
143
152
  cpu_use = 0.0
144
153
  for container in active_containers:
145
- cpu_use += container["cpu"]["total"]
154
+ cpu_use += container["cpu"].get("total", 0)
146
155
  sensor_data["docker"]["docker_cpu_use"] = round(cpu_use, 1)
147
156
  mem_use = 0.0
148
157
  for container in active_containers:
149
- mem_use += container["memory"]["usage"]
158
+ mem_use += container["memory"].get("usage", 0)
150
159
  sensor_data["docker"]["docker_memory_use"] = round(mem_use / 1024**2, 1)
151
160
  if data := self.data.get("raid"):
152
161
  sensor_data["raid"] = data
162
+ if data := self.data.get("uptime"):
163
+ sensor_data["uptime"] = data
153
164
  return sensor_data
@@ -6,15 +6,19 @@ class GlancesApiError(Exception):
6
6
 
7
7
  pass
8
8
 
9
+
9
10
  class GlancesApiConnectionError(GlancesApiError):
10
11
  """When a connection error is encountered."""
11
12
 
12
13
  pass
14
+
15
+
13
16
  class GlancesApiAuthorizationError(GlancesApiError):
14
17
  """When a connection error is encountered."""
15
18
 
16
19
  pass
17
20
 
21
+
18
22
  class GlancesApiNoDataAvailable(GlancesApiError):
19
23
  """When no data is available."""
20
24
 
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "glances_api"
3
- version = "0.4.1"
3
+ version = "0.4.3"
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"
@@ -18,12 +18,12 @@ classifiers = [
18
18
  ]
19
19
 
20
20
  [tool.poetry.dependencies]
21
- python = "^3.8"
21
+ python = "^3.9"
22
22
  httpx = ">=0.23,<1"
23
23
 
24
24
  [tool.poetry.dev-dependencies]
25
- black = "^22.6.0"
26
- pytest = "^7.1.2"
25
+ black = "^23.3"
26
+ pytest = "^7.3.0"
27
27
  pytest-httpx = ">0.15,<1"
28
28
  pytest-asyncio = "^0.16.0"
29
29
  isort = "^5.10.0"
@@ -1,30 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- from setuptools import setup
3
-
4
- packages = \
5
- ['glances_api']
6
-
7
- package_data = \
8
- {'': ['*']}
9
-
10
- install_requires = \
11
- ['httpx>=0.23,<1']
12
-
13
- setup_kwargs = {
14
- 'name': 'glances-api',
15
- 'version': '0.4.1',
16
- 'description': 'Python API for interacting with Glances',
17
- 'long_description': 'python-glances-api\n==================\n\nA Python client for interacting with `Glances <https://nicolargo.github.io/glances/>`_.\n\nThis module is not official, developed, supported or endorsed by Glances.\n\nInstallation\n------------\n\nThe module is available from the `Python Package Index <https://pypi.python.org/pypi>`_.\n\n.. code:: bash\n\n $ pip3 install glances_api\n\nOr on a Fedora-based system or on a CentOS/RHEL machine with has EPEL enabled.\n\n.. code:: bash\n\n $ sudo dnf -y install python3-glances-api\n\n\nFor Nix or NixOS is `pre-packed module <https://search.nixos.org/packages?channel=unstable&query=glances-api>`_\navailable. The lastest release is usually present in the ``unstable`` channel.\n\n.. code:: bash\n\n $ nix-env -iA nixos.python3Packages.glances-api\n\nUsage\n-----\n\nThe file ``example.py`` contains an example about how to use this module.\n\nLicense\n-------\n\n``python-glances-api`` is licensed under MIT, for more details check LICENSE.\n',
18
- 'author': 'Fabian Affolter',
19
- 'author_email': 'fabian@affolter-engineering.ch',
20
- 'maintainer': None,
21
- 'maintainer_email': None,
22
- 'url': 'https://github.com/home-assistant-ecosystem/python-glances-api',
23
- 'packages': packages,
24
- 'package_data': package_data,
25
- 'install_requires': install_requires,
26
- 'python_requires': '>=3.8,<4.0',
27
- }
28
-
29
-
30
- setup(**setup_kwargs)
File without changes