command_watcher 0.5.0__tar.gz → 0.7.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- command_watcher-0.7.0/PKG-INFO +106 -0
- command_watcher-0.7.0/README.rst +81 -0
- command_watcher-0.7.0/pyproject.toml +51 -0
- command_watcher-0.7.0/pyproject.toml.orig +50 -0
- {command_watcher-0.5.0 → command_watcher-0.7.0/src}/command_watcher/__init__.py +99 -177
- command_watcher-0.7.0/src/command_watcher/channels/base_channel.py +11 -0
- command_watcher-0.7.0/src/command_watcher/channels/beep.py +48 -0
- command_watcher-0.7.0/src/command_watcher/channels/email.py +67 -0
- command_watcher-0.7.0/src/command_watcher/channels/icinga.py +70 -0
- command_watcher-0.7.0/src/command_watcher/config.py +57 -0
- {command_watcher-0.5.0 → command_watcher-0.7.0/src}/command_watcher/log.py +11 -13
- command_watcher-0.7.0/src/command_watcher/message.py +200 -0
- command_watcher-0.7.0/src/command_watcher/report.py +27 -0
- {command_watcher-0.5.0 → command_watcher-0.7.0/src}/command_watcher/utils.py +5 -0
- command_watcher-0.5.0/LICENSE +0 -22
- command_watcher-0.5.0/PKG-INFO +0 -98
- command_watcher-0.5.0/README.rst +0 -73
- command_watcher-0.5.0/command_watcher/email.py +0 -42
- command_watcher-0.5.0/command_watcher/report.py +0 -353
- command_watcher-0.5.0/pyproject.toml +0 -34
- {command_watcher-0.5.0 → command_watcher-0.7.0/src}/command_watcher/py.typed +0 -0
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: command_watcher
|
|
3
|
+
Version: 0.7.0
|
|
4
|
+
Summary: Module to watch the execution of shell scripts. Both streams (`stdout` and `stderr`) are captured.
|
|
5
|
+
Author: Josef Friedrich
|
|
6
|
+
Author-email: Josef Friedrich <josef@friedrich.rocks>
|
|
7
|
+
License-Expression: MIT
|
|
8
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
15
|
+
Requires-Dist: pretiac>=0.6.0
|
|
16
|
+
Requires-Dist: pydantic>=2.12.5
|
|
17
|
+
Requires-Dist: pyyaml>=6.0.3
|
|
18
|
+
Requires-Dist: termcolor>=3.3.0
|
|
19
|
+
Requires-Dist: types-pyyaml>=6.0.12.20250915
|
|
20
|
+
Requires-Dist: types-requests>=2.32.4.20260107
|
|
21
|
+
Requires-Dist: types-termcolor>=1.1.6.2
|
|
22
|
+
Requires-Python: >=3.12, <4
|
|
23
|
+
Project-URL: Repository, https://github.com/Josef-Friedrich/command-watcher
|
|
24
|
+
Description-Content-Type: text/x-rst
|
|
25
|
+
|
|
26
|
+
.. image:: http://img.shields.io/pypi/v/command-watcher.svg
|
|
27
|
+
:target: https://pypi.org/project/command-watcher
|
|
28
|
+
:alt: This package on the Python Package Index
|
|
29
|
+
|
|
30
|
+
.. image:: https://github.com/Josef-Friedrich/command-watcher/actions/workflows/tests.yml/badge.svg
|
|
31
|
+
:target: https://github.com/Josef-Friedrich/command-watcher/actions/workflows/tests.yml
|
|
32
|
+
:alt: Tests
|
|
33
|
+
|
|
34
|
+
command_watcher
|
|
35
|
+
===============
|
|
36
|
+
|
|
37
|
+
Module to watch the execution of shell scripts. Both streams (`stdout`
|
|
38
|
+
and `stderr`) are captured.
|
|
39
|
+
|
|
40
|
+
The watcher's loggers print each message once and do not propagate it to
|
|
41
|
+
Python's root logger. Command output is also stored on the command executor
|
|
42
|
+
and, unless ``log=False`` is passed to ``watch.run()``, on the watcher.
|
|
43
|
+
|
|
44
|
+
.. code:: python
|
|
45
|
+
|
|
46
|
+
watch = Watch()
|
|
47
|
+
watch.log.critical('msg')
|
|
48
|
+
watch.log.error('msg')
|
|
49
|
+
watch.log.warning('msg')
|
|
50
|
+
watch.log.info('msg')
|
|
51
|
+
watch.log.debug('msg')
|
|
52
|
+
watch.run(['rsync', '-av', '/home', '/backup'])
|
|
53
|
+
|
|
54
|
+
.. code-block:: python
|
|
55
|
+
|
|
56
|
+
#! /opt/venvs/command_watcher/bin/python
|
|
57
|
+
|
|
58
|
+
from command_watcher import Watch
|
|
59
|
+
watch = Watch(
|
|
60
|
+
config_file='/etc/command-watcher.yml',
|
|
61
|
+
service_name='texlive_update'
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
tlmgr = '/usr/local/texlive/bin/x86_64-linux/tlmgr'
|
|
65
|
+
|
|
66
|
+
watch.run(f'{tlmgr} update --self')
|
|
67
|
+
watch.run(f'{tlmgr} update --all')
|
|
68
|
+
installed_packages = watch.run(
|
|
69
|
+
f'{tlmgr} info --only-installed', log=False
|
|
70
|
+
)
|
|
71
|
+
all_packages = watch.run(f'{tlmgr} info', log=False)
|
|
72
|
+
|
|
73
|
+
watch.final_report(
|
|
74
|
+
status=0,
|
|
75
|
+
performance_data={
|
|
76
|
+
'installed_packages': installed_packages.line_count_stdout,
|
|
77
|
+
'all_packages': all_packages.line_count_stdout,
|
|
78
|
+
},
|
|
79
|
+
)
|
|
80
|
+
|
|
81
|
+
.. code-block:: yaml
|
|
82
|
+
|
|
83
|
+
---
|
|
84
|
+
email:
|
|
85
|
+
from_addr: logs@example.com
|
|
86
|
+
to_addr: logs@example.com
|
|
87
|
+
to_addr_critical: critical@example.com
|
|
88
|
+
smtp_login: mailer@mail.example.com
|
|
89
|
+
smtp_password: abcd
|
|
90
|
+
smtp_server: mail.example.com:587
|
|
91
|
+
|
|
92
|
+
icinga:
|
|
93
|
+
api_endpoint_host: localhost
|
|
94
|
+
api_endpoint_port: 5665
|
|
95
|
+
client_private_key: /etc/pretiac/api-client.key.pem
|
|
96
|
+
client_certificate: /etc/pretiac/api-client.cert.pem
|
|
97
|
+
ca_certificate: /etc/pretiac/ca.crt
|
|
98
|
+
new_host_defaults:
|
|
99
|
+
templates: [passive-host]
|
|
100
|
+
new_service_defaults:
|
|
101
|
+
templates: [passive-service]
|
|
102
|
+
attrs:
|
|
103
|
+
check_interval: monthly
|
|
104
|
+
|
|
105
|
+
beep:
|
|
106
|
+
activated: true
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
.. image:: http://img.shields.io/pypi/v/command-watcher.svg
|
|
2
|
+
:target: https://pypi.org/project/command-watcher
|
|
3
|
+
:alt: This package on the Python Package Index
|
|
4
|
+
|
|
5
|
+
.. image:: https://github.com/Josef-Friedrich/command-watcher/actions/workflows/tests.yml/badge.svg
|
|
6
|
+
:target: https://github.com/Josef-Friedrich/command-watcher/actions/workflows/tests.yml
|
|
7
|
+
:alt: Tests
|
|
8
|
+
|
|
9
|
+
command_watcher
|
|
10
|
+
===============
|
|
11
|
+
|
|
12
|
+
Module to watch the execution of shell scripts. Both streams (`stdout`
|
|
13
|
+
and `stderr`) are captured.
|
|
14
|
+
|
|
15
|
+
The watcher's loggers print each message once and do not propagate it to
|
|
16
|
+
Python's root logger. Command output is also stored on the command executor
|
|
17
|
+
and, unless ``log=False`` is passed to ``watch.run()``, on the watcher.
|
|
18
|
+
|
|
19
|
+
.. code:: python
|
|
20
|
+
|
|
21
|
+
watch = Watch()
|
|
22
|
+
watch.log.critical('msg')
|
|
23
|
+
watch.log.error('msg')
|
|
24
|
+
watch.log.warning('msg')
|
|
25
|
+
watch.log.info('msg')
|
|
26
|
+
watch.log.debug('msg')
|
|
27
|
+
watch.run(['rsync', '-av', '/home', '/backup'])
|
|
28
|
+
|
|
29
|
+
.. code-block:: python
|
|
30
|
+
|
|
31
|
+
#! /opt/venvs/command_watcher/bin/python
|
|
32
|
+
|
|
33
|
+
from command_watcher import Watch
|
|
34
|
+
watch = Watch(
|
|
35
|
+
config_file='/etc/command-watcher.yml',
|
|
36
|
+
service_name='texlive_update'
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
tlmgr = '/usr/local/texlive/bin/x86_64-linux/tlmgr'
|
|
40
|
+
|
|
41
|
+
watch.run(f'{tlmgr} update --self')
|
|
42
|
+
watch.run(f'{tlmgr} update --all')
|
|
43
|
+
installed_packages = watch.run(
|
|
44
|
+
f'{tlmgr} info --only-installed', log=False
|
|
45
|
+
)
|
|
46
|
+
all_packages = watch.run(f'{tlmgr} info', log=False)
|
|
47
|
+
|
|
48
|
+
watch.final_report(
|
|
49
|
+
status=0,
|
|
50
|
+
performance_data={
|
|
51
|
+
'installed_packages': installed_packages.line_count_stdout,
|
|
52
|
+
'all_packages': all_packages.line_count_stdout,
|
|
53
|
+
},
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
.. code-block:: yaml
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
email:
|
|
60
|
+
from_addr: logs@example.com
|
|
61
|
+
to_addr: logs@example.com
|
|
62
|
+
to_addr_critical: critical@example.com
|
|
63
|
+
smtp_login: mailer@mail.example.com
|
|
64
|
+
smtp_password: abcd
|
|
65
|
+
smtp_server: mail.example.com:587
|
|
66
|
+
|
|
67
|
+
icinga:
|
|
68
|
+
api_endpoint_host: localhost
|
|
69
|
+
api_endpoint_port: 5665
|
|
70
|
+
client_private_key: /etc/pretiac/api-client.key.pem
|
|
71
|
+
client_certificate: /etc/pretiac/api-client.cert.pem
|
|
72
|
+
ca_certificate: /etc/pretiac/ca.crt
|
|
73
|
+
new_host_defaults:
|
|
74
|
+
templates: [passive-host]
|
|
75
|
+
new_service_defaults:
|
|
76
|
+
templates: [passive-service]
|
|
77
|
+
attrs:
|
|
78
|
+
check_interval: monthly
|
|
79
|
+
|
|
80
|
+
beep:
|
|
81
|
+
activated: true
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "command_watcher"
|
|
3
|
+
version = "0.7.0"
|
|
4
|
+
description = "Module to watch the execution of shell scripts. Both streams (`stdout` and `stderr`) are captured."
|
|
5
|
+
requires-python = ">=3.12,<4"
|
|
6
|
+
readme = "README.rst"
|
|
7
|
+
license = "MIT"
|
|
8
|
+
classifiers = [
|
|
9
|
+
"Development Status :: 5 - Production/Stable",
|
|
10
|
+
"License :: OSI Approved :: MIT License",
|
|
11
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
12
|
+
"Programming Language :: Python :: 3",
|
|
13
|
+
"Programming Language :: Python :: 3.12",
|
|
14
|
+
"Programming Language :: Python :: 3.13",
|
|
15
|
+
"Programming Language :: Python :: 3.14",
|
|
16
|
+
]
|
|
17
|
+
dependencies = [
|
|
18
|
+
"pretiac>=0.6.0",
|
|
19
|
+
"pydantic>=2.12.5",
|
|
20
|
+
"pyyaml>=6.0.3",
|
|
21
|
+
"termcolor>=3.3.0",
|
|
22
|
+
"types-pyyaml>=6.0.12.20250915",
|
|
23
|
+
"types-requests>=2.32.4.20260107",
|
|
24
|
+
"types-termcolor>=1.1.6.2",
|
|
25
|
+
]
|
|
26
|
+
|
|
27
|
+
[[project.authors]]
|
|
28
|
+
name = "Josef Friedrich"
|
|
29
|
+
email = "josef@friedrich.rocks"
|
|
30
|
+
|
|
31
|
+
[project.urls]
|
|
32
|
+
Repository = "https://github.com/Josef-Friedrich/command-watcher"
|
|
33
|
+
|
|
34
|
+
[dependency-groups]
|
|
35
|
+
dev = [
|
|
36
|
+
"mypy>=1.0",
|
|
37
|
+
"pytest>=9.0.2",
|
|
38
|
+
"stdout-stderr-capturing>=0.2.1",
|
|
39
|
+
]
|
|
40
|
+
|
|
41
|
+
[tool.uv.sources.pretiac]
|
|
42
|
+
git = "https://github.com/Josef-Friedrich/PREtty-Typed-Icinga2-Api-Client_py.git"
|
|
43
|
+
|
|
44
|
+
[tool.pytest.ini_options]
|
|
45
|
+
verbosity_assertions = 2
|
|
46
|
+
truncation_limit_lines = 999999
|
|
47
|
+
truncation_limit_chars = 999999
|
|
48
|
+
|
|
49
|
+
[build-system]
|
|
50
|
+
requires = ["uv_build>=0.13.7,<0.14.0"]
|
|
51
|
+
build-backend = "uv_build"
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "command_watcher"
|
|
3
|
+
version = "0.7.0"
|
|
4
|
+
description = "Module to watch the execution of shell scripts. Both streams (`stdout` and `stderr`) are captured."
|
|
5
|
+
authors = [{ name = "Josef Friedrich", email = "josef@friedrich.rocks" }]
|
|
6
|
+
requires-python = ">=3.12,<4"
|
|
7
|
+
readme = "README.rst"
|
|
8
|
+
license = "MIT"
|
|
9
|
+
classifiers = [
|
|
10
|
+
"Development Status :: 5 - Production/Stable",
|
|
11
|
+
"License :: OSI Approved :: MIT License",
|
|
12
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
13
|
+
"Programming Language :: Python :: 3",
|
|
14
|
+
"Programming Language :: Python :: 3.12",
|
|
15
|
+
"Programming Language :: Python :: 3.13",
|
|
16
|
+
"Programming Language :: Python :: 3.14",
|
|
17
|
+
]
|
|
18
|
+
dependencies = [
|
|
19
|
+
"pretiac>=0.6.0",
|
|
20
|
+
"pydantic>=2.12.5",
|
|
21
|
+
"pyyaml>=6.0.3",
|
|
22
|
+
"termcolor>=3.3.0",
|
|
23
|
+
"types-pyyaml>=6.0.12.20250915",
|
|
24
|
+
"types-requests>=2.32.4.20260107",
|
|
25
|
+
"types-termcolor>=1.1.6.2",
|
|
26
|
+
]
|
|
27
|
+
|
|
28
|
+
[project.urls]
|
|
29
|
+
Repository = "https://github.com/Josef-Friedrich/command-watcher"
|
|
30
|
+
|
|
31
|
+
[dependency-groups]
|
|
32
|
+
dev = [
|
|
33
|
+
"mypy>=1.0",
|
|
34
|
+
"pytest>=9.0.2",
|
|
35
|
+
"stdout-stderr-capturing>=0.2.1",
|
|
36
|
+
]
|
|
37
|
+
|
|
38
|
+
[tool.uv]
|
|
39
|
+
|
|
40
|
+
[tool.uv.sources]
|
|
41
|
+
pretiac = { git = "https://github.com/Josef-Friedrich/PREtty-Typed-Icinga2-Api-Client_py.git" }
|
|
42
|
+
|
|
43
|
+
[build-system]
|
|
44
|
+
requires = ["uv_build>=0.13.7,<0.14.0"]
|
|
45
|
+
build-backend = "uv_build"
|
|
46
|
+
|
|
47
|
+
[tool.pytest.ini_options]
|
|
48
|
+
verbosity_assertions = 2
|
|
49
|
+
truncation_limit_lines = 999999
|
|
50
|
+
truncation_limit_chars = 999999
|