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

Update charm libraries #11

Merged
merged 1 commit into from
Jan 10, 2024
Merged
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
16 changes: 8 additions & 8 deletions lib/charms/operator_libs_linux/v0/apt.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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")
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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!")

Expand Down Expand Up @@ -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!")

Expand All @@ -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:
Expand Down
Loading