style: Reformat with new Black version

This commit is contained in:
Inex Code 2024-07-26 22:59:44 +03:00
parent 659cfca8a3
commit 1259c081ef
42 changed files with 55 additions and 9 deletions

View file

@ -2,6 +2,7 @@
App tokens actions.
The only actions on tokens that are accessible from APIs
"""
from datetime import datetime, timezone
from typing import Optional
from pydantic import BaseModel

View file

@ -1,4 +1,5 @@
"""Actions to manage the SSH."""
from typing import Optional
from pydantic import BaseModel
from selfprivacy_api.actions.users import (

View file

@ -1,4 +1,5 @@
"""Actions to manage the system."""
import os
import subprocess
import pytz

View file

@ -1,4 +1,5 @@
"""Actions to manage the users."""
import re
from typing import Optional
from pydantic import BaseModel

View file

@ -1,6 +1,7 @@
"""
This module contains the controller class for backups.
"""
from datetime import datetime, timedelta, timezone
import time
import os

View file

@ -3,7 +3,8 @@ An abstract class for BackBlaze, S3 etc.
It assumes that while some providers are supported via restic/rclone, others
may require different backends
"""
from abc import ABC, abstractmethod
from abc import ABC
from selfprivacy_api.backup.backuppers import AbstractBackupper
from selfprivacy_api.graphql.queries.providers import (
BackupProvider as BackupProviderEnum,

View file

@ -1,6 +1,7 @@
"""
Module for storing backup related data in redis.
"""
from typing import List, Optional
from datetime import datetime

View file

@ -1,6 +1,7 @@
"""
The tasks module contains the worker tasks that are used to back up and restore
"""
from datetime import datetime, timezone
from selfprivacy_api.graphql.common_types.backup import (

View file

@ -1,4 +1,5 @@
"""GraphQL API for SelfPrivacy."""
# pylint: disable=too-few-public-methods
import typing
from strawberry.permission import BasePermission

View file

@ -1,4 +1,5 @@
"""Backup"""
# pylint: disable=too-few-public-methods
from enum import Enum
import strawberry

View file

@ -1,4 +1,5 @@
"""Jobs status"""
# pylint: disable=too-few-public-methods
import datetime
import typing

View file

@ -247,9 +247,9 @@ def get_volume_by_id(volume_id: str) -> Optional[StorageVolume]:
if volume is None:
return None
return StorageVolume(
total_space=str(volume.fssize)
if volume.fssize is not None
else str(volume.size),
total_space=(
str(volume.fssize) if volume.fssize is not None else str(volume.size)
),
free_space=str(volume.fsavail),
used_space=str(volume.fsused),
root=volume.name == "sda1",

View file

@ -1,4 +1,5 @@
"""API access mutations"""
# pylint: disable=too-few-public-methods
import datetime
import typing

View file

@ -1,4 +1,5 @@
"""Manipulate jobs"""
# pylint: disable=too-few-public-methods
import strawberry

View file

@ -1,4 +1,5 @@
"""Services mutations"""
# pylint: disable=too-few-public-methods
import typing
import strawberry

View file

@ -1,4 +1,5 @@
"""Storage devices mutations"""
import strawberry
from selfprivacy_api.graphql import IsAuthenticated
from selfprivacy_api.graphql.common_types.jobs import job_to_api_job

View file

@ -1,4 +1,5 @@
"""System management mutations"""
# pylint: disable=too-few-public-methods
import typing
import strawberry

View file

@ -1,4 +1,5 @@
"""System logs"""
from datetime import datetime
import typing
import strawberry
@ -86,7 +87,13 @@ class Logs:
list(
map(
lambda x: LogEntry(x),
get_paginated_logs(limit, up_cursor, down_cursor, filterBySlice, filterByUnit),
get_paginated_logs(
limit,
up_cursor,
down_cursor,
filterBySlice,
filterByUnit,
),
)
)
)

View file

@ -1,4 +1,5 @@
"""GraphQL API for SelfPrivacy."""
# pylint: disable=too-few-public-methods
import asyncio

View file

@ -14,6 +14,7 @@ A job is a dictionary with the following keys:
- error: error message if the job failed
- result: result of the job
"""
import typing
import asyncio
import datetime

View file

@ -1,4 +1,5 @@
"""Function to perform migration of app data to binds."""
import subprocess
import pathlib
import shutil

View file

@ -3,6 +3,7 @@ A task to start the system upgrade or rebuild by starting a systemd unit.
After starting, track the status of the systemd unit and update the Job
status accordingly.
"""
import subprocess
from selfprivacy_api.utils.huey import huey
from selfprivacy_api.jobs import JobStatus, Jobs, Job

View file

@ -22,6 +22,6 @@ class AddRoundcube(Migration):
def migrate(self) -> None:
with FlakeServiceManager() as manager:
if "roundcube" not in manager.services:
manager.services[
"roundcube"
] = "git+https://git.selfprivacy.org/SelfPrivacy/selfprivacy-nixos-config.git?ref=flakes&dir=sp-modules/roundcube"
manager.services["roundcube"] = (
"git+https://git.selfprivacy.org/SelfPrivacy/selfprivacy-nixos-config.git?ref=flakes&dir=sp-modules/roundcube"
)

View file

@ -1,6 +1,7 @@
"""
New device key used to obtain access token.
"""
from datetime import datetime, timedelta, timezone
import secrets
from pydantic import BaseModel

View file

@ -3,6 +3,7 @@ Recovery key used to obtain access token.
Recovery key has a token string, date of creation, optional date of expiration and optional count of uses left.
"""
from datetime import datetime, timezone
import secrets
from typing import Optional

View file

@ -3,6 +3,7 @@ Model of the access token.
Access token has a token string, device name and date of creation.
"""
from datetime import datetime
import secrets
from pydantic import BaseModel

View file

@ -1,6 +1,7 @@
"""
Token repository using Redis as backend.
"""
from typing import Any, Optional
from datetime import datetime
from hashlib import md5

View file

@ -1,4 +1,5 @@
"""Class representing Bitwarden service"""
import base64
import subprocess
from typing import List

View file

@ -1,4 +1,5 @@
"""Class representing Bitwarden service"""
import base64
import subprocess
from typing import List

View file

@ -1,4 +1,5 @@
"""Generic size counter using pathlib"""
import pathlib

View file

@ -1,4 +1,5 @@
"""Class representing Jitsi Meet service"""
import base64
import subprocess
from typing import List

View file

@ -1,4 +1,5 @@
"""Class representing Nextcloud service."""
import base64
import subprocess
from typing import List

View file

@ -1,4 +1,5 @@
"""Class representing ocserv service."""
import base64
import subprocess
import typing

View file

@ -1,4 +1,5 @@
"""Class representing Nextcloud service."""
import base64
import subprocess
from typing import List

View file

@ -1,4 +1,5 @@
"""Abstract class for a service running on a server"""
from abc import ABC, abstractmethod
from typing import List, Optional

View file

@ -1,4 +1,5 @@
"""Class representing Bitwarden service"""
import base64
import subprocess

View file

@ -1,4 +1,5 @@
"""A block device API wrapping lsblk"""
from __future__ import annotations
import subprocess
import json

View file

@ -1,4 +1,5 @@
"""MiniHuey singleton."""
from os import environ
from huey import RedisHuey

View file

@ -3,6 +3,7 @@ Singleton is a creational design pattern, which ensures that only
one object of its kind exists and provides a single point of access
to it for any other code.
"""
from threading import Lock

View file

@ -1,4 +1,5 @@
"""Generic service status fetcher using systemctl"""
import subprocess
from typing import List

View file

@ -1,4 +1,5 @@
"""Tests configuration."""
# pylint: disable=redefined-outer-name
# pylint: disable=unused-argument
import os

View file

@ -1,6 +1,7 @@
"""
Tests for generic service methods
"""
import pytest
from pytest import raises