Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refine(v3.6.x): log_setting #284

Merged
merged 2 commits into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions otaclient/app/boot_control/_cboot.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# limitations under the License.


import logging
import os
import re
from pathlib import Path
Expand All @@ -21,7 +22,7 @@
from typing import Generator, Optional


from .. import log_setting, errors as ota_errors
from .. import errors as ota_errors
from ..common import (
copytree_identical,
read_str_from_file,
Expand All @@ -44,9 +45,7 @@
from .firmware import Firmware


logger = log_setting.get_logger(
__name__, cfg.LOG_LEVEL_TABLE.get(__name__, cfg.DEFAULT_LOG_LEVEL)
)
logger = logging.getLogger(__name__)


class NvbootctrlError(Exception):
Expand Down Expand Up @@ -178,7 +177,9 @@ def _init_dev_info(self):
self.current_slot: str = Nvbootctrl.get_current_slot()
self.current_rootfs_dev: str = CMDHelperFuncs.get_current_rootfs_dev()
# NOTE: boot dev is always emmc device now
self.current_boot_dev: str = f"/dev/{Nvbootctrl.EMMC_DEV}p{Nvbootctrl.SLOTID_PARTID_MAP[self.current_slot]}"
self.current_boot_dev: str = (
f"/dev/{Nvbootctrl.EMMC_DEV}p{Nvbootctrl.SLOTID_PARTID_MAP[self.current_slot]}"
)

self.standby_slot: str = Nvbootctrl.CURRENT_STANDBY_FLIP[self.current_slot]
standby_partid = Nvbootctrl.SLOTID_PARTID_MAP[self.standby_slot]
Expand Down
6 changes: 2 additions & 4 deletions otaclient/app/boot_control/_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
r"""Shared utils for boot_controller."""


import logging
import os
import shutil
import sys
Expand All @@ -28,7 +29,6 @@
MountFailedReason,
)

from .. import log_setting
from ..configs import config as cfg
from ..common import (
read_str_from_file,
Expand All @@ -39,9 +39,7 @@
from ..proto import wrapper


logger = log_setting.get_logger(
__name__, cfg.LOG_LEVEL_TABLE.get(__name__, cfg.DEFAULT_LOG_LEVEL)
)
logger = logging.getLogger(__name__)


class CMDHelperFuncs:
Expand Down
7 changes: 3 additions & 4 deletions otaclient/app/boot_control/_grub.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"""


import logging
import re
import shutil
from dataclasses import dataclass
Expand All @@ -39,7 +40,7 @@
from pathlib import Path
from pprint import pformat

from .. import log_setting, errors as ota_errors
from .. import errors as ota_errors
from ..common import (
re_symlink_atomic,
read_str_from_file,
Expand All @@ -59,9 +60,7 @@
from .protocol import BootControllerProtocol


logger = log_setting.get_logger(
__name__, cfg.LOG_LEVEL_TABLE.get(__name__, cfg.DEFAULT_LOG_LEVEL)
)
logger = logging.getLogger(__name__)


class _GrubBootControllerError(Exception):
Expand Down
7 changes: 3 additions & 4 deletions otaclient/app/boot_control/_rpi_boot.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@
"""Boot control support for Raspberry pi 4 Model B."""


import logging
import os
import re
from string import Template
from pathlib import Path
from typing import Generator

from .. import log_setting, errors as ota_errors
from .. import errors as ota_errors
from ..proto import wrapper
from ..common import replace_atomic, subprocess_call

Expand All @@ -33,9 +34,7 @@
from .configs import rpi_boot_cfg as cfg
from .protocol import BootControllerProtocol

logger = log_setting.get_logger(
__name__, cfg.LOG_LEVEL_TABLE.get(__name__, cfg.DEFAULT_LOG_LEVEL)
)
logger = logging.getLogger(__name__)

_FSTAB_TEMPLATE_STR = (
"LABEL=${rootfs_fslabel}\t/\text4\tdiscard,x-systemd.growfs\t0\t1\n"
Expand Down
7 changes: 2 additions & 5 deletions otaclient/app/boot_control/firmware.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,13 @@
# limitations under the License.


import logging
import yaml
import zstandard
from pathlib import Path
from typing import Dict, Callable
from ..configs import config as cfg
from .. import log_setting

logger = log_setting.get_logger(
__name__, cfg.LOG_LEVEL_TABLE.get(__name__, cfg.DEFAULT_LOG_LEVEL)
)
logger = logging.getLogger(__name__)


class Firmware:
Expand Down
7 changes: 2 additions & 5 deletions otaclient/app/boot_control/selecter.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# limitations under the License.


import logging
import platform
from pathlib import Path
from typing import Type
Expand All @@ -21,13 +22,9 @@
from ._errors import BootControlError
from .protocol import BootControllerProtocol

from ..configs import config as cfg
from ..common import read_str_from_file
from .. import log_setting

logger = log_setting.get_logger(
__name__, cfg.LOG_LEVEL_TABLE.get(__name__, cfg.DEFAULT_LOG_LEVEL)
)
logger = logging.getLogger(__name__)


def detect_bootloader(raise_on_unknown=True) -> BootloaderType:
Expand Down
4 changes: 2 additions & 2 deletions otaclient/app/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

from __future__ import annotations
import itertools
import logging
import os
import shlex
import shutil
Expand All @@ -42,7 +43,6 @@
)
from urllib.parse import urljoin

from .log_setting import get_logger
from .configs import config as cfg

from otaclient._utils.linux import (
Expand All @@ -52,7 +52,7 @@
ParsedPasswd,
)

logger = get_logger(__name__, cfg.LOG_LEVEL_TABLE.get(__name__, cfg.DEFAULT_LOG_LEVEL))
logger = logging.getLogger(__name__)


def get_backoff(n: int, factor: float, _max: float) -> float:
Expand Down
8 changes: 3 additions & 5 deletions otaclient/app/create_standby/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,13 @@
# limitations under the License.


import logging
from typing import Type

from .interface import StandbySlotCreatorProtocol
from ..configs import CreateStandbyMechanism, config as cfg
from .. import log_setting
from ..configs import CreateStandbyMechanism

logger = log_setting.get_logger(
__name__, cfg.LOG_LEVEL_TABLE.get(__name__, cfg.DEFAULT_LOG_LEVEL)
)
logger = logging.getLogger(__name__)


def get_standby_slot_creator(
Expand Down
8 changes: 3 additions & 5 deletions otaclient/app/create_standby/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
r"""Common used helpers, classes and functions for different bank creating methods."""


r"""Common used helpers, classes and functions for different bank creating methods."""
import logging
import os
import random
import time
Expand Down Expand Up @@ -43,16 +44,13 @@
from ..configs import config as cfg
from ..ota_metadata import OTAMetadata, MetafilesV1
from ..proto.wrapper import RegularInf, DirectoryInf
from .. import log_setting
from ..update_stats import (
OTAUpdateStatsCollector,
RegProcessOperation,
RegInfProcessedStats,
)

logger = log_setting.get_logger(
__name__, cfg.LOG_LEVEL_TABLE.get(__name__, cfg.DEFAULT_LOG_LEVEL)
)
logger = logging.getLogger(__name__)


class _WeakRef:
Expand Down
6 changes: 2 additions & 4 deletions otaclient/app/create_standby/rebuild_mode.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# limitations under the License.


import logging
import os
import shutil
import time
Expand All @@ -29,14 +30,11 @@
RegProcessOperation,
)
from ..proto.wrapper import RegularInf
from .. import log_setting

from .common import HardlinkRegister, DeltaGenerator, DeltaBundle
from .interface import StandbySlotCreatorProtocol

logger = log_setting.get_logger(
__name__, cfg.LOG_LEVEL_TABLE.get(__name__, cfg.DEFAULT_LOG_LEVEL)
)
logger = logging.getLogger(__name__)


class RebuildMode(StandbySlotCreatorProtocol):
Expand Down
6 changes: 2 additions & 4 deletions otaclient/app/downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@


import errno
import logging
import os
import requests
import threading
Expand Down Expand Up @@ -50,11 +51,8 @@
from otaclient.ota_proxy import OTAFileCacheControl
from .configs import config as cfg
from .common import wait_with_backoff
from . import log_setting

logger = log_setting.get_logger(
__name__, cfg.LOG_LEVEL_TABLE.get(__name__, cfg.DEFAULT_LOG_LEVEL)
)
logger = logging.getLogger(__name__)

EMPTY_FILE_SHA256 = r"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
CACHE_CONTROL_HEADER = OTAFileCacheControl.HEADER_LOWERCASE
Expand Down
10 changes: 4 additions & 6 deletions otaclient/app/ecu_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,18 @@
# limitations under the License.
r"""ECU metadatas definition."""


import logging
import yaml
from copy import deepcopy
from dataclasses import dataclass, field, fields, MISSING
from pathlib import Path
from typing import Iterator, NamedTuple, Union, Dict, List, Any

from . import log_setting
from .configs import config as cfg, server_cfg
from .configs import server_cfg
from .boot_control import BootloaderType

logger = log_setting.get_logger(
__name__, cfg.LOG_LEVEL_TABLE.get(__name__, cfg.DEFAULT_LOG_LEVEL)
)

logger = logging.getLogger(__name__)

DEFAULT_ECU_INFO = {
"format_version": 1, # current version is 1
Expand Down
Loading
Loading