From 36e5fbf3ee6c52975b6606b0f1d6bf3059d8ef0f Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 9 May 2024 14:52:20 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- otaclient/app/boot_control/_common.py | 8 +++-- otaclient/app/boot_control/_grub.py | 17 ++++++++--- otaclient/app/boot_control/_jetson_cboot.py | 7 +++-- otaclient/app/boot_control/_rpi_boot.py | 8 +++-- otaclient/app/common.py | 22 +++++++++++--- otaclient/app/create_standby/common.py | 10 ++++--- otaclient/app/create_standby/rebuild_mode.py | 7 +++-- otaclient/app/downloader.py | 15 ++++++++-- otaclient/app/ota_client.py | 20 ++++++++----- otaclient/app/ota_metadata.py | 29 +++++++++++++++---- otaclient/app/proto/_common.py | 19 ++++++++++-- .../app/proto/_otaclient_v2_pb2_wrapper.py | 11 +++++-- otaclient/app/proto/otaclient_v2_pb2.py | 3 +- otaclient/configs/ecu_info.py | 3 +- otaclient/ota_proxy/orm.py | 16 ++++++++-- otaclient/ota_proxy/ota_cache.py | 28 ++++++++++++++---- otaclient/ota_proxy/server_app.py | 21 ++++++++++---- tests/test_boot_control/test_grub.py | 3 +- tests/test_boot_control/test_jetson_cboot.py | 11 ++++--- tests/test_common.py | 20 +++++++++---- tests/test_downloader.py | 14 +++++---- tests/test_ecu_info.py | 9 ++++-- tests/test_ota_client.py | 11 ++++--- tests/test_ota_client_stub.py | 8 +++-- tests/test_ota_metadata.py | 16 +++++----- tests/test_ota_proxy/test_cachedb.py | 3 +- .../test_subprocess_launch_otaproxy.py | 3 +- tests/test_proto/example_pb2.py | 3 +- tests/test_proto/example_pb2_wrapper.py | 15 ++++++---- tests/test_proxy_info.py | 3 +- tests/test_update_stats.py | 8 +++-- tools/emulator/main.py | 8 +++-- tools/status_monitor/main_win.py | 9 ++++-- 33 files changed, 276 insertions(+), 112 deletions(-) diff --git a/otaclient/app/boot_control/_common.py b/otaclient/app/boot_control/_common.py index 253a8342c..7cc61ecd4 100644 --- a/otaclient/app/boot_control/_common.py +++ b/otaclient/app/boot_control/_common.py @@ -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 diff --git a/otaclient/app/boot_control/_grub.py b/otaclient/app/boot_control/_grub.py index a927241c2..c502a4243 100644 --- a/otaclient/app/boot_control/_grub.py +++ b/otaclient/app/boot_control/_grub.py @@ -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 diff --git a/otaclient/app/boot_control/_jetson_cboot.py b/otaclient/app/boot_control/_jetson_cboot.py index c857f7999..dbbe8dc42 100644 --- a/otaclient/app/boot_control/_jetson_cboot.py +++ b/otaclient/app/boot_control/_jetson_cboot.py @@ -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 diff --git a/otaclient/app/boot_control/_rpi_boot.py b/otaclient/app/boot_control/_rpi_boot.py index 6f596624c..7b5956036 100644 --- a/otaclient/app/boot_control/_rpi_boot.py +++ b/otaclient/app/boot_control/_rpi_boot.py @@ -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 diff --git a/otaclient/app/common.py b/otaclient/app/common.py index 611eeaa37..08e874917 100644 --- a/otaclient/app/common.py +++ b/otaclient/app/common.py @@ -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 diff --git a/otaclient/app/create_standby/common.py b/otaclient/app/create_standby/common.py index e5ffcaa3e..70729551a 100644 --- a/otaclient/app/create_standby/common.py +++ b/otaclient/app/create_standby/common.py @@ -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__) diff --git a/otaclient/app/create_standby/rebuild_mode.py b/otaclient/app/create_standby/rebuild_mode.py index ae7d26912..b8f7e0a24 100644 --- a/otaclient/app/create_standby/rebuild_mode.py +++ b/otaclient/app/create_standby/rebuild_mode.py @@ -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 diff --git a/otaclient/app/downloader.py b/otaclient/app/downloader.py index 41cdaf1fd..ceeb8c428 100644 --- a/otaclient/app/downloader.py +++ b/otaclient/app/downloader.py @@ -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 diff --git a/otaclient/app/ota_client.py b/otaclient/app/ota_client.py index 0c3879f1d..85cd6df4a 100644 --- a/otaclient/app/ota_client.py +++ b/otaclient/app/ota_client.py @@ -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 diff --git a/otaclient/app/ota_metadata.py b/otaclient/app/ota_metadata.py index c3d6fa487..d0c2651cc 100644 --- a/otaclient/app/ota_metadata.py +++ b/otaclient/app/ota_metadata.py @@ -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 @@ -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__) diff --git a/otaclient/app/proto/_common.py b/otaclient/app/proto/_common.py index 38dd48db7..17fca155e 100644 --- a/otaclient/app/proto/_common.py +++ b/otaclient/app/proto/_common.py @@ -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 diff --git a/otaclient/app/proto/_otaclient_v2_pb2_wrapper.py b/otaclient/app/proto/_otaclient_v2_pb2_wrapper.py index a4de6c2fa..8423928c4 100644 --- a/otaclient/app/proto/_otaclient_v2_pb2_wrapper.py +++ b/otaclient/app/proto/_otaclient_v2_pb2_wrapper.py @@ -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 diff --git a/otaclient/app/proto/otaclient_v2_pb2.py b/otaclient/app/proto/otaclient_v2_pb2.py index f7dc2e51a..17a67aaa8 100644 --- a/otaclient/app/proto/otaclient_v2_pb2.py +++ b/otaclient/app/proto/otaclient_v2_pb2.py @@ -12,8 +12,7 @@ _sym_db = _symbol_database.Default() -from google.protobuf import \ - duration_pb2 as google_dot_protobuf_dot_duration__pb2 +from google.protobuf import duration_pb2 as google_dot_protobuf_dot_duration__pb2 DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile( b'\n\x12otaclient_v2.proto\x12\x0bOtaClientV2\x1a\x1egoogle/protobuf/duration.proto"Q\n\x10UpdateRequestEcu\x12\x0e\n\x06\x65\x63u_id\x18\x01 \x01(\t\x12\x0f\n\x07version\x18\x02 \x01(\t\x12\x0b\n\x03url\x18\x03 \x01(\t\x12\x0f\n\x07\x63ookies\x18\x04 \x01(\t";\n\rUpdateRequest\x12*\n\x03\x65\x63u\x18\x01 \x03(\x0b\x32\x1d.OtaClientV2.UpdateRequestEcu"M\n\x11UpdateResponseEcu\x12\x0e\n\x06\x65\x63u_id\x18\x01 \x01(\t\x12(\n\x06result\x18\x02 \x01(\x0e\x32\x18.OtaClientV2.FailureType"=\n\x0eUpdateResponse\x12+\n\x03\x65\x63u\x18\x01 \x03(\x0b\x32\x1e.OtaClientV2.UpdateResponseEcu"$\n\x12RollbackRequestEcu\x12\x0e\n\x06\x65\x63u_id\x18\x01 \x01(\t"?\n\x0fRollbackRequest\x12,\n\x03\x65\x63u\x18\x01 \x03(\x0b\x32\x1f.OtaClientV2.RollbackRequestEcu"O\n\x13RollbackResponseEcu\x12\x0e\n\x06\x65\x63u_id\x18\x01 \x01(\t\x12(\n\x06result\x18\x02 \x01(\x0e\x32\x18.OtaClientV2.FailureType"A\n\x10RollbackResponse\x12-\n\x03\x65\x63u\x18\x01 \x03(\x0b\x32 .OtaClientV2.RollbackResponseEcu"\x0f\n\rStatusRequest"\xf6\x04\n\x0eStatusProgress\x12/\n\x05phase\x18\x01 \x01(\x0e\x32 .OtaClientV2.StatusProgressPhase\x12\x1b\n\x13total_regular_files\x18\x02 \x01(\x04\x12\x1f\n\x17regular_files_processed\x18\x03 \x01(\x04\x12\x1c\n\x14\x66iles_processed_copy\x18\x04 \x01(\x04\x12\x1c\n\x14\x66iles_processed_link\x18\x05 \x01(\x04\x12 \n\x18\x66iles_processed_download\x18\x06 \x01(\x04\x12 \n\x18\x66ile_size_processed_copy\x18\x07 \x01(\x04\x12 \n\x18\x66ile_size_processed_link\x18\x08 \x01(\x04\x12$\n\x1c\x66ile_size_processed_download\x18\t \x01(\x04\x12\x34\n\x11\x65lapsed_time_copy\x18\n \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x34\n\x11\x65lapsed_time_link\x18\x0b \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x38\n\x15\x65lapsed_time_download\x18\x0c \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x17\n\x0f\x65rrors_download\x18\r \x01(\x04\x12\x1f\n\x17total_regular_file_size\x18\x0e \x01(\x04\x12\x35\n\x12total_elapsed_time\x18\x0f \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x16\n\x0e\x64ownload_bytes\x18\x10 \x01(\x04"\xb3\x01\n\x06Status\x12&\n\x06status\x18\x01 \x01(\x0e\x32\x16.OtaClientV2.StatusOta\x12)\n\x07\x66\x61ilure\x18\x02 \x01(\x0e\x32\x18.OtaClientV2.FailureType\x12\x16\n\x0e\x66\x61ilure_reason\x18\x03 \x01(\t\x12\x0f\n\x07version\x18\x04 \x01(\t\x12-\n\x08progress\x18\x05 \x01(\x0b\x32\x1b.OtaClientV2.StatusProgress"r\n\x11StatusResponseEcu\x12\x0e\n\x06\x65\x63u_id\x18\x01 \x01(\t\x12(\n\x06result\x18\x02 \x01(\x0e\x32\x18.OtaClientV2.FailureType\x12#\n\x06status\x18\x03 \x01(\x0b\x32\x13.OtaClientV2.Status"\x8e\x01\n\x0eStatusResponse\x12/\n\x03\x65\x63u\x18\x01 \x03(\x0b\x32\x1e.OtaClientV2.StatusResponseEcuB\x02\x18\x01\x12\x19\n\x11\x61vailable_ecu_ids\x18\x02 \x03(\t\x12\x30\n\x06\x65\x63u_v2\x18\x03 \x03(\x0b\x32 .OtaClientV2.StatusResponseEcuV2"\x87\x03\n\x13StatusResponseEcuV2\x12\x0e\n\x06\x65\x63u_id\x18\x01 \x01(\t\x12\x18\n\x10\x66irmware_version\x18\x02 \x01(\t\x12\x19\n\x11otaclient_version\x18\x03 \x01(\t\x12*\n\nota_status\x18\x0b \x01(\x0e\x32\x16.OtaClientV2.StatusOta\x12\x33\n\x0c\x66\x61ilure_type\x18\x0c \x01(\x0e\x32\x18.OtaClientV2.FailureTypeH\x00\x88\x01\x01\x12\x1b\n\x0e\x66\x61ilure_reason\x18\r \x01(\tH\x01\x88\x01\x01\x12\x1e\n\x11\x66\x61ilure_traceback\x18\x0e \x01(\tH\x02\x88\x01\x01\x12\x35\n\rupdate_status\x18\x0f \x01(\x0b\x32\x19.OtaClientV2.UpdateStatusH\x03\x88\x01\x01\x42\x0f\n\r_failure_typeB\x11\n\x0f_failure_reasonB\x14\n\x12_failure_tracebackB\x10\n\x0e_update_statusJ\x04\x08\x04\x10\x0bJ\x04\x08\x10\x10\x11"\xdd\x05\n\x0cUpdateStatus\x12\x1f\n\x17update_firmware_version\x18\x01 \x01(\t\x12%\n\x1dtotal_files_size_uncompressed\x18\x02 \x01(\x04\x12\x17\n\x0ftotal_files_num\x18\x03 \x01(\x04\x12\x1e\n\x16update_start_timestamp\x18\x04 \x01(\x04\x12\'\n\x05phase\x18\x0b \x01(\x0e\x32\x18.OtaClientV2.UpdatePhase\x12 \n\x18total_download_files_num\x18\x0c \x01(\x04\x12!\n\x19total_download_files_size\x18\r \x01(\x04\x12\x1c\n\x14\x64ownloaded_files_num\x18\x0e \x01(\x04\x12\x18\n\x10\x64ownloaded_bytes\x18\x0f \x01(\x04\x12\x1d\n\x15\x64ownloaded_files_size\x18\x10 \x01(\x04\x12\x1a\n\x12\x64ownloading_errors\x18\x11 \x01(\x04\x12\x1e\n\x16total_remove_files_num\x18\x12 \x01(\x04\x12\x19\n\x11removed_files_num\x18\x13 \x01(\x04\x12\x1b\n\x13processed_files_num\x18\x14 \x01(\x04\x12\x1c\n\x14processed_files_size\x18\x15 \x01(\x04\x12\x35\n\x12total_elapsed_time\x18\x1f \x01(\x0b\x32\x19.google.protobuf.Duration\x12@\n\x1d\x64\x65lta_generating_elapsed_time\x18 \x01(\x0b\x32\x19.google.protobuf.Duration\x12;\n\x18\x64ownloading_elapsed_time\x18! \x01(\x0b\x32\x19.google.protobuf.Duration\x12?\n\x1cupdate_applying_elapsed_time\x18" \x01(\x0b\x32\x19.google.protobuf.Duration*A\n\x0b\x46\x61ilureType\x12\x0e\n\nNO_FAILURE\x10\x00\x12\x0f\n\x0bRECOVERABLE\x10\x01\x12\x11\n\rUNRECOVERABLE\x10\x02*k\n\tStatusOta\x12\x0f\n\x0bINITIALIZED\x10\x00\x12\x0b\n\x07SUCCESS\x10\x01\x12\x0b\n\x07\x46\x41ILURE\x10\x02\x12\x0c\n\x08UPDATING\x10\x03\x12\x0f\n\x0bROLLBACKING\x10\x04\x12\x14\n\x10ROLLBACK_FAILURE\x10\x05*~\n\x13StatusProgressPhase\x12\x0b\n\x07INITIAL\x10\x00\x12\x0c\n\x08METADATA\x10\x01\x12\r\n\tDIRECTORY\x10\x02\x12\x0b\n\x07SYMLINK\x10\x03\x12\x0b\n\x07REGULAR\x10\x04\x12\x0e\n\nPERSISTENT\x10\x05\x12\x13\n\x0fPOST_PROCESSING\x10\x06*\xb1\x01\n\x0bUpdatePhase\x12\x10\n\x0cINITIALIZING\x10\x00\x12\x17\n\x13PROCESSING_METADATA\x10\x01\x12\x15\n\x11\x43\x41LCULATING_DELTA\x10\x02\x12\x19\n\x15\x44OWNLOADING_OTA_FILES\x10\x03\x12\x13\n\x0f\x41PPLYING_UPDATE\x10\x04\x12\x19\n\x15PROCESSING_POSTUPDATE\x10\x05\x12\x15\n\x11\x46INALIZING_UPDATE\x10\x06\x32\xe7\x01\n\x10OtaClientService\x12\x43\n\x06Update\x12\x1a.OtaClientV2.UpdateRequest\x1a\x1b.OtaClientV2.UpdateResponse"\x00\x12I\n\x08Rollback\x12\x1c.OtaClientV2.RollbackRequest\x1a\x1d.OtaClientV2.RollbackResponse"\x00\x12\x43\n\x06Status\x12\x1a.OtaClientV2.StatusRequest\x1a\x1b.OtaClientV2.StatusResponse"\x00\x42\x06\xa2\x02\x03OTAb\x06proto3' diff --git a/otaclient/configs/ecu_info.py b/otaclient/configs/ecu_info.py index 54a28f95e..50b4c8815 100644 --- a/otaclient/configs/ecu_info.py +++ b/otaclient/configs/ecu_info.py @@ -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__) diff --git a/otaclient/ota_proxy/orm.py b/otaclient/ota_proxy/orm.py index 023594693..53f1fa92a 100644 --- a/otaclient/ota_proxy/orm.py +++ b/otaclient/ota_proxy/orm.py @@ -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 diff --git a/otaclient/ota_proxy/ota_cache.py b/otaclient/ota_proxy/ota_cache.py index ffd738613..83735da8e 100644 --- a/otaclient/ota_proxy/ota_cache.py +++ b/otaclient/ota_proxy/ota_cache.py @@ -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 @@ -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__) diff --git a/otaclient/ota_proxy/server_app.py b/otaclient/ota_proxy/server_app.py index 4ff5a7119..2349ff284 100644 --- a/otaclient/ota_proxy/server_app.py +++ b/otaclient/ota_proxy/server_app.py @@ -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 diff --git a/tests/test_boot_control/test_grub.py b/tests/test_boot_control/test_grub.py index b835db589..b8560e837 100644 --- a/tests/test_boot_control/test_grub.py +++ b/tests/test_boot_control/test_grub.py @@ -219,8 +219,7 @@ def mock_setup( mocker: pytest_mock.MockerFixture, grub_ab_slot, ): - from otaclient.app.boot_control._common import (CMDHelperFuncs, - SlotMountHelper) + from otaclient.app.boot_control._common import CMDHelperFuncs, SlotMountHelper from otaclient.app.boot_control._grub import GrubABPartitionDetector # ------ start fsm ------ # diff --git a/tests/test_boot_control/test_jetson_cboot.py b/tests/test_boot_control/test_jetson_cboot.py index 5a4527740..001f7517d 100644 --- a/tests/test_boot_control/test_jetson_cboot.py +++ b/tests/test_boot_control/test_jetson_cboot.py @@ -25,10 +25,13 @@ import pytest from otaclient.app.boot_control import _jetson_cboot -from otaclient.app.boot_control._jetson_cboot import (BSPVersion, - FirmwareBSPVersion, - SlotID, _CBootControl, - parse_bsp_version) +from otaclient.app.boot_control._jetson_cboot import ( + BSPVersion, + FirmwareBSPVersion, + SlotID, + _CBootControl, + parse_bsp_version, +) logger = logging.getLogger(__name__) diff --git a/tests/test_common.py b/tests/test_common.py index 7919cfde7..d745faf76 100644 --- a/tests/test_common.py +++ b/tests/test_common.py @@ -26,12 +26,20 @@ import pytest -from otaclient.app.common import (RetryTaskMap, RetryTaskMapInterrupted, - copytree_identical, ensure_otaproxy_start, - file_sha256, get_backoff, re_symlink_atomic, - read_str_from_file, subprocess_call, - subprocess_check_output, verify_file, - write_str_to_file_sync) +from otaclient.app.common import ( + RetryTaskMap, + RetryTaskMapInterrupted, + copytree_identical, + ensure_otaproxy_start, + file_sha256, + get_backoff, + re_symlink_atomic, + read_str_from_file, + subprocess_call, + subprocess_check_output, + verify_file, + write_str_to_file_sync, +) from tests.conftest import run_http_server from tests.utils import compare_dir diff --git a/tests/test_downloader.py b/tests/test_downloader.py index e2d1bcada..b11324d53 100644 --- a/tests/test_downloader.py +++ b/tests/test_downloader.py @@ -25,11 +25,15 @@ import requests_mock from otaclient.app.common import file_sha256, urljoin_ensure_base -from otaclient.app.downloader import (ChunkStreamingError, - DestinationNotAvailableError, Downloader, - DownloadError, ExceedMaxRetryError, - HashVerificaitonError, - UnhandledHTTPError) +from otaclient.app.downloader import ( + ChunkStreamingError, + DestinationNotAvailableError, + Downloader, + DownloadError, + ExceedMaxRetryError, + HashVerificaitonError, + UnhandledHTTPError, +) from tests.conftest import TestConfiguration as cfg from tests.utils import zstd_compress_file diff --git a/tests/test_ecu_info.py b/tests/test_ecu_info.py index 1ba739e43..20354f62d 100644 --- a/tests/test_ecu_info.py +++ b/tests/test_ecu_info.py @@ -19,8 +19,13 @@ import pytest -from otaclient.configs.ecu_info import (DEFAULT_ECU_INFO, BootloaderType, - ECUContact, ECUInfo, parse_ecu_info) +from otaclient.configs.ecu_info import ( + DEFAULT_ECU_INFO, + BootloaderType, + ECUContact, + ECUInfo, + parse_ecu_info, +) @pytest.mark.parametrize( diff --git a/tests/test_ota_client.py b/tests/test_ota_client.py index 746a25a63..5496d647a 100644 --- a/tests/test_ota_client.py +++ b/tests/test_ota_client.py @@ -31,10 +31,13 @@ from otaclient.app.create_standby import StandbySlotCreatorProtocol from otaclient.app.create_standby.common import DeltaBundle, RegularDelta from otaclient.app.errors import OTAErrorRecoverable -from otaclient.app.ota_client import (OTAClient, OTAClientControlFlags, - OTAServicer, _OTAUpdater) -from otaclient.app.ota_metadata import (parse_dirs_from_txt, - parse_regulars_from_txt) +from otaclient.app.ota_client import ( + OTAClient, + OTAClientControlFlags, + OTAServicer, + _OTAUpdater, +) +from otaclient.app.ota_metadata import parse_dirs_from_txt, parse_regulars_from_txt from otaclient.app.proto import wrapper from otaclient.app.proto.wrapper import DirectoryInf, RegularInf from otaclient.configs.ecu_info import ECUInfo diff --git a/tests/test_ota_client_stub.py b/tests/test_ota_client_stub.py index b4eea874c..e16293d1a 100644 --- a/tests/test_ota_client_stub.py +++ b/tests/test_ota_client_stub.py @@ -26,9 +26,11 @@ from otaclient.app.ota_client import OTAServicer from otaclient.app.ota_client_call import OtaClientCall -from otaclient.app.ota_client_stub import (ECUStatusStorage, - OTAClientServiceStub, - OTAProxyLauncher) +from otaclient.app.ota_client_stub import ( + ECUStatusStorage, + OTAClientServiceStub, + OTAProxyLauncher, +) from otaclient.app.proto import wrapper from otaclient.configs.ecu_info import ECUInfo, parse_ecu_info from otaclient.configs.proxy_info import ProxyInfo, parse_proxy_info diff --git a/tests/test_ota_metadata.py b/tests/test_ota_metadata.py index 9cf4df3af..eb5bb502d 100644 --- a/tests/test_ota_metadata.py +++ b/tests/test_ota_metadata.py @@ -27,13 +27,15 @@ from cryptography.hazmat.primitives import hashes, serialization from cryptography.hazmat.primitives.asymmetric import ec -from otaclient.app.ota_metadata import (MetadataJWTPayloadInvalid, - MetadataJWTVerificationFailed, - _MetadataJWTParser, - parse_dirs_from_txt, - parse_persistents_from_txt, - parse_regulars_from_txt, - parse_symlinks_from_txt) +from otaclient.app.ota_metadata import ( + MetadataJWTPayloadInvalid, + MetadataJWTVerificationFailed, + _MetadataJWTParser, + parse_dirs_from_txt, + parse_persistents_from_txt, + parse_regulars_from_txt, + parse_symlinks_from_txt, +) HEADER = """\ {"alg": "ES256"}\ diff --git a/tests/test_ota_proxy/test_cachedb.py b/tests/test_ota_proxy/test_cachedb.py index a5966d3a7..7c3d3c3fd 100644 --- a/tests/test_ota_proxy/test_cachedb.py +++ b/tests/test_ota_proxy/test_cachedb.py @@ -33,8 +33,7 @@ class TestORM: @pytest.fixture(autouse=True) def create_table_defs(self): - from otaclient.ota_proxy.orm import (NULL_TYPE, ColumnDescriptor, - ORMBase) + from otaclient.ota_proxy.orm import NULL_TYPE, ColumnDescriptor, ORMBase @dataclass class TableCls(ORMBase): diff --git a/tests/test_ota_proxy/test_subprocess_launch_otaproxy.py b/tests/test_ota_proxy/test_subprocess_launch_otaproxy.py index f7e441485..512a2bed3 100644 --- a/tests/test_ota_proxy/test_subprocess_launch_otaproxy.py +++ b/tests/test_ota_proxy/test_subprocess_launch_otaproxy.py @@ -18,8 +18,7 @@ from pathlib import Path from typing import Any, Dict -from otaclient.ota_proxy import (OTAProxyContextProto, - subprocess_otaproxy_launcher) +from otaclient.ota_proxy import OTAProxyContextProto, subprocess_otaproxy_launcher class _DummyOTAProxyContext(OTAProxyContextProto): diff --git a/tests/test_proto/example_pb2.py b/tests/test_proto/example_pb2.py index 622331863..d826b71cf 100644 --- a/tests/test_proto/example_pb2.py +++ b/tests/test_proto/example_pb2.py @@ -12,8 +12,7 @@ _sym_db = _symbol_database.Default() -from google.protobuf import \ - duration_pb2 as google_dot_protobuf_dot_duration__pb2 +from google.protobuf import duration_pb2 as google_dot_protobuf_dot_duration__pb2 DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile( b'\n\rexample.proto\x1a\x1egoogle/protobuf/duration.proto"\x9e\x01\n\x0cInnerMessage\x12\x11\n\tint_field\x18\x01 \x01(\r\x12\x14\n\x0c\x64ouble_field\x18\x02 \x01(\x01\x12\x11\n\tstr_field\x18\x03 \x01(\t\x12\x31\n\x0e\x64uration_field\x18\x04 \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x1f\n\nenum_field\x18\x05 \x01(\x0e\x32\x0b.SampleEnum"\x99\x03\n\x0cOuterMessage\x12\x1d\n\x15repeated_scalar_field\x18\x01 \x03(\t\x12/\n\x18repeated_composite_field\x18\x02 \x03(\x0b\x32\r.InnerMessage\x12!\n\nnested_msg\x18\x03 \x01(\x0b\x32\r.InnerMessage\x12\x43\n\x14mapping_scalar_field\x18\x04 \x03(\x0b\x32%.OuterMessage.MappingScalarFieldEntry\x12I\n\x17mapping_composite_field\x18\x05 \x03(\x0b\x32(.OuterMessage.MappingCompositeFieldEntry\x1a\x39\n\x17MappingScalarFieldEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\t:\x02\x38\x01\x1aK\n\x1aMappingCompositeFieldEntry\x12\x0b\n\x03key\x18\x01 \x01(\r\x12\x1c\n\x05value\x18\x02 \x01(\x0b\x32\r.InnerMessage:\x02\x38\x01*3\n\nSampleEnum\x12\x0b\n\x07VALUE_0\x10\x00\x12\x0b\n\x07VALUE_1\x10\x01\x12\x0b\n\x07VALUE_2\x10\x02\x62\x06proto3' diff --git a/tests/test_proto/example_pb2_wrapper.py b/tests/test_proto/example_pb2_wrapper.py index 4e06f0b2a..45ae7cd04 100644 --- a/tests/test_proto/example_pb2_wrapper.py +++ b/tests/test_proto/example_pb2_wrapper.py @@ -18,11 +18,16 @@ from typing import Optional as _Optional from typing import Union as _Union -from otaclient.app.proto.wrapper import (Duration, EnumWrapper, - MessageMapContainer, MessageWrapper, - RepeatedCompositeContainer, - RepeatedScalarContainer, - ScalarMapContainer, calculate_slots) +from otaclient.app.proto.wrapper import ( + Duration, + EnumWrapper, + MessageMapContainer, + MessageWrapper, + RepeatedCompositeContainer, + RepeatedScalarContainer, + ScalarMapContainer, + calculate_slots, +) from . import example_pb2 as _pb2 diff --git a/tests/test_proxy_info.py b/tests/test_proxy_info.py index 2193ca79e..9fa0d1def 100644 --- a/tests/test_proxy_info.py +++ b/tests/test_proxy_info.py @@ -20,8 +20,7 @@ import pytest -from otaclient.configs.proxy_info import (DEFAULT_PROXY_INFO, ProxyInfo, - parse_proxy_info) +from otaclient.configs.proxy_info import DEFAULT_PROXY_INFO, ProxyInfo, parse_proxy_info logger = logging.getLogger(__name__) diff --git a/tests/test_update_stats.py b/tests/test_update_stats.py index 6e978a633..835d5c71a 100644 --- a/tests/test_update_stats.py +++ b/tests/test_update_stats.py @@ -18,9 +18,11 @@ import pytest -from otaclient.app.update_stats import (OTAUpdateStatsCollector, - RegInfProcessedStats, - RegProcessOperation) +from otaclient.app.update_stats import ( + OTAUpdateStatsCollector, + RegInfProcessedStats, + RegProcessOperation, +) logger = logging.getLogger(__name__) diff --git a/tools/emulator/main.py b/tools/emulator/main.py index ce61a5bf9..8c859d54e 100644 --- a/tools/emulator/main.py +++ b/tools/emulator/main.py @@ -24,8 +24,12 @@ from configs import config as cfg from configs import server_cfg from ecu import Ecu -from ota_client_service import (OtaClientServiceV2, service_start, - service_stop, service_wait_for_termination) +from ota_client_service import ( + OtaClientServiceV2, + service_start, + service_stop, + service_wait_for_termination, +) from ota_client_stub import OtaClientStub logger = log_setting.get_logger( diff --git a/tools/status_monitor/main_win.py b/tools/status_monitor/main_win.py index 06f75388a..10bc556ae 100644 --- a/tools/status_monitor/main_win.py +++ b/tools/status_monitor/main_win.py @@ -19,8 +19,13 @@ from .configs import config, key_mapping from .ecu_status_box import ECUStatusDisplayBox -from .utils import (ASCII_NUM_MAPPING, PAGE_SCROLL_KEYS, init_pad, - page_scroll_key_handler, reset_scr) +from .utils import ( + ASCII_NUM_MAPPING, + PAGE_SCROLL_KEYS, + init_pad, + page_scroll_key_handler, + reset_scr, +) class MainScreen: