Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed May 9, 2024
1 parent 792154f commit 36e5fbf
Show file tree
Hide file tree
Showing 33 changed files with 276 additions and 112 deletions.
8 changes: 6 additions & 2 deletions otaclient/app/boot_control/_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,12 @@
from subprocess import CalledProcessError
from typing import Callable, Literal, NoReturn, Optional, Union

from ..common import (read_str_from_file, subprocess_call,
subprocess_check_output, write_str_to_file_sync)
from ..common import (
read_str_from_file,
subprocess_call,
subprocess_check_output,
write_str_to_file_sync,
)
from ..configs import config as cfg
from ..proto import wrapper

Expand Down
17 changes: 13 additions & 4 deletions otaclient/app/boot_control/_grub.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,20 @@
from typing import ClassVar, Dict, Generator, List, Optional, Tuple

from .. import errors as ota_errors
from ..common import (re_symlink_atomic, read_str_from_file, subprocess_call,
subprocess_check_output, write_str_to_file_sync)
from ..common import (
re_symlink_atomic,
read_str_from_file,
subprocess_call,
subprocess_check_output,
write_str_to_file_sync,
)
from ..proto import wrapper
from ._common import (CMDHelperFuncs, OTAStatusFilesControl, SlotMountHelper,
cat_proc_cmdline)
from ._common import (
CMDHelperFuncs,
OTAStatusFilesControl,
SlotMountHelper,
cat_proc_cmdline,
)
from .configs import grub_cfg as cfg
from .protocol import BootControllerProtocol

Expand Down
7 changes: 5 additions & 2 deletions otaclient/app/boot_control/_jetson_cboot.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,11 @@
from typing_extensions import Annotated, Self

from otaclient.app import errors as ota_errors
from otaclient.app.common import (copytree_identical, subprocess_run_wrapper,
write_str_to_file_sync)
from otaclient.app.common import (
copytree_identical,
subprocess_run_wrapper,
write_str_to_file_sync,
)
from otaclient.app.proto import wrapper

from ._common import CMDHelperFuncs, OTAStatusFilesControl, SlotMountHelper
Expand Down
8 changes: 6 additions & 2 deletions otaclient/app/boot_control/_rpi_boot.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,12 @@
from .. import errors as ota_errors
from ..common import replace_atomic, subprocess_call, subprocess_check_output
from ..proto import wrapper
from ._common import (CMDHelperFuncs, OTAStatusFilesControl, SlotMountHelper,
write_str_to_file_sync)
from ._common import (
CMDHelperFuncs,
OTAStatusFilesControl,
SlotMountHelper,
write_str_to_file_sync,
)
from .configs import rpi_boot_cfg as cfg
from .protocol import BootControllerProtocol

Expand Down
22 changes: 18 additions & 4 deletions otaclient/app/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,28 @@
from hashlib import sha256
from pathlib import Path
from queue import Queue
from typing import (Any, Callable, Generator, Generic, Iterable, NamedTuple,
Optional, Set, TypeVar, Union)
from typing import (
Any,
Callable,
Generator,
Generic,
Iterable,
NamedTuple,
Optional,
Set,
TypeVar,
Union,
)
from urllib.parse import urljoin

import requests

from otaclient._utils.linux import (ParsedGroup, ParsedPasswd,
map_gid_by_grpnam, map_uid_by_pwnam)
from otaclient._utils.linux import (
ParsedGroup,
ParsedPasswd,
map_gid_by_grpnam,
map_uid_by_pwnam,
)

from .configs import config as cfg

Expand Down
10 changes: 6 additions & 4 deletions otaclient/app/create_standby/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,18 @@
from hashlib import sha256
from pathlib import Path
from threading import Event, Lock
from typing import (Any, Dict, Iterator, List, Optional, OrderedDict, Set,
Tuple, Union)
from typing import Any, Dict, Iterator, List, Optional, OrderedDict, Set, Tuple, Union
from weakref import WeakKeyDictionary, WeakValueDictionary

from ..common import create_tmp_fname
from ..configs import config as cfg
from ..ota_metadata import MetafilesV1, OTAMetadata
from ..proto.wrapper import DirectoryInf, RegularInf
from ..update_stats import (OTAUpdateStatsCollector, RegInfProcessedStats,
RegProcessOperation)
from ..update_stats import (
OTAUpdateStatsCollector,
RegInfProcessedStats,
RegProcessOperation,
)

logger = logging.getLogger(__name__)

Expand Down
7 changes: 5 additions & 2 deletions otaclient/app/create_standby/rebuild_mode.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,11 @@
from ..configs import config as cfg
from ..ota_metadata import MetafilesV1, OTAMetadata
from ..proto.wrapper import RegularInf
from ..update_stats import (OTAUpdateStatsCollector, RegInfProcessedStats,
RegProcessOperation)
from ..update_stats import (
OTAUpdateStatsCollector,
RegInfProcessedStats,
RegProcessOperation,
)
from .common import DeltaBundle, DeltaGenerator, HardlinkRegister
from .interface import StandbySlotCreatorProtocol

Expand Down
15 changes: 13 additions & 2 deletions otaclient/app/downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,19 @@
from functools import wraps
from hashlib import sha256
from os import PathLike
from typing import (IO, Any, ByteString, Callable, Dict, Iterator, Mapping,
Optional, Protocol, Tuple, Union)
from typing import (
IO,
Any,
ByteString,
Callable,
Dict,
Iterator,
Mapping,
Optional,
Protocol,
Tuple,
Union,
)
from urllib.parse import urlsplit

import requests
Expand Down
20 changes: 13 additions & 7 deletions otaclient/app/ota_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,24 @@
from . import errors as ota_errors
from . import ota_metadata
from .boot_control import BootControllerProtocol, get_boot_controller
from .common import (PersistFilesHandler, RetryTaskMap,
RetryTaskMapInterrupted, ensure_otaproxy_start,
get_backoff)
from .common import (
PersistFilesHandler,
RetryTaskMap,
RetryTaskMapInterrupted,
ensure_otaproxy_start,
get_backoff,
)
from .configs import config as cfg
from .configs import ecu_info
from .create_standby import (StandbySlotCreatorProtocol,
get_standby_slot_creator)
from .create_standby import StandbySlotCreatorProtocol, get_standby_slot_creator
from .interface import OTAClientProtocol
from .ota_status import LiveOTAStatus
from .proto import wrapper
from .update_stats import (OTAUpdateStatsCollector, RegInfProcessedStats,
RegProcessOperation)
from .update_stats import (
OTAUpdateStatsCollector,
RegInfProcessedStats,
RegProcessOperation,
)

try:
from otaclient import __version__ # type: ignore
Expand Down
29 changes: 23 additions & 6 deletions otaclient/app/ota_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,21 @@
from os import PathLike
from pathlib import Path
from tempfile import NamedTemporaryFile, TemporaryDirectory
from typing import (Any, Callable, ClassVar, Dict, Generic, Iterator, List,
Optional, Tuple, Type, TypeVar, Union, overload)
from typing import (
Any,
Callable,
ClassVar,
Dict,
Generic,
Iterator,
List,
Optional,
Tuple,
Type,
TypeVar,
Union,
overload,
)
from urllib.parse import quote

from OpenSSL import crypto
Expand All @@ -63,10 +76,14 @@
from .common import RetryTaskMap, get_backoff, urljoin_ensure_base
from .configs import config as cfg
from .downloader import Downloader
from .proto.streamer import (Uint32LenDelimitedMsgReader,
Uint32LenDelimitedMsgWriter)
from .proto.wrapper import (DirectoryInf, MessageWrapper, PersistentInf,
RegularInf, SymbolicLinkInf)
from .proto.streamer import Uint32LenDelimitedMsgReader, Uint32LenDelimitedMsgWriter
from .proto.wrapper import (
DirectoryInf,
MessageWrapper,
PersistentInf,
RegularInf,
SymbolicLinkInf,
)

logger = logging.getLogger(__name__)

Expand Down
19 changes: 16 additions & 3 deletions otaclient/app/proto/_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,22 @@
from enum import EnumMeta, IntEnum
from functools import update_wrapper
from io import StringIO
from typing import (Any, Dict, Generic, Iterable, List, Mapping, Optional,
Type, TypeVar, Union, get_args, get_origin, get_type_hints,
overload)
from typing import (
Any,
Dict,
Generic,
Iterable,
List,
Mapping,
Optional,
Type,
TypeVar,
Union,
get_args,
get_origin,
get_type_hints,
overload,
)

from google.protobuf.duration_pb2 import Duration as _Duration
from google.protobuf.message import Message as _pb_Message
Expand Down
11 changes: 8 additions & 3 deletions otaclient/app/proto/_otaclient_v2_pb2_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,14 @@
import otaclient_v2_pb2 as _v2
from typing_extensions import Self

from ._common import (Duration, EnumWrapper, MessageWrapper,
RepeatedCompositeContainer, RepeatedScalarContainer,
calculate_slots)
from ._common import (
Duration,
EnumWrapper,
MessageWrapper,
RepeatedCompositeContainer,
RepeatedScalarContainer,
calculate_slots,
)

# protocols

Expand Down
3 changes: 1 addition & 2 deletions otaclient/app/proto/otaclient_v2_pb2.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions otaclient/configs/ecu_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@
from pydantic import AfterValidator, BeforeValidator, Field, IPvAnyAddress
from typing_extensions import Annotated

from otaclient._utils.typing import (NetworkPort, StrOrPath,
gen_strenum_validator)
from otaclient._utils.typing import NetworkPort, StrOrPath, gen_strenum_validator
from otaclient.configs._common import BaseFixedConfig

logger = logging.getLogger(__name__)
Expand Down
16 changes: 14 additions & 2 deletions otaclient/ota_proxy/orm.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,20 @@
from abc import ABC
from dataclasses import asdict, astuple, dataclass, fields
from io import StringIO
from typing import (TYPE_CHECKING, Any, Callable, Dict, Generic, List,
Optional, Tuple, Type, TypeVar, Union, overload)
from typing import (
TYPE_CHECKING,
Any,
Callable,
Dict,
Generic,
List,
Optional,
Tuple,
Type,
TypeVar,
Union,
overload,
)

from typing_extensions import Self, dataclass_transform

Expand Down
28 changes: 22 additions & 6 deletions otaclient/ota_proxy/ota_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,21 @@
import weakref
from concurrent.futures import Executor, ThreadPoolExecutor
from pathlib import Path
from typing import (AsyncGenerator, AsyncIterator, Callable, Coroutine, Dict,
Generic, List, Mapping, MutableMapping, Optional, Tuple,
TypeVar, Union)
from typing import (
AsyncGenerator,
AsyncIterator,
Callable,
Coroutine,
Dict,
Generic,
List,
Mapping,
MutableMapping,
Optional,
Tuple,
TypeVar,
Union,
)
from urllib.parse import SplitResult, quote, urlsplit

import aiofiles
Expand All @@ -38,9 +50,13 @@
from .cache_control import OTAFileCacheControl
from .config import config as cfg
from .db import AIO_OTACacheDBProxy, CacheMeta, OTACacheDB
from .errors import (BaseOTACacheError, CacheMultiStreamingFailed,
CacheStreamingFailed, CacheStreamingInterrupt,
StorageReachHardLimit)
from .errors import (
BaseOTACacheError,
CacheMultiStreamingFailed,
CacheStreamingFailed,
CacheStreamingInterrupt,
StorageReachHardLimit,
)
from .utils import read_file, url_based_hash, wait_with_backoff

logger = logging.getLogger(__name__)
Expand Down
21 changes: 15 additions & 6 deletions otaclient/ota_proxy/server_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,21 @@

from otaclient._utils.logging import BurstSuppressFilter

from ._consts import (BHEADER_AUTHORIZATION, BHEADER_CONTENT_ENCODING,
BHEADER_COOKIE, BHEADER_OTA_FILE_CACHE_CONTROL,
HEADER_AUTHORIZATION, HEADER_CONTENT_ENCODING,
HEADER_COOKIE, HEADER_OTA_FILE_CACHE_CONTROL, METHOD_GET,
REQ_TYPE_HTTP, REQ_TYPE_LIFESPAN, RESP_TYPE_BODY,
RESP_TYPE_START)
from ._consts import (
BHEADER_AUTHORIZATION,
BHEADER_CONTENT_ENCODING,
BHEADER_COOKIE,
BHEADER_OTA_FILE_CACHE_CONTROL,
HEADER_AUTHORIZATION,
HEADER_CONTENT_ENCODING,
HEADER_COOKIE,
HEADER_OTA_FILE_CACHE_CONTROL,
METHOD_GET,
REQ_TYPE_HTTP,
REQ_TYPE_LIFESPAN,
RESP_TYPE_BODY,
RESP_TYPE_START,
)
from .errors import BaseOTACacheError
from .ota_cache import OTACache

Expand Down
Loading

0 comments on commit 36e5fbf

Please sign in to comment.