glances_api 0.2.0__tar.gz → 0.2.1__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.
@@ -0,0 +1,29 @@
1
+ name: Python package and lint
2
+
3
+ on:
4
+ push:
5
+ branches: [ master ]
6
+ pull_request:
7
+ branches: [ master ]
8
+
9
+ jobs:
10
+ build:
11
+
12
+ runs-on: ubuntu-latest
13
+ strategy:
14
+ matrix:
15
+ python-version: [3.5, 3.6, 3.7, 3.8]
16
+
17
+ steps:
18
+ - uses: actions/checkout@v2
19
+ - name: Set up Python ${{ matrix.python-version }}
20
+ uses: actions/setup-python@v2
21
+ with:
22
+ python-version: ${{ matrix.python-version }}
23
+ - name: Install dependencies
24
+ run: |
25
+ python -m pip install --upgrade pip
26
+ pip install flake8 pytest
27
+ if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
28
+ - name: Black Code Formatter
29
+ uses: lgeiger/black-action@v1.0.1
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2017-2018 Fabian Affolter
3
+ Copyright (c) 2017-2021 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,16 +1,16 @@
1
1
  Metadata-Version: 1.1
2
2
  Name: glances_api
3
- Version: 0.2.0
3
+ Version: 0.2.1
4
4
  Summary: Python API for interacting with Glances.
5
- Home-page: https://github.com/fabaff/python-glances-api
5
+ Home-page: https://github.com/home-assistant-ecosystem/python-glances-api
6
6
  Author: Fabian Affolter
7
7
  Author-email: fabian@affolter-engineering.ch
8
8
  License: MIT
9
- Download-URL: https://github.com/fabaff/python-glances-api/releases
9
+ Download-URL: https://github.com/home-assistant-ecosystem/python-glances-api/releases
10
10
  Description: python-glances-api
11
11
  ==================
12
12
 
13
- Python API for interacting with `Glances <https://nicolargo.github.io/glances/>`_.
13
+ A Python client for interacting with `Glances <https://nicolargo.github.io/glances/>`_.
14
14
 
15
15
  This module is not official, developed, supported or endorsed by Glances.
16
16
 
@@ -23,6 +23,12 @@ Description: python-glances-api
23
23
 
24
24
  $ pip3 install glances_api
25
25
 
26
+ Or on a Fedora-based system or on a CentOS/RHEL machine with has EPEL enabled.
27
+
28
+ .. code:: bash
29
+
30
+ $ sudo dnf -y install python3-glances-api
31
+
26
32
  Usage
27
33
  -----
28
34
 
@@ -35,7 +41,7 @@ Description: python-glances-api
35
41
 
36
42
  .. code:: bash
37
43
 
38
- $ python3.6 -m venv .
44
+ $ python3 -m venv .
39
45
  $ source bin/activate
40
46
  $ python3 setup.py develop
41
47
 
@@ -1,7 +1,7 @@
1
1
  python-glances-api
2
2
  ==================
3
3
 
4
- Python API for interacting with `Glances <https://nicolargo.github.io/glances/>`_.
4
+ A Python client for interacting with `Glances <https://nicolargo.github.io/glances/>`_.
5
5
 
6
6
  This module is not official, developed, supported or endorsed by Glances.
7
7
 
@@ -14,6 +14,12 @@ The module is available from the `Python Package Index <https://pypi.python.org/
14
14
 
15
15
  $ pip3 install glances_api
16
16
 
17
+ Or on a Fedora-based system or on a CentOS/RHEL machine with has EPEL enabled.
18
+
19
+ .. code:: bash
20
+
21
+ $ sudo dnf -y install python3-glances-api
22
+
17
23
  Usage
18
24
  -----
19
25
 
@@ -26,7 +32,7 @@ For development is recommended to use a ``venv``.
26
32
 
27
33
  .. code:: bash
28
34
 
29
- $ python3.6 -m venv .
35
+ $ python3 -m venv .
30
36
  $ source bin/activate
31
37
  $ python3 setup.py develop
32
38
 
@@ -0,0 +1,31 @@
1
+ """Sample script to use the Python API client for Glances."""
2
+ import asyncio
3
+
4
+ import aiohttp
5
+
6
+ from glances_api import Glances
7
+
8
+ HOST = "127.0.0.1"
9
+ VERSION = 3
10
+
11
+
12
+ async def main():
13
+ """The main part of the example script."""
14
+ async with aiohttp.ClientSession() as session:
15
+ data = Glances(loop, session, version=VERSION)
16
+
17
+ # Get the metrics for the memory
18
+ await data.get_metrics("mem")
19
+
20
+ # Print the values
21
+ print("Memory values:", data.values)
22
+
23
+ # Get the metrics about the disks
24
+ await data.get_metrics("diskio")
25
+
26
+ # Print the values
27
+ print("Disk values:", data.values)
28
+
29
+
30
+ loop = asyncio.get_event_loop()
31
+ loop.run_until_complete(main())
@@ -8,20 +8,30 @@ import async_timeout
8
8
  from . import exceptions
9
9
 
10
10
  _LOGGER = logging.getLogger(__name__)
11
- _RESOURCE = '{schema}://{host}:{port}/api/{version}'
11
+ _RESOURCE = "{schema}://{host}:{port}/api/{version}"
12
12
 
13
13
 
14
14
  class Glances(object):
15
15
  """A class for handling the data retrieval."""
16
16
 
17
- def __init__(self, loop, session, host='localhost', port=61208, version=2,
18
- ssl=False, username=None, password=None):
17
+ def __init__(
18
+ self,
19
+ loop,
20
+ session,
21
+ host="localhost",
22
+ port=61208,
23
+ version=2,
24
+ ssl=False,
25
+ username=None,
26
+ password=None,
27
+ ):
19
28
  """Initialize the connection."""
20
- schema = 'https' if ssl else 'http'
29
+ schema = "https" if ssl else "http"
21
30
  self._loop = loop
22
31
  self._session = session
23
- self.url = _RESOURCE.format(schema=schema, host=host, port=port,
24
- version=version)
32
+ self.url = _RESOURCE.format(
33
+ schema=schema, host=host, port=port, version=version
34
+ )
25
35
  self.data = None
26
36
  self.values = None
27
37
  self.plugins = None
@@ -30,7 +40,7 @@ class Glances(object):
30
40
 
31
41
  async def get_data(self):
32
42
  """Retrieve the data."""
33
- url = '{}/{}'.format(self.url, 'all')
43
+ url = "{}/{}".format(self.url, "all")
34
44
 
35
45
  try:
36
46
  with async_timeout.timeout(5, loop=self._loop):
@@ -41,6 +51,8 @@ class Glances(object):
41
51
  response = await self._session.get(url, auth=auth)
42
52
 
43
53
  _LOGGER.debug("Response from Glances API: %s", response.status)
54
+ print(response.status)
55
+ print(response.text)
44
56
  self.data = await response.json()
45
57
  _LOGGER.debug(self.data)
46
58
  except (asyncio.TimeoutError, aiohttp.ClientError):
@@ -59,7 +71,7 @@ class Glances(object):
59
71
 
60
72
  async def get_plugins(self):
61
73
  """Retrieve the available plugins."""
62
- url = '{}/{}'.format(self.url, 'pluginslist')
74
+ url = "{}/{}".format(self.url, "pluginslist")
63
75
 
64
76
  try:
65
77
  with async_timeout.timeout(5, loop=self._loop):
@@ -1,16 +1,16 @@
1
1
  Metadata-Version: 1.1
2
2
  Name: glances-api
3
- Version: 0.2.0
3
+ Version: 0.2.1
4
4
  Summary: Python API for interacting with Glances.
5
- Home-page: https://github.com/fabaff/python-glances-api
5
+ Home-page: https://github.com/home-assistant-ecosystem/python-glances-api
6
6
  Author: Fabian Affolter
7
7
  Author-email: fabian@affolter-engineering.ch
8
8
  License: MIT
9
- Download-URL: https://github.com/fabaff/python-glances-api/releases
9
+ Download-URL: https://github.com/home-assistant-ecosystem/python-glances-api/releases
10
10
  Description: python-glances-api
11
11
  ==================
12
12
 
13
- Python API for interacting with `Glances <https://nicolargo.github.io/glances/>`_.
13
+ A Python client for interacting with `Glances <https://nicolargo.github.io/glances/>`_.
14
14
 
15
15
  This module is not official, developed, supported or endorsed by Glances.
16
16
 
@@ -23,6 +23,12 @@ Description: python-glances-api
23
23
 
24
24
  $ pip3 install glances_api
25
25
 
26
+ Or on a Fedora-based system or on a CentOS/RHEL machine with has EPEL enabled.
27
+
28
+ .. code:: bash
29
+
30
+ $ sudo dnf -y install python3-glances-api
31
+
26
32
  Usage
27
33
  -----
28
34
 
@@ -35,7 +41,7 @@ Description: python-glances-api
35
41
 
36
42
  .. code:: bash
37
43
 
38
- $ python3.6 -m venv .
44
+ $ python3 -m venv .
39
45
  $ source bin/activate
40
46
  $ python3 setup.py develop
41
47
 
@@ -2,7 +2,10 @@ CHANGES.rst
2
2
  LICENSE
3
3
  MANIFEST.in
4
4
  README.rst
5
+ example.py
6
+ requirements.txt
5
7
  setup.py
8
+ .github/workflows/python-package.yml
6
9
  glances_api/__init__.py
7
10
  glances_api/exceptions.py
8
11
  glances_api.egg-info/PKG-INFO
@@ -0,0 +1,2 @@
1
+ aiohttp<4,>=3.7.4
2
+ async_timeout<4
@@ -0,0 +1,2 @@
1
+ # python-glances-api requirements. Use setup.py for the dependencies.
2
+ .
@@ -0,0 +1,41 @@
1
+ #!/usr/bin/env python3
2
+ """Set up the Python API client for Glances."""
3
+ import os
4
+ import sys
5
+
6
+ try:
7
+ from setuptools import setup
8
+ except ImportError:
9
+ from distutils.core import setup
10
+
11
+ here = os.path.abspath(os.path.dirname(__file__))
12
+
13
+ with open(os.path.join(here, "README.rst"), encoding="utf-8") as readme_file:
14
+ long_description = readme_file.read()
15
+
16
+ setup(
17
+ name="glances_api",
18
+ version="0.2.1",
19
+ description="Python API for interacting with Glances.",
20
+ long_description=long_description,
21
+ url="https://github.com/home-assistant-ecosystem/python-glances-api",
22
+ download_url="https://github.com/home-assistant-ecosystem/python-glances-api/releases",
23
+ author="Fabian Affolter",
24
+ author_email="fabian@affolter-engineering.ch",
25
+ license="MIT",
26
+ install_requires=["aiohttp>=3.7.4,<4", "async_timeout<4"],
27
+ packages=["glances_api"],
28
+ zip_safe=True,
29
+ classifiers=[
30
+ "Development Status :: 3 - Alpha",
31
+ "Environment :: Console",
32
+ "Intended Audience :: Developers",
33
+ "License :: OSI Approved :: MIT License",
34
+ "Operating System :: MacOS :: MacOS X",
35
+ "Operating System :: Microsoft :: Windows",
36
+ "Operating System :: POSIX",
37
+ "Programming Language :: Python :: 3.5",
38
+ "Programming Language :: Python :: 3.6",
39
+ "Topic :: Utilities",
40
+ ],
41
+ )
@@ -1,2 +0,0 @@
1
- aiohttp
2
- async_timeout
@@ -1,49 +0,0 @@
1
- #!/usr/bin/env python3
2
- """
3
- Copyright (c) 2017-2018 Fabian Affolter <fabian@affolter-engineering.ch>
4
-
5
- Licensed under MIT. All rights reserved.
6
- """
7
- import os
8
- import sys
9
-
10
- try:
11
- from setuptools import setup
12
- except ImportError:
13
- from distutils.core import setup
14
-
15
- here = os.path.abspath(os.path.dirname(__file__))
16
-
17
- with open(os.path.join(here, 'README.rst'), encoding='utf-8') as f:
18
- long_description = f.read()
19
-
20
- if sys.argv[-1] == 'publish':
21
- os.system('python3 setup.py sdist upload')
22
- sys.exit()
23
-
24
- setup(
25
- name='glances_api',
26
- version='0.2.0',
27
- description='Python API for interacting with Glances.',
28
- long_description=long_description,
29
- url='https://github.com/fabaff/python-glances-api',
30
- download_url='https://github.com/fabaff/python-glances-api/releases',
31
- author='Fabian Affolter',
32
- author_email='fabian@affolter-engineering.ch',
33
- license='MIT',
34
- install_requires=['aiohttp', 'async_timeout'],
35
- packages=['glances_api'],
36
- zip_safe=True,
37
- classifiers=[
38
- 'Development Status :: 3 - Alpha',
39
- 'Environment :: Console',
40
- 'Intended Audience :: Developers',
41
- 'License :: OSI Approved :: MIT License',
42
- 'Operating System :: MacOS :: MacOS X',
43
- 'Operating System :: Microsoft :: Windows',
44
- 'Operating System :: POSIX',
45
- 'Programming Language :: Python :: 3.5',
46
- 'Programming Language :: Python :: 3.6',
47
- 'Topic :: Utilities',
48
- ],
49
- )
File without changes
File without changes
File without changes