Skip to main content

Pure Python procps "watch" replacement

Project description

py-proc-watch

PyPI version Downloads Supported Python versions Poetry

Library and command line tool for watching process output. This is more or less a simpler version of watch from procps.

The main differences come from defaults:

  • py-proc-watch always trims long lines so they fit on the screen
  • py-proc-watch respects color ANSI escape sequences (but strips the rest)
  • Python or C for the implementation

Design goals

py-proc-watch library and tool should be:

  1. simple
  2. fast for very long output of executed command
  3. easily tested for correct behavior
  4. pure Python to maximize the amount of supported systems
  5. easy to use in other tools

Usage

pywatch command line tool supports only a few command line options to keep it simple:

usage: pywatch.py [-h] [-n INTERVAL] [-p] [-v] command [command ...]

positional arguments:
  command               command to watch, can be specified as a quoted string or as a list (use -- to separate pywatch and command options)

options:
  -h, --help            show this help message and exit
  -n INTERVAL, --interval INTERVAL
                        seconds to wait between command runs, positive floats and zero are accepted
  -p, --precise         try to run the command precisely at intervals
  -v, --debug           show debug information

py_proc_watch can be used also as a Python module to provide "watch-like" functionality easily. The library is quite simple, so just read the source and tests.

Development

py-proc-watch uses Python Poetry to manage dependencies, version 1.3.0 or later is required due to lock file format.

Used tools:

  • isort for keeping imports sane
  • black for enforcing a consistent code style
  • ruff for linting
  • mypy for type checking
  • pytest for running test
  • mockito for mocks in unit tests
  • poethepoet for easily running all of the above

The magic incantation:

poetry run poe check

will run all of the lint and test tools for you. During development running:

poetry run poe format

Will run isort and black to format the source code, ruff and mypy will be executed after code formatting to check for violations.

Contributing and reporting issues

Please use GitHub Issues and Pull requests. If you're contributing code please see Development section.

License

MIT, see LICENSE.md for full text. This is very permissive license, see following pages for more information:

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

py_proc_watch-0.2.3.tar.gz (8.3 kB view details)

Uploaded Source

Built Distribution

py_proc_watch-0.2.3-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

File details

Details for the file py_proc_watch-0.2.3.tar.gz.

File metadata

  • Download URL: py_proc_watch-0.2.3.tar.gz
  • Upload date:
  • Size: 8.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.7 Windows/11

File hashes

Hashes for py_proc_watch-0.2.3.tar.gz
Algorithm Hash digest
SHA256 6f7a3788fd2ebd285b8785a301ea62f1bb382cc6e3765083f84e5e4151ed2312
MD5 2823adc4e00c489f710458779ea03935
BLAKE2b-256 73ddc023e2f1500d0237ccc873b372b96ad836dd952daa3e0c12cdce5b9391df

See more details on using hashes here.

File details

Details for the file py_proc_watch-0.2.3-py3-none-any.whl.

File metadata

  • Download URL: py_proc_watch-0.2.3-py3-none-any.whl
  • Upload date:
  • Size: 6.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.7 Windows/11

File hashes

Hashes for py_proc_watch-0.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 cd687695614ca23fcc694a66615461682a6bf77db85c3683517b12ce1d29f14c
MD5 ed41ed92c47cb45e35865cc68558fc77
BLAKE2b-256 7ee1eb28db6706456a9c05cb2447c2234a7245df169bc74402b4263b59adb6c0

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page