diff --git a/TODO b/TODO index cc5e17b..9014fba 100644 --- a/TODO +++ b/TODO @@ -27,3 +27,7 @@ The reason for this is to ensure the continuity of the git history. # Add good documentation to every function and module, but plan to review all of it once everything is in place + +# Do all output via logging module + +- Idea show INFO and above, but display info without timestamp etc. diff --git a/poetry.lock b/poetry.lock index c7bc605..7b8e00a 100644 --- a/poetry.lock +++ b/poetry.lock @@ -321,13 +321,13 @@ python-dateutil = ">=2.7" [[package]] name = "hypothesis" -version = "6.92.2" +version = "6.93.1" description = "A library for property-based testing" optional = false python-versions = ">=3.8" files = [ - {file = "hypothesis-6.92.2-py3-none-any.whl", hash = "sha256:d335044492acb03fa1fdb4edacb81cca2e578049fc7306345bc0e8947fef15a9"}, - {file = "hypothesis-6.92.2.tar.gz", hash = "sha256:841f89a486c43bdab55698de8929bd2635639ec20bf6ce98ccd75622d7ee6d41"}, + {file = "hypothesis-6.93.1-py3-none-any.whl", hash = "sha256:f2c32911c5ebde7097ac8715670daed0b6fb3431501c2b80cf39ba6bbc66cd7c"}, + {file = "hypothesis-6.93.1.tar.gz", hash = "sha256:637dc3cfb6ba7ac65b4599013f7b364dd99eeacd78e472c196e806ceada7519f"}, ] [package.dependencies] @@ -335,7 +335,7 @@ attrs = ">=22.2.0" sortedcontainers = ">=2.1.0,<3.0.0" [package.extras] -all = ["backports.zoneinfo (>=0.2.1)", "black (>=19.10b0)", "click (>=7.0)", "django (>=3.2)", "dpcontracts (>=0.4)", "lark (>=0.10.1)", "libcst (>=0.3.16)", "numpy (>=1.17.3)", "pandas (>=1.1)", "pytest (>=4.6)", "python-dateutil (>=1.4)", "pytz (>=2014.1)", "redis (>=3.0.0)", "rich (>=9.0.0)", "tzdata (>=2023.3)"] +all = ["backports.zoneinfo (>=0.2.1)", "black (>=19.10b0)", "click (>=7.0)", "django (>=3.2)", "dpcontracts (>=0.4)", "lark (>=0.10.1)", "libcst (>=0.3.16)", "numpy (>=1.17.3)", "pandas (>=1.1)", "pytest (>=4.6)", "python-dateutil (>=1.4)", "pytz (>=2014.1)", "redis (>=3.0.0)", "rich (>=9.0.0)", "tzdata (>=2023.4)"] cli = ["black (>=19.10b0)", "click (>=7.0)", "rich (>=9.0.0)"] codemods = ["libcst (>=0.3.16)"] dateutil = ["python-dateutil (>=1.4)"] @@ -348,7 +348,7 @@ pandas = ["pandas (>=1.1)"] pytest = ["pytest (>=4.6)"] pytz = ["pytz (>=2014.1)"] redis = ["redis (>=3.0.0)"] -zoneinfo = ["backports.zoneinfo (>=0.2.1)", "tzdata (>=2023.3)"] +zoneinfo = ["backports.zoneinfo (>=0.2.1)", "tzdata (>=2023.4)"] [[package]] name = "iniconfig" diff --git a/pyaptly/aptly_test.py b/pyaptly/aptly_test.py index 4cc9b66..492335c 100644 --- a/pyaptly/aptly_test.py +++ b/pyaptly/aptly_test.py @@ -106,7 +106,7 @@ def test_mirror_create(): assert state.mirrors == expect -def do_mirror_update(config): +def do_mirror_update(config): # pragma: no cover """Test if updating mirrors works.""" args = ["-c", config, "mirror", "create"] state = SystemStateReader() @@ -173,7 +173,7 @@ def test_mirror_update_single(): main(args) -def do_snapshot_create(config): +def do_snapshot_create(config): # pragma: no cover """Test if createing snapshots works""" do_mirror_update(config) args = ["-c", config, "snapshot", "create"] @@ -377,7 +377,7 @@ def test_snapshot_update_threetimes_rotating(): assert state.snapshot_map == expected -def do_snapshot_update_rotating(config): +def do_snapshot_update_rotating(config): # pragma: no cover """Helper for rotating snapshot tests""" do_mirror_update(config) args = [ @@ -461,6 +461,7 @@ def test_snapshot_create_repo(): return state +@pytest.mark.skip def test_snapshot_create_merge(): """Test if snapshot merge create works.""" with test.clean_and_config( @@ -490,6 +491,7 @@ def test_snapshot_create_merge(): assert expect == state.snapshot_map +@pytest.mark.skip def test_snapshot_create_filter(): """Test if snapshot filter create works.""" with test.clean_and_config( @@ -507,7 +509,7 @@ def test_snapshot_create_filter(): assert state == expect -def do_publish_create(config): +def do_publish_create(config): # pragma: no cover """Test if creating publishes works.""" do_snapshot_create(config) args = ["-c", config, "publish", "create"] @@ -522,7 +524,7 @@ def do_publish_create(config): assert expect == state.publish_map -def do_publish_create_rotating(config): +def do_publish_create_rotating(config): # pragma: no cover """Test if creating publishes works.""" do_snapshot_update_rotating(config) args = ["-c", config, "publish", "create"] @@ -547,6 +549,7 @@ def do_publish_create_rotating(config): assert expect == state.publish_map +@pytest.mark.skip def test_publish_create_single(): """Test if creating a single publish works.""" with test.clean_and_config( @@ -572,6 +575,7 @@ def test_publish_create_single(): assert expect == state.publish_map +@pytest.mark.skip def test_publish_create_inexistent(): """Test if creating inexistent publish raises an error.""" with test.clean_and_config( @@ -596,6 +600,7 @@ def test_publish_create_inexistent(): assert error +@pytest.mark.skip def test_publish_create_repo(): """Test if creating repo publishes works.""" with test.clean_and_config( @@ -626,6 +631,7 @@ def test_publish_create_repo(): assert {"centrify latest": set([])} == state.publish_map +@pytest.mark.skip def test_publish_create_basic(): """Test if creating publishes works.""" with test.clean_and_config( @@ -638,6 +644,7 @@ def test_publish_create_basic(): do_publish_create(config) +@pytest.mark.skip def test_publish_update_rotating(): """Test if update rotating publishes works.""" with test.clean_and_config( @@ -666,6 +673,7 @@ def test_publish_update_rotating(): assert expect == state.publish_map +@pytest.mark.skip def test_publish_snapshot_update_rotating(): """Test if update rotating publishes via snapshot works.""" with test.clean_and_config( @@ -694,6 +702,7 @@ def test_publish_snapshot_update_rotating(): assert expect == state.publish_map +@pytest.mark.skip def test_publish_create_rotating(): """Test if creating rotating publishes works.""" with test.clean_and_config( @@ -706,7 +715,7 @@ def test_publish_create_rotating(): do_publish_create_rotating(config) -def do_publish_create_republish(config): +def do_publish_create_republish(config): # pragma: no cover """Test if creating republishes works.""" with testfixtures.LogCapture() as l: do_publish_create(config) @@ -728,6 +737,7 @@ def do_publish_create_republish(config): assert "fakerepo01-stable main" in state.publishes +@pytest.mark.skip def test_publish_create_republish(): """Test if creating republishes works.""" with test.clean_and_config( @@ -740,6 +750,7 @@ def test_publish_create_republish(): do_publish_create_republish(config) +@pytest.mark.skip def test_publish_update_republish(): """Test if update republishes works.""" with test.clean_and_config( @@ -782,6 +793,7 @@ def test_publish_update_republish(): assert expect == state.publish_map +@pytest.mark.skip def test_publish_updating_basic(): """Test if updating publishes works.""" with test.clean_and_config( @@ -815,7 +827,7 @@ def test_publish_updating_basic(): assert expect == state.publish_map -def do_repo_create(config): +def do_repo_create(config): # pragma: no cover """Test if creating repositories works.""" args = ["-c", config, "repo", "create"] main(args) @@ -833,6 +845,7 @@ def do_repo_create(config): assert set(["centrify"]) == state.repos +@pytest.mark.skip def test_repo_create_single(): """Test if creating a single repo works.""" with test.clean_and_config( @@ -854,6 +867,7 @@ def test_repo_create_single(): assert set(["centrify"]) == state.repos +@pytest.mark.skip def test_repo_create_inexistent(): """Test if creating an inexistent repo causes an error.""" with test.clean_and_config( @@ -877,6 +891,7 @@ def test_repo_create_inexistent(): assert error +@pytest.mark.skip def test_repo_create_basic(): """Test if creating repositories works.""" with test.clean_and_config( @@ -888,6 +903,7 @@ def test_repo_create_basic(): do_repo_create(config) +@pytest.mark.skip def test_snapshot_spec_as_dict(): "Test various snapshot formats for snapshot_spec_to_name()" diff --git a/pyaptly/conftest.py b/pyaptly/conftest.py index 01183ea..6cea7b2 100644 --- a/pyaptly/conftest.py +++ b/pyaptly/conftest.py @@ -16,6 +16,7 @@ aptly_conf = Path.home().absolute() / ".aptly.conf" test_base = Path(__file__).absolute().parent / "tests" +setup_base = Path("/setup") @pytest.fixture() @@ -73,6 +74,13 @@ def environment(debug_mode): aptly_conf.unlink() +@pytest.fixture() +def test_key_03(environment): + """Get test gpg-key number 3.""" + util.run_command(["gpg", "--import", setup_base / "test03.key"], check=True) + util.run_command(["gpg", "--import", setup_base / "test03.pub"], check=True) + + @pytest.fixture() def freeze(request): """Freeze to datetime. @@ -204,7 +212,7 @@ def snapshot_update_rotating(config, mirror_update, freeze): @pytest.fixture() -def repo_create(environment, config): +def repo_create(environment, config, test_key_03): """Test if creating repositories works.""" args = ["-c", config, "repo", "create"] pyaptly.main(args) @@ -220,3 +228,64 @@ def repo_create(environment, config): ] ) assert set(["centrify"]) == state.repos + + +@pytest.fixture() +def publish_create(config, snapshot_create, test_key_03): + """Test if creating publishes works.""" + args = ["-c", config, "publish", "create"] + pyaptly.main(args) + state = pyaptly.SystemStateReader() + state.read() + assert set(["fakerepo02 main", "fakerepo01 main"]) == state.publishes + expect = { + "fakerepo02 main": set(["fakerepo02-20121006T0000Z"]), + "fakerepo01 main": set(["fakerepo01-20121010T0000Z"]), + } + assert expect == state.publish_map + + +@pytest.fixture() +def publish_create_rotating(config, snapshot_update_rotating, test_key_03): + """Test if creating publishes works.""" + args = ["-c", config, "publish", "create"] + pyaptly.main(args) + state = pyaptly.SystemStateReader() + state.read() + assert ( + set( + [ + "fakerepo01/current stable", + "fake/current stable", + "fakerepo02/current stable", + ] + ) + == state.publishes + ) + expect = { + "fake/current stable": set(["fake-current"]), + "fakerepo01/current stable": set(["fakerepo01-current"]), + "fakerepo02/current stable": set(["fakerepo02-current"]), + } + assert expect == state.publish_map + + +@pytest.fixture() +def publish_create_republish(config, publish_create, caplog): + """Test if creating republishes works.""" + found = False + for rec in caplog.records: + if rec.levelname == "CRITICAL": + if "has been deferred" in rec.msg: + found = True + assert found + args = [ + "-c", + config, + "publish", + "create", + ] + pyaptly.main(args) + state = pyaptly.SystemStateReader() + state.read() + assert "fakerepo01-stable main" in state.publishes diff --git a/pyaptly/test.py b/pyaptly/test.py index 7556c16..78f0ada 100644 --- a/pyaptly/test.py +++ b/pyaptly/test.py @@ -143,7 +143,7 @@ def clean_and_config(test_input, freeze="2012-10-10 10:10:10", sign=False): gnupg.chmod(0o700) environb[b"GNUPGHOME"] = str(gnupg).encode("UTF-8") - if sign: + if sign: # pragma: no cover setup = Path("/setup") subprocess.run(["gpg", "--import", setup / "test03.pub"], check=True) subprocess.run(["gpg", "--import", setup / "test03.key"], check=True) diff --git a/pyaptly/tests/publish-current.toml b/pyaptly/tests/publish-current.toml new file mode 100644 index 0000000..ef4aed0 --- /dev/null +++ b/pyaptly/tests/publish-current.toml @@ -0,0 +1,44 @@ +[mirror.fakerepo01] +max-tries = 2 +archive = "http://localhost:3123/fakerepo01" +gpg-keys = [ "2841988729C7F3FF",] +components = "main" +distribution = "main" + +[mirror.fakerepo02] +archive = "http://localhost:3123/fakerepo02" +gpg-keys = [ "2841988729C7F3FF",] +components = "main" +distribution = "main" + +[snapshot.fakerepo01-current] +mirror = "fakerepo01" + +[snapshot.fakerepo02-current] +mirror = "fakerepo02" + +[snapshot.fake-current] +merge = [ "fakerepo01-current", "fakerepo02-current",] + +[publish] +[[publish."fakerepo01/current"]] +distribution = "stable" +architectures = [ "amd64",] +components = [ "main",] +snapshots = [ "fakerepo01-current",] +automatic-update = true + +[[publish."fakerepo02/current"]] +distribution = "stable" +architectures = [ "amd64",] +components = [ "main",] +snapshots = [ "fakerepo02-current",] +automatic-update = true + +[[publish."fake/current"]] +distribution = "stable" +architectures = [ "amd64",] +components = [ "main",] +snapshots = [ "fake-current",] +automatic-update = true + diff --git a/pyaptly/tests/publish-publish.toml b/pyaptly/tests/publish-publish.toml new file mode 100644 index 0000000..ba84998 --- /dev/null +++ b/pyaptly/tests/publish-publish.toml @@ -0,0 +1,56 @@ +[mirror.fakerepo01] +max-tries = 2 +archive = "http://localhost:3123/fakerepo01" +gpg-keys = [ "2841988729C7F3FF",] +components = "main" +distribution = "main" + +[mirror.fakerepo02] +archive = "http://localhost:3123/fakerepo02" +gpg-keys = [ "2841988729C7F3FF",] +components = "main" +distribution = "main" + +[snapshot."fakerepo01-%T"] +mirror = "fakerepo01" + +[snapshot."fakerepo02-%T"] +mirror = "fakerepo02" + +[snapshot."fakerepo01-%T".timestamp] +time = "00:00" + +[snapshot."fakerepo02-%T".timestamp] +time = "00:00" +repeat-weekly = "sat" + +[publish] +[[publish.fakerepo01]] +gpg-key = "6D79A810B9B7ABAE" +skip-contents = true +automatic-update = true +components = "main" +distribution = "main" +[[publish.fakerepo01.snapshots]] +name = "fakerepo01-%T" +timestamp = "current" +archive-on-update = "archived-fakerepo01-%T" + + +[[publish.fakerepo02]] +gpg-key = "6D79A810B9B7ABAE" +automatic-update = true +components = "main" +distribution = "main" +[[publish.fakerepo02.snapshots]] +name = "fakerepo02-%T" +timestamp = "current" +archive-on-update = "archived-fakerepo02-%T" + +[[publish.fakerepo01-stable]] +publish = "fakerepo01 main" +gpg-key = "6D79A810B9B7ABAE" +automatic-update = true +components = "main" +distribution = "main" + diff --git a/pyaptly/tests/publish-repo.toml b/pyaptly/tests/publish-repo.toml new file mode 100644 index 0000000..9c7692b --- /dev/null +++ b/pyaptly/tests/publish-repo.toml @@ -0,0 +1,12 @@ +[repo.centrify] +architectures = [ "amd64", "i386",] +distribution = "stable" +component = "main" + +[publish] +[[publish.centrify]] +distribution = "latest" +repo = "centrify" +gpg-key = "6D79A810B9B7ABAE" +automatic-update = true +components = "main" diff --git a/pyaptly/tests/publish.toml b/pyaptly/tests/publish.toml new file mode 100644 index 0000000..d1871e4 --- /dev/null +++ b/pyaptly/tests/publish.toml @@ -0,0 +1,50 @@ +[mirror.fakerepo01] +max-tries = 2 +archive = "http://localhost:3123/fakerepo01" +gpg-keys = [ "2841988729C7F3FF",] +components = "main" +distribution = "main" + +[mirror.fakerepo02] +archive = "http://localhost:3123/fakerepo02" +gpg-keys = [ "2841988729C7F3FF",] +components = "main" +distribution = "main" + +[snapshot."fakerepo01-%T"] +mirror = "fakerepo01" + +[snapshot."fakerepo02-%T"] +mirror = "fakerepo02" + +[snapshot."fakerepo01-%T".timestamp] +time = "00:00" + +[snapshot."fakerepo02-%T".timestamp] +time = "00:00" +repeat-weekly = "sat" + +[publish] +[[publish.fakerepo01]] +gpg-key = "6D79A810B9B7ABAE" +skip-contents = true +automatic-update = true +components = "main" +distribution = "main" +[[publish.fakerepo01.snapshots]] +name = "fakerepo01-%T" +timestamp = "current" +archive-on-update = "archived-fakerepo01-%T" + + +[[publish.fakerepo02]] +gpg-key = "6D79A810B9B7ABAE" +automatic-update = true +components = "main" +distribution = "main" +[[publish.fakerepo02.snapshots]] +name = "fakerepo02-%T" +timestamp = "current" +archive-on-update = "archived-fakerepo02-%T" + + diff --git a/pyaptly/tests/test_publish.py b/pyaptly/tests/test_publish.py new file mode 100644 index 0000000..81d9f4a --- /dev/null +++ b/pyaptly/tests/test_publish.py @@ -0,0 +1,176 @@ +"""Test publish functionality.""" +import pytest + +import pyaptly + + +@pytest.mark.parametrize("repo", ["fakerepo01", "asdfasdf"]) +@pytest.mark.parametrize("config", ["publish.toml"], indirect=True) +def test_publish_create_single(config, snapshot_create, test_key_03, repo): + """Test if creating a single publish works.""" + args = ["-c", config, "publish", "create", repo] + if repo == "asdfasdf": + with pytest.raises(ValueError): + pyaptly.main(args) + return + pyaptly.main(args) + state = pyaptly.SystemStateReader() + state.read() + assert set(["fakerepo01 main"]) == state.publishes + expect = {"fakerepo01 main": set(["fakerepo01-20121010T0000Z"])} + assert expect == state.publish_map + + +@pytest.mark.parametrize("config", ["publish.toml"], indirect=True) +def test_publish_create_inexistent(config, snapshot_create, test_key_03): + """Test if creating inexistent publish raises an error.""" + args = ["-c", config, "publish", "create", "asdfasdf"] + error = False + try: + pyaptly.main(args) + except ValueError: + error = True + assert error + + +@pytest.mark.parametrize("config", ["publish-repo.toml"], indirect=True) +def test_repo_crate_basic(config, repo_create): + """Test if creating repositories works.""" + pass + + +@pytest.mark.parametrize("config", ["publish-repo.toml"], indirect=True) +def test_publish_create_repo(config, repo_create): + """Test if creating repo publishes works.""" + args = [ + "-c", + config, + "publish", + "create", + ] + pyaptly.main(args) + args = [ + "-c", + config, + "publish", + "update", + ] + pyaptly.main(args) + state = pyaptly.SystemStateReader() + state.read() + assert set(["centrify latest"]) == state.publishes + assert {"centrify latest": set([])} == state.publish_map + + +@pytest.mark.parametrize("config", ["publish.toml"], indirect=True) +def test_publish_create_basic(config, publish_create): + """Test if creating publishes works.""" + pass + + +@pytest.mark.parametrize("via", ["publish", "snapshot"]) +@pytest.mark.parametrize("config", ["publish-current.toml"], indirect=True) +def test_publish_update_rotating(config, freeze, publish_create_rotating, via): + """Test if update rotating publishes works.""" + freeze.move_to("2012-10-11 10:10:10") + args = ["-c", config, via, "update"] + pyaptly.main(args) + state = pyaptly.SystemStateReader() + state.read() + expect = { + "fake/current stable": set(["fake-current"]), + "fakerepo01/current stable": set(["fakerepo01-current"]), + "fakerepo02/current stable": set(["fakerepo02-current"]), + } + assert expect == state.publish_map + if via == "snapshot": + expect2 = { + "fakerepo02-current", + "fakerepo02-current-rotated-20121011T1010Z", + "fakerepo01-current", + "fake-current", + "fakerepo01-current-rotated-20121011T1010Z", + "fakerepo02-current-rotated-20121010T1010Z", + "fakerepo01-current-rotated-20121010T1010Z", + "fake-current-rotated-20121010T1010Z", + "fake-current-rotated-20121011T1010Z", + } + assert expect2 == state.snapshots + + +@pytest.mark.parametrize("config", ["publish-current.toml"], indirect=True) +def test_publish_create_rotating(config, publish_create_rotating): + """Test if creating rotating publishes works.""" + pass + + +@pytest.mark.parametrize("config", ["publish-publish.toml"], indirect=True) +def test_publish_create_republish(config, publish_create_republish): + """Test if creating republishes works.""" + pass + + +@pytest.mark.parametrize("config", ["publish-publish.toml"], indirect=True) +def test_publish_update_republish(config, publish_create_republish, freeze): + """Test if update republishes works.""" + freeze.move_to("2012-10-11 10:10:10") + args = ["-c", config, "snapshot", "create"] + pyaptly.main(args) + args = ["-c", config, "publish", "update"] + pyaptly.main(args) + state = pyaptly.SystemStateReader() + state.read() + assert "fakerepo01-stable main" in state.publishes + # As you see fakerepo01-stable main points to the old snapshot + # this is theoretically not correct, but it will be fixed with + # the next call to publish update. Since we use this from a hourly cron + # job it is no problem. + # This can't be easily fixed and would need a rewrite of the + # dependencies engine. + expect = { + "fakerepo01-stable main": set(["fakerepo01-20121010T0000Z"]), + "fakerepo02 main": set(["fakerepo02-20121006T0000Z"]), + "fakerepo01 main": set(["fakerepo01-20121011T0000Z"]), + } + assert expect == state.publish_map + + +@pytest.mark.parametrize("config", ["publish.toml"], indirect=True) +def test_publish_updating_basic(config, publish_create, freeze): + """Test if updating publishes works.""" + freeze.move_to("2012-10-11 10:10:10") + args = ["-c", config, "snapshot", "create"] + pyaptly.main(args) + args = ["-c", config, "publish", "update"] + pyaptly.main(args) + state = pyaptly.SystemStateReader() + state.read() + expect = set( + [ + "archived-fakerepo01-20121011T1010Z", + "fakerepo01-20121011T0000Z", + "fakerepo02-20121006T0000Z", + "fakerepo01-20121010T0000Z", + ] + ) + assert expect == state.snapshots + expect2 = { + "fakerepo02 main": set(["fakerepo02-20121006T0000Z"]), + "fakerepo01 main": set(["fakerepo01-20121011T0000Z"]), + } + assert expect2 == state.publish_map + + +@pytest.mark.parametrize("repo", ["centrify", "asdfasdf"]) +@pytest.mark.parametrize("config", ["repo.toml"], indirect=True) +def test_repo_create_single(config, repo, test_key_03): + """Test if updating publishes works.""" + args = ["-c", config, "repo", "create", repo] + if repo == "asdfasdf": + with pytest.raises(ValueError): + pyaptly.main(args) + return + pyaptly.main(args) + state = pyaptly.SystemStateReader() + state.read() + assert set(["centrify"]) == state.repos diff --git a/pyaptly/tests/test_util.py b/pyaptly/tests/test_util.py index bc68c8e..04f9042 100644 --- a/pyaptly/tests/test_util.py +++ b/pyaptly/tests/test_util.py @@ -3,7 +3,7 @@ import pytest -from .. import util +from .. import legacy, util EXPECT = """ stdout: 'first @@ -39,3 +39,19 @@ def test_run(test_path, debug_mode, caplog, decode, unicode_error): def test_freeze(freeze): """Test if setting freeze params works.""" assert str(datetime.now()) == "2014-10-10 10:10:10" + + +def test_snapshot_spec_as_dict(): + """Test various snapshot formats for snapshot_spec_to_name().""" + snap_string = "snapshot-foo" + snap_dict = {"name": "foo"} + + # TODO We cannot typecheck this as long as we do not typecheck legacy.py + cfg = { + "snapshot": { + "foo": {}, + } + } # type: ignore + + assert legacy.snapshot_spec_to_name(cfg, snap_string) == snap_string # type: ignore + assert legacy.snapshot_spec_to_name(cfg, snap_dict) == "foo" # type: ignore diff --git a/pyaptly/util.py b/pyaptly/util.py index 14bb1ff..32b65ca 100644 --- a/pyaptly/util.py +++ b/pyaptly/util.py @@ -2,6 +2,7 @@ import logging import subprocess +from pathlib import Path from subprocess import DEVNULL, PIPE # noqa: F401 from typing import Union @@ -25,7 +26,7 @@ def is_debug_mode(): return _DEBUG or _PYTEST_DEBUG -def run_command(cmd_args: list[str], *, decode: bool = True, **kwargs): +def run_command(cmd_args: list[Union[str, Path]], *, decode: bool = True, **kwargs): """Instrumented subprocess.run for easier debugging. By default this run command will add `encoding="UTF-8"` to kwargs. Disable