🚨 — Make ruff and pylint happy

This commit is contained in:
Luc Didry 2024-08-27 11:11:31 +02:00
parent a25cfea8c0
commit aac7ca4ec5
No known key found for this signature in database
GPG key ID: EA868E12D0257E3C

View file

@ -226,8 +226,7 @@ async def watch_agents(time_without_agent, config):
db = await get_db() db = await get_db()
agents = await queries.get_recent_agents_count(db, time_without_agent) agents = await queries.get_recent_agents_count(db, time_without_agent)
if agents == 0: if agents == 0:
click.echo( click.echo(f"No agent has been seen in the last {time_without_agent} minutes.")
f"No agent has been seen in the last {time_without_agent} minutes.")
sysexit(1) sysexit(1)
@ -524,8 +523,7 @@ async def show(config):
status = "" status = ""
if _user.disabled: if _user.disabled:
status = "" status = ""
click.echo( click.echo(f"{status} {_user.username}, last login: {_user.last_login_at}")
f"{status} {_user.username}, last login: {_user.last_login_at}")
@server.command(short_help="Generate a token for agents") @server.command(short_help="Generate a token for agents")
@ -580,41 +578,40 @@ async def test_mail(config, domain, severity):
if not conf.general.mail: if not conf.general.mail:
click.echo("Mail is not configured, cannot test", err=True) click.echo("Mail is not configured, cannot test", err=True)
sysexit(1) sysexit(1)
return else:
now = datetime.now()
task = Task(
url=f"https://{domain}",
domain=domain,
check="body-contains",
expected="foo",
frequency=1,
selected_by="test",
selected_at=now,
)
now = datetime.now() result = Result(
task = Task( submitted_at=now,
url=f"https://{domain}", status="success",
domain=domain, context={"foo": "bar"},
check="body-contains", task=task,
expected="foo", agent_id="test",
frequency=1, severity="ok",
selected_by="test", )
selected_at=now,
)
result = Result( class _FalseRequest:
submitted_at=now, def url_for(*args, **kwargs):
status="success", return "/url"
context={"foo": "bar"},
task=task,
agent_id="test",
severity="ok",
)
class _FalseRequest: set_log_level("debug")
def url_for(*args, **kwargs): notify_by_mail(
return "/url" result,
task,
set_log_level("debug") severity="SEVERITY",
notify_by_mail( old_severity="OLD SEVERITY",
result, config=conf.general.mail,
task, request=_FalseRequest(),
severity="SEVERITY", )
old_severity="OLD SEVERITY",
config=conf.general.mail,
request=_FalseRequest(),
)
if __name__ == "__main__": if __name__ == "__main__":