flake8 fixup
* fix trailing/ leading whitespaces * fix None comparison to use is + add noqa ignore statements for the influx escape replacements + add noqa ignore statements around the bare excepts TODO: This is only a temporary fix for most of the bare excepts, we need further specify those.
This commit is contained in:
parent
5f0cb289c1
commit
044e0334d2
|
@ -48,7 +48,7 @@ listen:
|
||||||
|
|
||||||
acl:
|
acl:
|
||||||
api:
|
api:
|
||||||
user:
|
user:
|
||||||
- "api_user@magicbroccoli.de"
|
- "api_user@magicbroccoli.de"
|
||||||
loopback:
|
loopback:
|
||||||
ip:
|
ip:
|
||||||
|
@ -59,7 +59,7 @@ acl:
|
||||||
api_permissions:
|
api_permissions:
|
||||||
"api access":
|
"api access":
|
||||||
from:
|
from:
|
||||||
- mod_http_api
|
- mod_http_api
|
||||||
who:
|
who:
|
||||||
access:
|
access:
|
||||||
allow:
|
allow:
|
||||||
|
@ -81,7 +81,7 @@ configuration file should be located at `/etc/ejabberd-metrics.yml`.
|
||||||
#### systemd service
|
#### systemd service
|
||||||
To properly operate the metrics exporter tools, we created some systemd service templates, to simplify the whole
|
To properly operate the metrics exporter tools, we created some systemd service templates, to simplify the whole
|
||||||
process. If the `ejabberd-metrics.yml` file is not accessible for the user`nobody:nogroup`, it is required to update the
|
process. If the `ejabberd-metrics.yml` file is not accessible for the user`nobody:nogroup`, it is required to update the
|
||||||
`User` and `Group` definitions inside the service file.
|
`User` and `Group` definitions inside the service file.
|
||||||
If a virtualenv is used, it is required to update the `Environment=PATH` to include the `venv/bin` directory created
|
If a virtualenv is used, it is required to update the `Environment=PATH` to include the `venv/bin` directory created
|
||||||
earlier.
|
earlier.
|
||||||
|
|
||||||
|
|
2
api.py
2
api.py
|
@ -53,6 +53,6 @@ class EjabberdApi:
|
||||||
return fn(self._login, data)
|
return fn(self._login, data)
|
||||||
return fn(data)
|
return fn(data)
|
||||||
|
|
||||||
except:
|
except: # noqa: E722
|
||||||
# this needs to be more specific
|
# this needs to be more specific
|
||||||
return {}
|
return {}
|
||||||
|
|
|
@ -38,13 +38,13 @@ class EjabberdCleanup(EjabberdApiCalls):
|
||||||
lastdate = None
|
lastdate = None
|
||||||
try:
|
try:
|
||||||
lastdate = datetime.datetime.strptime(last_stamp, "%Y-%m-%dT%H:%M:%SZ")
|
lastdate = datetime.datetime.strptime(last_stamp, "%Y-%m-%dT%H:%M:%SZ")
|
||||||
except:
|
except: # noqa: E722
|
||||||
try:
|
try:
|
||||||
lastdate = datetime.datetime.strptime(last_stamp, "%Y-%m-%dT%H:%M:%S.%fZ")
|
lastdate = datetime.datetime.strptime(last_stamp, "%Y-%m-%dT%H:%M:%S.%fZ")
|
||||||
except:
|
except: # noqa: E722
|
||||||
logging.error(f"{user}@{host}: not able to parse '{last_stamp}'")
|
logging.error(f"{user}@{host}: not able to parse '{last_stamp}'")
|
||||||
return
|
return
|
||||||
if lastdate != None and lastdate - datetime.datetime.now() > datetime.timedelta(
|
if lastdate is not None and lastdate - datetime.datetime.now() > datetime.timedelta(
|
||||||
days=self.offline_since_days
|
days=self.offline_since_days
|
||||||
):
|
):
|
||||||
self.delete_user(host, user, f"last seen @ {lastdate}")
|
self.delete_user(host, user, f"last seen @ {lastdate}")
|
||||||
|
|
|
@ -21,8 +21,8 @@ class Influx:
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _rmspace(key: str = None, value: (str, int) = None):
|
def _rmspace(key: str = None, value: (str, int) = None):
|
||||||
try:
|
try:
|
||||||
key = key.replace(" ", "\ ")
|
key = key.replace(" ", "\ ") # noqa: W605
|
||||||
value = value.replace(" ", "\ ")
|
value = value.replace(" ", "\ ") # noqa: W605
|
||||||
except (TypeError, AttributeError):
|
except (TypeError, AttributeError):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ class DynamicMetricsHandler(BaseHTTPRequestHandler):
|
||||||
registry = registry.restricted_registry(params["name[]"])
|
registry = registry.restricted_registry(params["name[]"])
|
||||||
try:
|
try:
|
||||||
output = generate_latest(registry)
|
output = generate_latest(registry)
|
||||||
except:
|
except: # noqa: E722
|
||||||
self.send_error(500, "error generating metric output")
|
self.send_error(500, "error generating metric output")
|
||||||
raise
|
raise
|
||||||
self.send_response(200)
|
self.send_response(200)
|
||||||
|
|
Loading…
Reference in New Issue