Skip to content

Commit 2029820

Browse files
committed
Format with black
1 parent 7d5ce1e commit 2029820

2 files changed

Lines changed: 21 additions & 11 deletions

File tree

example.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
from glances_api import Glances
77

8-
HOST = '127.0.0.1'
8+
HOST = "127.0.0.1"
99
VERSION = 3
1010

1111

@@ -15,13 +15,13 @@ async def main():
1515
data = Glances(loop, session, version=VERSION)
1616

1717
# Get the metrics for the memory
18-
await data.get_metrics('mem')
18+
await data.get_metrics("mem")
1919

2020
# Print the values
2121
print("Memory values:", data.values)
2222

2323
# Get the metrics about the disks
24-
await data.get_metrics('diskio')
24+
await data.get_metrics("diskio")
2525

2626
# Print the values
2727
print("Disk values:", data.values)

glances_api/__init__.py

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,30 @@
88
from . import exceptions
99

1010
_LOGGER = logging.getLogger(__name__)
11-
_RESOURCE = '{schema}://{host}:{port}/api/{version}'
11+
_RESOURCE = "{schema}://{host}:{port}/api/{version}"
1212

1313

1414
class Glances(object):
1515
"""A class for handling the data retrieval."""
1616

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+
):
1928
"""Initialize the connection."""
20-
schema = 'https' if ssl else 'http'
29+
schema = "https" if ssl else "http"
2130
self._loop = loop
2231
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+
)
2535
self.data = None
2636
self.values = None
2737
self.plugins = None
@@ -30,7 +40,7 @@ def __init__(self, loop, session, host='localhost', port=61208, version=2,
3040

3141
async def get_data(self):
3242
"""Retrieve the data."""
33-
url = '{}/{}'.format(self.url, 'all')
43+
url = "{}/{}".format(self.url, "all")
3444

3545
try:
3646
with async_timeout.timeout(5, loop=self._loop):
@@ -61,7 +71,7 @@ async def get_metrics(self, element):
6171

6272
async def get_plugins(self):
6373
"""Retrieve the available plugins."""
64-
url = '{}/{}'.format(self.url, 'pluginslist')
74+
url = "{}/{}".format(self.url, "pluginslist")
6575

6676
try:
6777
with async_timeout.timeout(5, loop=self._loop):

0 commit comments

Comments
 (0)