From 260ab2ba227e2c800f630891b84f70825b7882bc Mon Sep 17 00:00:00 2001 From: Sebastian Mark Date: Mon, 10 Jun 2024 12:09:05 +0200 Subject: [PATCH] chore: fix pylint complains --- dc-ops | 10 ++++++---- lib/helper.py | 12 ++++++++---- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/dc-ops b/dc-ops index 2651f96..311fe48 100755 --- a/dc-ops +++ b/dc-ops @@ -5,6 +5,8 @@ # CC-BY-SA (https://creativecommons.org/licenses/by-sa/4.0/deed.de) # for civil use only +# pylint: disable=missing-module-docstring,invalid-name + import argparse import logging as log from pathlib import Path @@ -15,12 +17,12 @@ from lib.helper import run_subprocess, update_git_repo, do_selfupdate # read config file configfile = Path(__file__).with_name("config.yml") -with configfile.open("r") as f: +with configfile.open("r", encoding="utf-8") as f: cfg = yaml.safe_load(f.read()) # fmt: off parser = argparse.ArgumentParser() -parser.add_argument("--ignore-git-status", action="store_true", help="continue even if there are no new commits") # noqa +parser.add_argument("--ignore-git-status", action="store_true", help="continue even if there are no new commits") parser.add_argument("--loglevel", help="set loglevel (overrides config file)") args = parser.parse_args() # fmt: on @@ -47,7 +49,7 @@ for stack in cfg["stacks"]: # header stackdir = stack["dir"] - log.info(f"processing: {stackdir}") + log.info("processing: %s", stackdir) # update repo and check for new commits if not update_git_repo(stackdir, args.ignore_git_status): @@ -63,7 +65,7 @@ for stack in cfg["stacks"]: # (or just for the directory if no compose-file defined) composefiles = stack.get("compose-files", ["docker-compose.yml"]) for composefile in composefiles: - log.info(f"-> bringing up {composefile}") + log.info("-> bringing up %s", composefile) if not run_subprocess( f"docker compose --file {composefile} up --detach {composeopts}", stackdir, diff --git a/lib/helper.py b/lib/helper.py index 2bb56d5..1fbe286 100644 --- a/lib/helper.py +++ b/lib/helper.py @@ -1,3 +1,5 @@ +# pylint: disable=missing-module-docstring + import logging as log import subprocess import sys @@ -32,7 +34,9 @@ def run_subprocess(command: str, workdir: str) -> bool: bool: False if subprocess fails """ try: - log.debug(subprocess.run(command.split(" "), cwd=workdir, text=True)) + log.debug( + subprocess.run(command.split(" "), cwd=workdir, text=True, check=False) + ) except subprocess.CalledProcessError: return False @@ -62,7 +66,7 @@ def update_git_repo(repo_path: str, ignore_git_status: bool) -> bool: try: fetch_res = repo.remotes.origin.fetch()[0] except git.exc.GitCommandError as e: - log.error("-> " + str(e)) + log.error("-> %s ", str(e)) return False # check for new commits @@ -72,9 +76,9 @@ def update_git_repo(repo_path: str, ignore_git_status: bool) -> bool: # pull remote changes to local branch try: - log.info("-> " + repo.git.pull()) + log.info("-> %s", repo.git.pull()) except git.exc.GitCommandError as e: - log.error("-> " + str(e)) + log.error("-> %s", str(e)) return False return True