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

refactor: replace check_call with run_command (no-merge) #64

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
11 changes: 5 additions & 6 deletions pyaptly/mirror.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""Create and update mirrors in aptly."""
import logging
import subprocess

from . import state_reader, util

Expand Down Expand Up @@ -47,16 +46,16 @@ def add_gpg_keys(mirror_config):
key,
]
lg.debug("Adding gpg key with call: %s", key_command)
subprocess.check_call(key_command)
except subprocess.CalledProcessError: # pragma: no cover
util.run_command(key_command, check=True)
except util.CalledProcessError: # pragma: no cover
url = keys_urls[key]
if url:
key_shell = (
"curl %s | "
"gpg --no-default-keyring --keyring trustedkeys.gpg "
"--import"
) % url
subprocess.check_call(["bash", "-c", key_shell])
util.run_command(["bash", "-c", key_shell], check=True)
else:
raise
state_reader.state.read_gpg()
Expand Down Expand Up @@ -129,7 +128,7 @@ def cmd_mirror_create(cfg, mirror_name, mirror_config):
aptly_cmd.extend(util.unit_or_list_to_list(mirror_config["components"]))

lg.debug("Running command: %s", " ".join(aptly_cmd))
subprocess.check_call(aptly_cmd)
util.run_command(aptly_cmd, check=True)


def cmd_mirror_update(cfg, mirror_name, mirror_config):
Expand All @@ -151,4 +150,4 @@ def cmd_mirror_update(cfg, mirror_name, mirror_config):

aptly_cmd.append(mirror_name)
lg.debug("Running command: %s", " ".join(aptly_cmd))
subprocess.check_call(aptly_cmd)
util.run_command(aptly_cmd, check=True)
Loading