Skip to main content

SSH, Proc, Multiproc, tail.py, log.py, stream.py, daemonize.py, etc.

Project description

reversefold.util

Available on pypi

This is a collection of various command-line scripts and libraries which have come in useful over the years I've worked with Python.

log.py

Captures stdout of a process and enables transformation the output (such as adding a timestamp to each line) and is compatible with external logrotate through WatchedFileHandler.

daemonize.py

Useful for daemonizing another process which either does not daemonize itself or for which you want to capture stdout and stderr to log files. Uses WatchedFileHandler for output to log files to allow for external log rotation.

stream.py

Similar to tail -f but with some more options for type of buffering and supports streaming the entire current contents of the file before then following the tail of the file.

reversefold.util

rate_limit_gen

A generator wrapper which rate-limits another generator. If the rate is exceeded, further values received within the period are discarded. Useful, for example, for making sure that the number of lines you display from a log file you're following don't cause your terminal to block while displaying a huge amount of output.

chunked

Breaks up an iterable into equal-sized chunks.

reversefold.util.ssh

SSHHost

A programmatic interface to ssh. Allows easily running a single command or a shell script or interactively sending input and displaying output. Originally written as a drop-in monkeypatch for fabric's use of paramiko.

reversefold.util.multiproc

run_subproc

Takes a subprocess as input and sets up threads for handling and displaying stdout and stderr from the process. Defaults to blocking until the process is finished but also supports immediately returning and including the threads in the return value. Also defaults to capturing the stdout and stderr and returning them as lists of lines.

reversefold.util.proc

Provides context managers to ensure that a process is sent a TERM or KILL signal (or both) to a process when the context block exits. Can optionally find child processes recursively and send the same signal(s) to them. Also provides functions for the same functionality.

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

reversefold.util-3.5.5.tar.gz (15.9 kB view details)

Uploaded Source

Built Distribution

reversefold.util-3.5.5-py3-none-any.whl (20.0 kB view details)

Uploaded Python 3

File details

Details for the file reversefold.util-3.5.5.tar.gz.

File metadata

  • Download URL: reversefold.util-3.5.5.tar.gz
  • Upload date:
  • Size: 15.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.9.1

File hashes

Hashes for reversefold.util-3.5.5.tar.gz
Algorithm Hash digest
SHA256 4e6f202dce8b5870493b13c85264ced78a4eeb7bdd1d9d115aa5145ecad1daf1
MD5 6aad92eb8526965dbcb2f5b3721eab66
BLAKE2b-256 8336337d67fac3f6c8e53ce19595f1eae4e3a48b4cb0a59806b3f331768a5928

See more details on using hashes here.

File details

Details for the file reversefold.util-3.5.5-py3-none-any.whl.

File metadata

  • Download URL: reversefold.util-3.5.5-py3-none-any.whl
  • Upload date:
  • Size: 20.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.9.1

File hashes

Hashes for reversefold.util-3.5.5-py3-none-any.whl
Algorithm Hash digest
SHA256 05f67816489a03e22c3052dd597055679c1a9a85a99c31ae7c7ee6b277dd6bc4
MD5 4116f8688e69d49daf56c0962ca2f2df
BLAKE2b-256 1dd2f76e1554bc233300bb63512500d75b008f34eac747bcd39ed3c1aa1032fa

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