Skip to content

Commit

Permalink
Merge pull request #82 from adfinis/jlf/feat-update-logging-and-outpu…
Browse files Browse the repository at this point in the history
…t-functionality

feat: update logging and output functionality
  • Loading branch information
Jean-Louis Fuchs authored Mar 13, 2024
2 parents 88ba5a1 + b366bd6 commit 828bd66
Show file tree
Hide file tree
Showing 24 changed files with 347 additions and 496 deletions.
8 changes: 8 additions & 0 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Logging and output

We use the logging facility for both debugging and output to the user. If you
want to output a normal message (replacement of `print()`) use `lg.warn()`. The
name might feel counter-intuitive, but I don't want to hack the logging-system
and add new levels. `INFO` is basically reseved for successful commands.
Unsuccessful commands are logged on `ERROR`. You can also hide unsuccessful command
using `hide_error=True` in `run_command`.
31 changes: 12 additions & 19 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ wait-for-ready: up ## wait for web-server to be ready for testing

.PHONY: poetry-install
poetry-install: wait-for-ready ## install dev environment
@docker compose exec testing poetry install
@docker compose exec testing poetry install --without lsp

.PHONY: mypy
mypy: poetry-install
Expand All @@ -48,24 +48,17 @@ mypy: poetry-install
pytest: poetry-install ## run pytest
@docker compose exec testing poetry run pytest -vv --cov

.PHONY: check-isort
check-isort: poetry-install ## check isort
@docker compose exec testing poetry run isort --check pyaptly
.PHONY: format
format: poetry-install ## format code with ruff
@docker compose exec testing poetry run ruff format pyaptly

.PHONY: check-black
check-black: poetry-install ## check black
@docker compose exec testing poetry run black --check pyaptly

.PHONY: check-black
format-black: poetry-install ## format code with black
@docker compose exec testing poetry run black pyaptly

.PHONY: flake8
flake8: poetry-install ## run flake8
@docker compose exec testing poetry run flake8 pyaptly
.PHONY: fix
fix: poetry-install ## fix code with ruff
@docker compose exec testing poetry run ruff check --fix pyaptly

.PHONY: lint-code
lint-code: check-isort check-black flake8 ## check all linters
lint-code: ## check all linters
@docker compose exec testing poetry run ruff check pyaptly

.PHONY: test
test: pytest mypy lint-code ## run all testing
Expand All @@ -82,9 +75,9 @@ entr-pytest: poetry-install ## run pytest with entr
entr-mypy: poetry-install ## run pytest with entr
@docker compose exec testing bash -c "find -name '*.py' | SHELL=bash poetry run entr bash -c 'make local-mypy; echo ---'"

.PHONY: entr-flake8
entr-flake8: poetry-install ## run flake8 with entr
@docker compose exec testing bash -c "find -name '*.py' | SHELL=bash poetry run entr bash -c 'flake8 pyaptly; echo ---'"
.PHONY: entr-lint
entr-lint: poetry-install ## run ruff with entr
@docker compose exec testing bash -c "find -name '*.py' | SHELL=bash poetry run entr bash -c 'ruff check pyaptly; echo ---'"

.PHONY: local-mypy
local-mypy: ## Run mypy as daemon locally (requires local-dev)
Expand Down
68 changes: 67 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,75 @@
# Pyaptly

Automates the creation and managment of aptly mirrors and snapshots based on yml
Automates the creation and managment of aptly mirrors and snapshots based on toml
input files.

**Important**: Corrently under heavy development:

- For for the old version [switch to the master branch](https://github.com/adfinis/pyaptly/tree/master)
- Main branch builds contain [alpha packages](https://github.com/adfinis/pyaptly/actions/runs/8147002919), see Artifacts

## Example commands

Initialize a new aptly server.

```shell
pyaptly -c mirrors.toml mirror create
pyaptly -c mirrors.toml mirror update
pyaptly -c mirrors.toml snapshot create
pyaptly -c mirrors.toml publish create
```

Update mirrors and snapshots and switch publish endpoints with
```automatic-update: true``` to the new snapshots.

```shell
pyaptly -c mirrors.toml mirror update
pyaptly -c mirrors.toml snapshot create
pyaptly -c mirrors.toml publish create
pyaptly -c mirrors.toml publish update
```

Manually trigger a switch to the new snapshots for the publish endpoint
ubuntu/stable.

```shell
pyaptly -c mirrors.toml publish update ubuntu/stable
```

## Debugging

The most interesting mode for users is not `--debug` but `--info` which shows
all commands executed.

```bash
> pyaptly legacy -- --info --config pyaptly/tests/repo.toml repo create
Command call
cmd: gpg --no-default-keyring --keyring trustedkeys.gpg --list-keys --with-colons -> 0
stdout: 'tru::1:1709575833:0:3:1:5
pub:-:255:22:2841988729C7F3FF:1701882080:::-:::scESC:::::ed25519:::0:
fpr:::::::::6380C07FF6496016E01CF4522841988729C7F3FF:
uid:-::::1701882080::5BBE9C7E7AA5EEE3538F66274125D69FA727FD1E::Pyaptly Test 01 <[email protected]>::::::::::0:
sub:-:255:18:0A1CBEF26FE4F36E:1701882080::::::e:::::cv25519::
fpr:::::::::9EE64E40A5E3530D3E18A97C0A1CBEF26FE4F36E:
pub:-:255:22:EC54D33E5B5EBE98:1701882297:::-:::scESC:::::ed25519:::0:
fpr:::::::::660D45228AB6B59CCE48AFB3EC54D33E5B5EBE98:
uid:-::::1701882297::F3EF71B78669C0FC259A4078151BDC5815A6015D::Pyaptly Test 02 <[email protected]>::::::::::0:
sub:-:255:18:042FE0F5BB743B60:1701882297::::::e:::::cv25519::
fpr:::::::::AE58B62134E02AF8E5D55FF4042FE0F5BB743B60:'
Command call
cmd: aptly repo list -raw -> 0
stderr: 'Config file not found, creating default config at /root/.aptly.conf'
Command call
cmd: aptly mirror list -raw -> 0
Command call
cmd: aptly snapshot list -raw -> 0
Command call
cmd: aptly publish list -raw -> 0
Command call
cmd: aptly repo -architectures=amd64,i386 -distribution=stable -component=main create centrify -> 0
stdout: 'Local repo [centrify] successfully added.
You can run 'aptly repo add centrify ...' to add packages to repository.'
```

Commands that fail are always displayed in red on a tty, but that actually only
happens if something is broken.
112 changes: 0 additions & 112 deletions README.rst

This file was deleted.

Loading

0 comments on commit 828bd66

Please sign in to comment.