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. App tokens actions.
The only actions on tokens that are accessible from APIs The only actions on tokens that are accessible from APIs
""" """
from datetime import datetime, timezone from datetime import datetime, timezone
from typing import Optional from typing import Optional
from pydantic import BaseModel from pydantic import BaseModel

View file

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

View file

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

View file

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

View file

@ -1,6 +1,7 @@
""" """
This module contains the controller class for backups. This module contains the controller class for backups.
""" """
from datetime import datetime, timedelta, timezone from datetime import datetime, timedelta, timezone
import time import time
import os 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 It assumes that while some providers are supported via restic/rclone, others
may require different backends may require different backends
""" """
from abc import ABC, abstractmethod
from abc import ABC
from selfprivacy_api.backup.backuppers import AbstractBackupper from selfprivacy_api.backup.backuppers import AbstractBackupper
from selfprivacy_api.graphql.queries.providers import ( from selfprivacy_api.graphql.queries.providers import (
BackupProvider as BackupProviderEnum, BackupProvider as BackupProviderEnum,

View file

@ -1,6 +1,7 @@
""" """
Module for storing backup related data in redis. Module for storing backup related data in redis.
""" """
from typing import List, Optional from typing import List, Optional
from datetime import datetime 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 The tasks module contains the worker tasks that are used to back up and restore
""" """
from datetime import datetime, timezone from datetime import datetime, timezone
from selfprivacy_api.graphql.common_types.backup import ( from selfprivacy_api.graphql.common_types.backup import (

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,4 +1,5 @@
"""System logs""" """System logs"""
from datetime import datetime from datetime import datetime
import typing import typing
import strawberry import strawberry
@ -86,7 +87,13 @@ class Logs:
list( list(
map( map(
lambda x: LogEntry(x), 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.""" """GraphQL API for SelfPrivacy."""
# pylint: disable=too-few-public-methods # pylint: disable=too-few-public-methods
import asyncio import asyncio

View file

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

View file

@ -1,4 +1,5 @@
"""Function to perform migration of app data to binds.""" """Function to perform migration of app data to binds."""
import subprocess import subprocess
import pathlib import pathlib
import shutil 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 After starting, track the status of the systemd unit and update the Job
status accordingly. status accordingly.
""" """
import subprocess import subprocess
from selfprivacy_api.utils.huey import huey from selfprivacy_api.utils.huey import huey
from selfprivacy_api.jobs import JobStatus, Jobs, Job from selfprivacy_api.jobs import JobStatus, Jobs, Job

View file

@ -22,6 +22,6 @@ class AddRoundcube(Migration):
def migrate(self) -> None: def migrate(self) -> None:
with FlakeServiceManager() as manager: with FlakeServiceManager() as manager:
if "roundcube" not in manager.services: if "roundcube" not in manager.services:
manager.services[ manager.services["roundcube"] = (
"roundcube" "git+https://git.selfprivacy.org/SelfPrivacy/selfprivacy-nixos-config.git?ref=flakes&dir=sp-modules/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. New device key used to obtain access token.
""" """
from datetime import datetime, timedelta, timezone from datetime import datetime, timedelta, timezone
import secrets import secrets
from pydantic import BaseModel 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. Recovery key has a token string, date of creation, optional date of expiration and optional count of uses left.
""" """
from datetime import datetime, timezone from datetime import datetime, timezone
import secrets import secrets
from typing import Optional 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. Access token has a token string, device name and date of creation.
""" """
from datetime import datetime from datetime import datetime
import secrets import secrets
from pydantic import BaseModel from pydantic import BaseModel

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,4 +1,5 @@
"""MiniHuey singleton.""" """MiniHuey singleton."""
from os import environ from os import environ
from huey import RedisHuey 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 one object of its kind exists and provides a single point of access
to it for any other code. to it for any other code.
""" """
from threading import Lock from threading import Lock

View file

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

View file

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

View file

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