glances_api 0.4.0__tar.gz → 0.4.2__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.
- {glances_api-0.4.0 → glances_api-0.4.2}/LICENSE +1 -1
- {glances_api-0.4.0 → glances_api-0.4.2}/PKG-INFO +4 -4
- {glances_api-0.4.0 → glances_api-0.4.2}/glances_api/__init__.py +15 -15
- {glances_api-0.4.0 → glances_api-0.4.2}/glances_api/exceptions.py +4 -0
- {glances_api-0.4.0 → glances_api-0.4.2}/pyproject.toml +4 -4
- glances_api-0.4.0/setup.py +0 -30
- {glances_api-0.4.0 → glances_api-0.4.2}/README.rst +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2017-
|
|
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.
|
|
3
|
+
Version: 0.4.2
|
|
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.
|
|
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,22 +61,22 @@ class Glances:
|
|
|
61
61
|
raise exceptions.GlancesApiAuthorizationError(
|
|
62
62
|
"Please check your credentials"
|
|
63
63
|
)
|
|
64
|
-
|
|
64
|
+
|
|
65
|
+
if response.status_code != httpx.codes.OK:
|
|
65
66
|
raise exceptions.GlancesApiNoDataAvailable(
|
|
66
67
|
f"endpoint: '{endpoint}' is not valid"
|
|
67
68
|
)
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
)
|
|
69
|
+
try:
|
|
70
|
+
_LOGGER.debug(response.json())
|
|
71
|
+
if endpoint == "all":
|
|
72
|
+
self.data = response.json()
|
|
73
|
+
elif endpoint == "pluginslist":
|
|
74
|
+
self.plugins = response.json()
|
|
75
|
+
except TypeError:
|
|
76
|
+
_LOGGER.error("Can not load data from Glances")
|
|
77
|
+
raise exceptions.GlancesApiConnectionError(
|
|
78
|
+
"Unable to get the data from Glances"
|
|
79
|
+
)
|
|
80
80
|
|
|
81
81
|
async def get_metrics(self, element: str) -> None:
|
|
82
82
|
"""Get all the metrics for a monitored element."""
|
|
@@ -142,11 +142,11 @@ class Glances:
|
|
|
142
142
|
sensor_data["docker"] = {"docker_active": len(active_containers)}
|
|
143
143
|
cpu_use = 0.0
|
|
144
144
|
for container in active_containers:
|
|
145
|
-
cpu_use += container["cpu"]
|
|
145
|
+
cpu_use += container["cpu"].get("total", 0)
|
|
146
146
|
sensor_data["docker"]["docker_cpu_use"] = round(cpu_use, 1)
|
|
147
147
|
mem_use = 0.0
|
|
148
148
|
for container in active_containers:
|
|
149
|
-
mem_use += container["memory"]
|
|
149
|
+
mem_use += container["memory"].get("usage", 0)
|
|
150
150
|
sensor_data["docker"]["docker_memory_use"] = round(mem_use / 1024**2, 1)
|
|
151
151
|
if data := self.data.get("raid"):
|
|
152
152
|
sensor_data["raid"] = 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.
|
|
3
|
+
version = "0.4.2"
|
|
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.
|
|
21
|
+
python = "^3.9"
|
|
22
22
|
httpx = ">=0.23,<1"
|
|
23
23
|
|
|
24
24
|
[tool.poetry.dev-dependencies]
|
|
25
|
-
black = "^
|
|
26
|
-
pytest = "^
|
|
25
|
+
black = "^23.3"
|
|
26
|
+
pytest = "^7.1.2"
|
|
27
27
|
pytest-httpx = ">0.15,<1"
|
|
28
28
|
pytest-asyncio = "^0.16.0"
|
|
29
29
|
isort = "^5.10.0"
|
glances_api-0.4.0/setup.py
DELETED
|
@@ -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.0',
|
|
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
|