From 45178808469af24058397744b2df1f3ab8393847 Mon Sep 17 00:00:00 2001 From: einarf Date: Thu, 28 May 2020 00:13:27 +0200 Subject: [PATCH] pep8 --- src/restic_compose_backup/cli.py | 13 +++++++++++-- src/restic_compose_backup/containers.py | 3 ++- src/restic_compose_backup/log.py | 6 +++--- src/restic_compose_backup/utils.py | 5 ++++- 4 files changed, 20 insertions(+), 7 deletions(-) diff --git a/src/restic_compose_backup/cli.py b/src/restic_compose_backup/cli.py index c558c2e..fb8cbce 100644 --- a/src/restic_compose_backup/cli.py +++ b/src/restic_compose_backup/cli.py @@ -93,12 +93,21 @@ def status(config, containers): if container.volume_backup_enabled: for mount in container.filter_mounts(): - logger.info(' - volume: %s -> %s', mount.source, container.get_volume_backup_destination(mount, '/volumes')) + logger.info( + ' - volume: %s -> %s', + mount.source, + container.get_volume_backup_destination(mount, '/volumes'), + ) if container.database_backup_enabled: instance = container.instance ping = instance.ping() - logger.info(' - %s (is_ready=%s) -> %s', instance.container_type, ping == 0, instance.backup_destination_path()) + logger.info( + ' - %s (is_ready=%s) -> %s', + instance.container_type, + ping == 0, + instance.backup_destination_path(), + ) if ping != 0: logger.error("Database '%s' in service %s cannot be reached", instance.container_type, container.service_name) diff --git a/src/restic_compose_backup/containers.py b/src/restic_compose_backup/containers.py index acf12db..8ad0f97 100644 --- a/src/restic_compose_backup/containers.py +++ b/src/restic_compose_backup/containers.py @@ -72,7 +72,8 @@ class Container: @property def service_name(self) -> str: """Name of the container/service""" - return self.get_label('com.docker.compose.service', default='') or self.get_label('com.docker.swarm.service.name', default='') + return self.get_label('com.docker.compose.service', default='') or \ + self.get_label('com.docker.swarm.service.name', default='') @property def backup_process_label(self) -> str: diff --git a/src/restic_compose_backup/log.py b/src/restic_compose_backup/log.py index 4c3e82b..e4663cf 100644 --- a/src/restic_compose_backup/log.py +++ b/src/restic_compose_backup/log.py @@ -22,7 +22,7 @@ def setup(level: str = 'warning'): ch = logging.StreamHandler(stream=sys.stdout) ch.setLevel(level) - # ch.setFormatter(logging.Formatter(f'%(asctime)s - {HOSTNAME} - %(name)s - %(levelname)s - %(message)s')) - # ch.setFormatter(logging.Formatter(f'%(asctime)s - {HOSTNAME} - %(levelname)s - %(message)s')) - ch.setFormatter(logging.Formatter(f'%(asctime)s - %(levelname)s: %(message)s')) + # ch.setFormatter(logging.Formatter('%(asctime)s - {HOSTNAME} - %(name)s - %(levelname)s - %(message)s')) + # ch.setFormatter(logging.Formatter('%(asctime)s - {HOSTNAME} - %(levelname)s - %(message)s')) + ch.setFormatter(logging.Formatter('%(asctime)s - %(levelname)s: %(message)s')) logger.addHandler(ch) diff --git a/src/restic_compose_backup/utils.py b/src/restic_compose_backup/utils.py index 1debddd..0f96fbe 100644 --- a/src/restic_compose_backup/utils.py +++ b/src/restic_compose_backup/utils.py @@ -1,9 +1,12 @@ import os import logging -from typing import List +from typing import List, TYPE_CHECKING from contextlib import contextmanager import docker +if TYPE_CHECKING: + from restic_compose_backup.containers import Container + logger = logging.getLogger(__name__) TRUE_VALUES = ['1', 'true', 'True', True, 1]