Metadata-Version: 2.1
Name: command-watcher
Version: 0.1.0
Summary: Module to watch the execution of shell scripts. Both streams (`stdout` and `stderr`) are captured.
Home-page: https://github.com/Josef-Friedrich/command-watcher
License: MIT
Author: Josef Friedrich
Author-email: josef@friedrich.rocks
Requires-Python: >=3.8,<4.0
Classifier: Development Status :: 5 - Production/Stable
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Requires-Dist: conf2levels (>=0.4.0,<0.5.0)
Requires-Dist: jflib (>=1.0.0,<2.0.0)
Requires-Dist: requests (>=2.28.1,<3.0.0)
Requires-Dist: termcolor (>=1.1.0,<2.0.0)
Requires-Dist: types-requests (>=2.28.1,<3.0.0)
Requires-Dist: types-termcolor (>=1.1.5,<2.0.0)
Project-URL: Repository, https://github.com/Josef-Friedrich/command-watcher
Description-Content-Type: text/x-rst

command_watcher
===============

Module to watch the execution of shell scripts. Both streams (`stdout`
and `stderr`) are captured.

.. code:: python

    watch = Watch()
    watch.log.critical('msg')
    watch.log.error('msg')
    watch.log.warning('msg')
    watch.log.info('msg')
    watch.log.debug('msg')
    watch.run(['rsync', '-av', '/home', '/backup'])

.. code-block:: python

    from command_watcher import Watch
    watch = Watch(
        config_file='/etc/command-watcher.ini',
        service_name='texlive_update'
    )

    tlmgr = '/usr/local/texlive/bin/x86_64-linux/tlmgr'

    watch.run('{} update --self'.format(tlmgr))
    watch.run('{} update --all'.format(tlmgr))
    installed_packages = watch.run(
        '{} info --only-installed'.format(tlmgr), log=False
    )
    all_packages = watch.run('{} info'.format(tlmgr), log=False)

    watch.final_report(
        status=0,
        performance_data={
            'installed_packages': installed_packages.line_count_stdout,
            'all_packages': all_packages.line_count_stdout,
        },
    )

.. code-block:: ini

    [email]
    subject_prefix = [cwatcher]
    from_addr =
    to_addr = logs@example.com
    to_addr_critical = critical@example.com
    smtp_login = mailer
    smtp_password = 1234
    smtp_server = mail.example.com:587

    [nsca]
    remote_host = 1.2.3.4
    password = asdf1234
    encryption_method = 8
    ; port = 5667

    [icinga]
    url = https://icinga.example.com:5665
    user = user
    password = 1234

    [beep]
    activated = True

