From 81dab470d285bcdb41734f3f0756c44605e4af1a Mon Sep 17 00:00:00 2001 From: wh1te909 Date: Fri, 26 Jan 2024 07:38:52 +0000 Subject: [PATCH] blacked --- api/tacticalrmm/agents/models.py | 44 +++++++++++-------- api/tacticalrmm/alerts/models.py | 20 +++++---- api/tacticalrmm/autotasks/models.py | 22 ++++++---- api/tacticalrmm/core/views.py | 6 +-- .../commands/generate_json_schemas.py | 1 + .../management/commands/get_webtar_url.py | 1 + .../tests/test_report_template_views.py | 8 ++-- api/tacticalrmm/ee/reporting/views.py | 6 +-- api/tacticalrmm/logs/tests.py | 8 ++-- 9 files changed, 68 insertions(+), 48 deletions(-) diff --git a/api/tacticalrmm/agents/models.py b/api/tacticalrmm/agents/models.py index 21ddfc0f2e..c1e5e6a739 100644 --- a/api/tacticalrmm/agents/models.py +++ b/api/tacticalrmm/agents/models.py @@ -507,24 +507,32 @@ def get_agent_policies(self) -> "Dict[str, Optional[Policy]]": ) return { - "agent_policy": self.policy - if self.policy and not self.policy.is_agent_excluded(self) - else None, - "site_policy": site_policy - if (site_policy and not site_policy.is_agent_excluded(self)) - and not self.block_policy_inheritance - else None, - "client_policy": client_policy - if (client_policy and not client_policy.is_agent_excluded(self)) - and not self.block_policy_inheritance - and not self.site.block_policy_inheritance - else None, - "default_policy": default_policy - if (default_policy and not default_policy.is_agent_excluded(self)) - and not self.block_policy_inheritance - and not self.site.block_policy_inheritance - and not self.client.block_policy_inheritance - else None, + "agent_policy": ( + self.policy + if self.policy and not self.policy.is_agent_excluded(self) + else None + ), + "site_policy": ( + site_policy + if (site_policy and not site_policy.is_agent_excluded(self)) + and not self.block_policy_inheritance + else None + ), + "client_policy": ( + client_policy + if (client_policy and not client_policy.is_agent_excluded(self)) + and not self.block_policy_inheritance + and not self.site.block_policy_inheritance + else None + ), + "default_policy": ( + default_policy + if (default_policy and not default_policy.is_agent_excluded(self)) + and not self.block_policy_inheritance + and not self.site.block_policy_inheritance + and not self.client.block_policy_inheritance + else None + ), } def check_run_interval(self) -> int: diff --git a/api/tacticalrmm/alerts/models.py b/api/tacticalrmm/alerts/models.py index f0485a6b67..f008843380 100644 --- a/api/tacticalrmm/alerts/models.py +++ b/api/tacticalrmm/alerts/models.py @@ -169,15 +169,17 @@ def create_or_return_check_alert( assigned_check=check, agent=agent, alert_type=AlertType.CHECK, - severity=check.alert_severity - if check.check_type - not in { - CheckType.MEMORY, - CheckType.CPU_LOAD, - CheckType.DISK_SPACE, - CheckType.SCRIPT, - } - else alert_severity, + severity=( + check.alert_severity + if check.check_type + not in { + CheckType.MEMORY, + CheckType.CPU_LOAD, + CheckType.DISK_SPACE, + CheckType.SCRIPT, + } + else alert_severity + ), message=f"{agent.hostname} has a {check.check_type} check: {check.readable_desc} that failed.", hidden=True, ), diff --git a/api/tacticalrmm/autotasks/models.py b/api/tacticalrmm/autotasks/models.py index c13a89f633..a700bdb99a 100644 --- a/api/tacticalrmm/autotasks/models.py +++ b/api/tacticalrmm/autotasks/models.py @@ -248,16 +248,20 @@ def generate_nats_task_payload(self) -> Dict[str, Any]: "name": self.win_task_name, "overwrite_task": True, "enabled": self.enabled, - "trigger": self.task_type - if self.task_type != TaskType.CHECK_FAILURE - else TaskType.MANUAL, + "trigger": ( + self.task_type + if self.task_type != TaskType.CHECK_FAILURE + else TaskType.MANUAL + ), "multiple_instances": self.task_instance_policy or 0, - "delete_expired_task_after": self.remove_if_not_scheduled - if self.expire_date - else False, - "start_when_available": self.run_asap_after_missed - if self.task_type != TaskType.RUN_ONCE - else True, + "delete_expired_task_after": ( + self.remove_if_not_scheduled if self.expire_date else False + ), + "start_when_available": ( + self.run_asap_after_missed + if self.task_type != TaskType.RUN_ONCE + else True + ), } if self.task_type in ( diff --git a/api/tacticalrmm/core/views.py b/api/tacticalrmm/core/views.py index 186d07f37e..dccddb498e 100644 --- a/api/tacticalrmm/core/views.py +++ b/api/tacticalrmm/core/views.py @@ -91,9 +91,9 @@ def dashboard_info(request): "show_community_scripts": request.user.show_community_scripts, "dbl_click_action": request.user.agent_dblclick_action, "default_agent_tbl_tab": request.user.default_agent_tbl_tab, - "url_action": request.user.url_action.id - if request.user.url_action - else None, + "url_action": ( + request.user.url_action.id if request.user.url_action else None + ), "client_tree_sort": request.user.client_tree_sort, "client_tree_splitter": request.user.client_tree_splitter, "loading_bar_color": request.user.loading_bar_color, diff --git a/api/tacticalrmm/ee/reporting/management/commands/generate_json_schemas.py b/api/tacticalrmm/ee/reporting/management/commands/generate_json_schemas.py index 5f1bf4bc45..b9d781f05f 100644 --- a/api/tacticalrmm/ee/reporting/management/commands/generate_json_schemas.py +++ b/api/tacticalrmm/ee/reporting/management/commands/generate_json_schemas.py @@ -3,6 +3,7 @@ This file is subject to the EE License Agreement. For details, see: https://license.tacticalrmm.com/ee """ + import json from typing import TYPE_CHECKING, Any, Dict, List, Tuple diff --git a/api/tacticalrmm/ee/reporting/management/commands/get_webtar_url.py b/api/tacticalrmm/ee/reporting/management/commands/get_webtar_url.py index 7f96fd1f84..626115a528 100644 --- a/api/tacticalrmm/ee/reporting/management/commands/get_webtar_url.py +++ b/api/tacticalrmm/ee/reporting/management/commands/get_webtar_url.py @@ -3,6 +3,7 @@ This file is subject to the EE License Agreement. For details, see: https://license.tacticalrmm.com/ee """ + import urllib.parse from time import sleep from typing import Any, Optional diff --git a/api/tacticalrmm/ee/reporting/tests/test_report_template_views.py b/api/tacticalrmm/ee/reporting/tests/test_report_template_views.py index 44d8e1b871..0d81252c20 100644 --- a/api/tacticalrmm/ee/reporting/tests/test_report_template_views.py +++ b/api/tacticalrmm/ee/reporting/tests/test_report_template_views.py @@ -187,9 +187,11 @@ def test_generate_report_with_dependencies( template=report_template.template_md, template_type=report_template.type, css=report_template.template_css if report_template.template_css else "", - html_template=report_template.template_html.id - if report_template.template_html - else None, + html_template=( + report_template.template_html.id + if report_template.template_html + else None + ), variables=report_template.template_variables, dependencies={"client": 1}, ) diff --git a/api/tacticalrmm/ee/reporting/views.py b/api/tacticalrmm/ee/reporting/views.py index 8b993b3aad..67153ddccc 100644 --- a/api/tacticalrmm/ee/reporting/views.py +++ b/api/tacticalrmm/ee/reporting/views.py @@ -130,9 +130,9 @@ def post(self, request: Request, pk: int) -> Union[FileResponse, Response]: template=template.template_md, template_type=template.type, css=template.template_css or "", - html_template=template.template_html.id - if template.template_html - else None, + html_template=( + template.template_html.id if template.template_html else None + ), variables=template.template_variables, dependencies=request.data["dependencies"], ) diff --git a/api/tacticalrmm/logs/tests.py b/api/tacticalrmm/logs/tests.py index ef1f766688..885b3b79c1 100644 --- a/api/tacticalrmm/logs/tests.py +++ b/api/tacticalrmm/logs/tests.py @@ -152,9 +152,11 @@ def test_get_audit_logs(self): self.assertEqual(resp.status_code, 200) self.assertEqual( len(resp.data["audit_logs"]), # type:ignore - pagination["rowsPerPage"] - if req["count"] > pagination["rowsPerPage"] - else req["count"], + ( + pagination["rowsPerPage"] + if req["count"] > pagination["rowsPerPage"] + else req["count"] + ), ) self.assertEqual(resp.data["total"], req["count"]) # type:ignore