pep8 and friends
* add default logging NullHandler * fix indentation mismatch * rename control to calls to better point out its purpose * rename class to EjabberdApiCalls to better point out it purpose * changed get_nodes to an internal support method
This commit is contained in:
parent
d36dbe03c8
commit
71440b7a8f
3
api.py
3
api.py
|
@ -1,9 +1,8 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
import logging
|
import logging
|
||||||
import re
|
|
||||||
|
|
||||||
from packaging import version
|
logging.getLogger(__name__).addHandler(logging.NullHandler())
|
||||||
|
|
||||||
|
|
||||||
class EjabberdApi:
|
class EjabberdApi:
|
||||||
|
|
|
@ -1,14 +1,16 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
import re
|
|
||||||
import logging
|
import logging
|
||||||
|
import re
|
||||||
|
|
||||||
from packaging import version
|
from packaging import version
|
||||||
|
|
||||||
from api import EjabberdApi
|
from api import EjabberdApi
|
||||||
|
|
||||||
class EjabberdCtl(EjabberdApi):
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
class EjabberdApiCalls(EjabberdApi):
|
||||||
@property
|
@property
|
||||||
def verstring(self):
|
def verstring(self):
|
||||||
if self._login is not None:
|
if self._login is not None:
|
||||||
|
@ -23,7 +25,7 @@ class EjabberdCtl(EjabberdApi):
|
||||||
raise SystemExit(17)
|
raise SystemExit(17)
|
||||||
|
|
||||||
# return parsed version string
|
# return parsed version string
|
||||||
logging.debug(f"fetch version: {tmp}")
|
log.debug(f"fetched version string: {tmp}")
|
||||||
return version.parse(tmp)
|
return version.parse(tmp)
|
||||||
|
|
||||||
return None
|
return None
|
|
@ -3,10 +3,10 @@
|
||||||
import datetime
|
import datetime
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from control import EjabberdCtl
|
from calls import EjabberdApiCalls
|
||||||
|
|
||||||
|
|
||||||
class EjabberdCleanup(EjabberdCtl):
|
class EjabberdCleanup(EjabberdApiCalls):
|
||||||
def __init__(self, url, login, api):
|
def __init__(self, url, login, api):
|
||||||
super().__init__(url, login, api)
|
super().__init__(url, login, api)
|
||||||
self.ignore_hosts = []
|
self.ignore_hosts = []
|
||||||
|
|
|
@ -2,13 +2,13 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
import ipaddress
|
import ipaddress
|
||||||
|
|
||||||
from control import EjabberdCtl
|
from calls import EjabberdApiCalls
|
||||||
|
|
||||||
# rfc6052: IPv6 Addressing of IPv4/IPv6 Translators
|
# rfc6052: IPv6 Addressing of IPv4/IPv6 Translators
|
||||||
nat64 = ipaddress.ip_network("64:ff9b::/96")
|
nat64 = ipaddress.ip_network("64:ff9b::/96")
|
||||||
|
|
||||||
|
|
||||||
class EjabberdMetrics(EjabberdCtl):
|
class EjabberdMetrics(EjabberdApiCalls):
|
||||||
"""
|
"""
|
||||||
class to fetch metrics per xmlrpc
|
class to fetch metrics per xmlrpc
|
||||||
"""
|
"""
|
||||||
|
@ -190,7 +190,7 @@ class EjabberdMetrics(EjabberdCtl):
|
||||||
|
|
||||||
return data
|
return data
|
||||||
|
|
||||||
def get_nodes(self):
|
def _get_nodes(self):
|
||||||
if not hasattr(self, "_nodes"):
|
if not hasattr(self, "_nodes"):
|
||||||
self._nodes = self.fetch_nodes()
|
self._nodes = self.fetch_nodes()
|
||||||
return self._nodes
|
return self._nodes
|
||||||
|
@ -224,7 +224,7 @@ class EjabberdMetrics(EjabberdCtl):
|
||||||
data["vhosts"] = vhosts
|
data["vhosts"] = vhosts
|
||||||
|
|
||||||
nodes = {}
|
nodes = {}
|
||||||
for node in self.get_nodes():
|
for node in self._get_nodes():
|
||||||
nodes[node] = self.get_node_metrics(node)
|
nodes[node] = self.get_node_metrics(node)
|
||||||
|
|
||||||
data["online_client_by_ipversion"] = self.get_online_client_by_ipversion()
|
data["online_client_by_ipversion"] = self.get_online_client_by_ipversion()
|
||||||
|
|
Loading…
Reference in New Issue