mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2024-11-21 19:51:28 +00:00
style: Reformat with new Black version
This commit is contained in:
parent
cabb6cca90
commit
a1bbd31833
|
@ -1,7 +1,8 @@
|
|||
"""
|
||||
App tokens actions.
|
||||
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
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
"""Actions to manage the SSH."""
|
||||
|
||||
from typing import Optional
|
||||
from pydantic import BaseModel
|
||||
from selfprivacy_api.actions.users import (
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
"""Actions to manage the system."""
|
||||
|
||||
import os
|
||||
import subprocess
|
||||
import pytz
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
"""Actions to manage the users."""
|
||||
|
||||
import re
|
||||
from typing import Optional
|
||||
from pydantic import BaseModel
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
"""
|
||||
This module contains the controller class for backups.
|
||||
"""
|
||||
|
||||
from datetime import datetime, timedelta, timezone
|
||||
import time
|
||||
import os
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
"""
|
||||
Module for storing backup related data in redis.
|
||||
"""
|
||||
|
||||
from typing import List, Optional
|
||||
from datetime import datetime
|
||||
|
||||
|
|
|
@ -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 (
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
"""GraphQL API for SelfPrivacy."""
|
||||
|
||||
# pylint: disable=too-few-public-methods
|
||||
import typing
|
||||
from strawberry.permission import BasePermission
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
"""Backup"""
|
||||
|
||||
# pylint: disable=too-few-public-methods
|
||||
from enum import Enum
|
||||
import strawberry
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
"""Jobs status"""
|
||||
|
||||
# pylint: disable=too-few-public-methods
|
||||
import datetime
|
||||
import typing
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
"""API access mutations"""
|
||||
|
||||
# pylint: disable=too-few-public-methods
|
||||
import datetime
|
||||
import typing
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
"""Manipulate jobs"""
|
||||
|
||||
# pylint: disable=too-few-public-methods
|
||||
import strawberry
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
"""Services mutations"""
|
||||
|
||||
# pylint: disable=too-few-public-methods
|
||||
import typing
|
||||
import strawberry
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
"""System management mutations"""
|
||||
|
||||
# pylint: disable=too-few-public-methods
|
||||
import typing
|
||||
import strawberry
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
"""System logs"""
|
||||
|
||||
from datetime import datetime
|
||||
import typing
|
||||
import strawberry
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
"""GraphQL API for SelfPrivacy."""
|
||||
|
||||
# pylint: disable=too-few-public-methods
|
||||
|
||||
import asyncio
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
"""Function to perform migration of app data to binds."""
|
||||
|
||||
import subprocess
|
||||
import pathlib
|
||||
import shutil
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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"
|
||||
)
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
"""
|
||||
New device key used to obtain access token.
|
||||
"""
|
||||
|
||||
from datetime import datetime, timedelta, timezone
|
||||
import secrets
|
||||
from pydantic import BaseModel
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
"""
|
||||
Token repository using Redis as backend.
|
||||
"""
|
||||
|
||||
from typing import Any, Optional
|
||||
from datetime import datetime
|
||||
from hashlib import md5
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
"""Class representing Bitwarden service"""
|
||||
|
||||
import base64
|
||||
import subprocess
|
||||
from typing import List
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
"""Class representing Bitwarden service"""
|
||||
|
||||
import base64
|
||||
import subprocess
|
||||
from typing import List
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
"""Generic size counter using pathlib"""
|
||||
|
||||
import pathlib
|
||||
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
"""Class representing Jitsi Meet service"""
|
||||
|
||||
import base64
|
||||
import subprocess
|
||||
from typing import List
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
"""Class representing Nextcloud service."""
|
||||
|
||||
import base64
|
||||
import subprocess
|
||||
from typing import List
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
"""Class representing ocserv service."""
|
||||
|
||||
import base64
|
||||
import subprocess
|
||||
import typing
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
"""Class representing Nextcloud service."""
|
||||
|
||||
import base64
|
||||
import subprocess
|
||||
from typing import List
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
"""Abstract class for a service running on a server"""
|
||||
|
||||
from abc import ABC, abstractmethod
|
||||
from typing import List, Optional
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
"""Class representing Bitwarden service"""
|
||||
|
||||
import base64
|
||||
import subprocess
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
"""A block device API wrapping lsblk"""
|
||||
|
||||
from __future__ import annotations
|
||||
import subprocess
|
||||
import json
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
"""MiniHuey singleton."""
|
||||
|
||||
from os import environ
|
||||
from huey import RedisHuey
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
"""Generic service status fetcher using systemctl"""
|
||||
|
||||
import subprocess
|
||||
from typing import List
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
"""Tests configuration."""
|
||||
|
||||
# pylint: disable=redefined-outer-name
|
||||
# pylint: disable=unused-argument
|
||||
import os
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
"""
|
||||
Tests for generic service methods
|
||||
"""
|
||||
|
||||
import pytest
|
||||
from pytest import raises
|
||||
|
||||
|
|
Loading…
Reference in a new issue