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.0.tar.gz (16.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

reversefold.util-3.5.0-py3-none-any.whl (19.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: reversefold.util-3.5.0.tar.gz
  • Upload date:
  • Size: 16.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/0.12.17 CPython/3.5.2 Darwin/18.7.0

File hashes

Hashes for reversefold.util-3.5.0.tar.gz
Algorithm Hash digest
SHA256 3d32dcb49bc6bb997f3d6bb1b315d90872711fb7f5eb2d667fade04acb1e8fc0
MD5 37fc2ec87c23b249f3dc3787f1f68357
BLAKE2b-256 df0c77873ecce0cba2043fe68da1d22eadf9c239cd1dd6d661e3fa65483eb088

See more details on using hashes here.

File details

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

File metadata

  • Download URL: reversefold.util-3.5.0-py3-none-any.whl
  • Upload date:
  • Size: 19.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/0.12.17 CPython/3.5.2 Darwin/18.7.0

File hashes

Hashes for reversefold.util-3.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fa235f5878ca1cb630c8e500640f9449bcc7fb5b431cb3b50f16a2b19df89c45
MD5 6141f6af9a2f1d7185315e80c2a9d4f1
BLAKE2b-256 07483699858f0acc54f219e6e0da0c02374c29c33dfe85d13cc4a72e4974975a

See more details on using hashes here.

Supported by

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