Pack and unpack Check_MK mkp files
Project description
python-mkp
Pack or unpack Check_MK mkp files.
The purpose of this library is to generate mkp files from source without having to set up a complete Check_MK instance. It is not intended for installing mkp files to a Check_MK site.
Installation
pip install mkp
Usage
Automatically pack mkp package
Run mkp-init in an empty directory.
This will create an executable script dist.py:
#!/usr/bin/env python
from mkp import dist
dist({
'author': 'John Doe',
'description': 'Test the automatic creation of packages',
'download_url': 'http://example.com/',
'name': 'test',
'title': 'Test',
'version': '1.0',
'version.min_required': '1.2.3',
})
and a directory structure similar to this:
├── agents/
├── agent_based/
├── checkman/
├── checks/
├── doc/
├── inventory/
├── lib/
├── notifications/
├── pnp-templates/
├── web/
└── dist.py
Now add your files to the respective directories and edit the metadata in
dist.py as needed. Empty directories can be deleted.
Running ./dist.py will pack all files in the directories listed above to a mkp package with the canonical name and the
specified metadata. The mkp file will be written to the dist directory.
Extract mkp package using mkp-extract cli tool
mkp-extract --help
mkp-extract foo-1.0.mkp
mkp-extract foo-1.0.mkp --output-dir bar --no-prefix
Advanced usage
Extract mkp package programmatically
import mkp
package = mkp.load_file('foo-1.0.mkp')
print(package.info)
package.extract_files('path/to/somewhere')
Pack files to mkp package
In contrast to dist, this provides the possibility to manually select the
files by replacing find_files. It is also possible to choose a different
output filename.
import mkp
info = {
'author': 'tom-mi',
'description': 'Test the system',
'download_url': 'http://example.com/',
'files': mkp.find_files('path/to/files'),
'name': 'test',
'title': 'Test',
'version': '1.0',
'version.min_required': '1.2.3',
}
mkp.pack_to_file(info, 'path/to/files', 'test-1.0.mkp')
Exclude files when packing using regular expressions:
from mkp import dist
dist({
# ...
}, exclude_patterns=[r'.*\.pyc$', '__pycache__'])
or
import mkp
files = mkp.find_files('path/to/files', exclude_patterns=[r'.*\.pyc$', '__pycache__'])
Include all subdirectories instead of just the "known" ones:
from mkp import dist, INCLUDE_ALL
dist({
# ...
}, directories=INCLUDE_ALL)
or
import mkp
files = mkp.find_files('path/to/files', directories=mkp.INCLUDE_ALL)
Include only specific subdirectories:
from mkp import dist
dist({
# ...
}, directories=['checks', 'agents'])
or
import mkp
files = mkp.find_files('path/to/files', directories=['checks', 'agents'])
Development Setup
Install development dependencies into local environment (${repo_root}/.venv):
scripts/bootstrap
Run all tests with tox:
scripts/test
# or
source .venv/bin/activate
tox
Run tests of current python version with pytest:
source .venv/bin/activate
pytest
Release new version:
git tag <new_version>
git push --tags
License
This software is licensed under GPLv2.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mkp-0.7-py2.py3-none-any.whl.
File metadata
- Download URL: mkp-0.7-py2.py3-none-any.whl
- Upload date:
- Size: 14.4 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b59ba8bdfde3bd726549ed54187a2020420bfa80715c52b4b17a490991661fda
|
|
| MD5 |
f1cc6e047b23519c21b20aa651eb625d
|
|
| BLAKE2b-256 |
087bfc54d9782c32e4e951a2e2e2e692b042e0f45aea700a80af0265412d3f68
|
Provenance
The following attestation bundles were made for mkp-0.7-py2.py3-none-any.whl:
Publisher:
release.yml on tom-mi/python-mkp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mkp-0.7-py2.py3-none-any.whl -
Subject digest:
b59ba8bdfde3bd726549ed54187a2020420bfa80715c52b4b17a490991661fda - Sigstore transparency entry: 741929836
- Sigstore integration time:
-
Permalink:
tom-mi/python-mkp@4c0d64ce1eeee9874695c4e8cbf3d7f0973959f6 -
Branch / Tag:
refs/tags/0.7 - Owner: https://github.com/tom-mi
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@4c0d64ce1eeee9874695c4e8cbf3d7f0973959f6 -
Trigger Event:
push
-
Statement type: