From 21cda43b25bb4052627280f5db6b4b437e793ee7 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 10 Jan 2024 01:30:45 +0000 Subject: [PATCH] chore: update charm libraries --- lib/charms/operator_libs_linux/v0/apt.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/charms/operator_libs_linux/v0/apt.py b/lib/charms/operator_libs_linux/v0/apt.py index 7afb183..1400df7 100644 --- a/lib/charms/operator_libs_linux/v0/apt.py +++ b/lib/charms/operator_libs_linux/v0/apt.py @@ -108,7 +108,7 @@ import subprocess from collections.abc import Mapping from enum import Enum -from subprocess import PIPE, CalledProcessError, check_call, check_output +from subprocess import PIPE, CalledProcessError, check_output from typing import Iterable, List, Optional, Tuple, Union from urllib.parse import urlparse @@ -122,7 +122,7 @@ # Increment this PATCH version before using `charmcraft publish-lib` or reset # to 0 if you are raising the major API version -LIBPATCH = 11 +LIBPATCH = 13 VALID_SOURCE_TYPES = ("deb", "deb-src") @@ -250,10 +250,10 @@ def _apt( try: env = os.environ.copy() env["DEBIAN_FRONTEND"] = "noninteractive" - check_call(_cmd, env=env, stderr=PIPE, stdout=PIPE) + subprocess.run(_cmd, capture_output=True, check=True, text=True, env=env) except CalledProcessError as e: raise PackageError( - "Could not {} package(s) [{}]: {}".format(command, [*package_names], e.output) + "Could not {} package(s) [{}]: {}".format(command, [*package_names], e.stderr) ) from None def _add(self) -> None: @@ -476,7 +476,7 @@ def from_apt_cache( ) except CalledProcessError as e: raise PackageError( - "Could not list packages in apt-cache: {}".format(e.output) + "Could not list packages in apt-cache: {}".format(e.stderr) ) from None pkg_groups = output.strip().split("\n\n") @@ -748,7 +748,7 @@ def add_package( packages = {"success": [], "retry": [], "failed": []} - package_names = [package_names] if type(package_names) is str else package_names + package_names = [package_names] if isinstance(package_names, str) else package_names if not package_names: raise TypeError("Expected at least one package name to add, received zero!") @@ -818,7 +818,7 @@ def remove_package( """ packages = [] - package_names = [package_names] if type(package_names) is str else package_names + package_names = [package_names] if isinstance(package_names, str) else package_names if not package_names: raise TypeError("Expected at least one package name to add, received zero!") @@ -837,7 +837,7 @@ def remove_package( def update() -> None: """Update the apt cache via `apt-get update`.""" - check_call(["apt-get", "update"], stderr=PIPE, stdout=PIPE) + subprocess.run(["apt-get", "update"], capture_output=True, check=True) def import_key(key: str) -> str: