Ponytail
Overview
Python "tail -F" like functionality, targeted for processing log data, with a goal of being reliable and robust.
Create an object to follow a file.
Features: - Detects if file is truncated and starts over at the beginning. - Detects file rename and new file created (for log rotation). - Continues reading old file after rotation to catch stragglers written there. - Can write an optional "offset" file so it can pick up from where it left off.
Arguments:
Follow(filename, offset_filename=None, watch_rotated_file_seconds=300):
- filename: Filename to open and read data from.
- offset_filename: If given, a file name to write offset information to. This file is written either whenever the end of file is reached during reading, or when the "save_offset()" method is called. If you break out of the read loop (say because of Control-C), it is best to save the offset.
- watch_rotated_file_seconds: After detecting the file has been rotated, watch the old file for this many seconds to see if new data has been written to it after the rotation.
Follow().readline(none_on_no_data):
- none_on_no_data: If true, instead of sleeping and continuing, it will return None if data is not ready.
Follow().save_offset()
- No arguments
Example
f = ponytail.Follow('/var/log/syslog')
for line in f.readlines():
print(line.rstrip())
More exhaustive example:
f = ponytail.Follow('/var/log/syslog', offset_filename='/tmp/syslog.offset', watch_rotated_file_seconds=10)
for line in f.readlines():
print(line.rstrip())
The above will save the processed offset to a file, and later processing will pick up where the previous run left off. It will also stop watching the old file after a rotation, after 10 seconds (default is 300).
Metadata
Release files for ponytail 0.9.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| ponytail-0.9.3.tar.gz | 8.2 kB | Without provenance | Details for ponytail-0.9.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ponytail-0.9.3-py3-none-any.whl | Python 3 | none | any | Details for ponytail-0.9.3-py3-none-any.whl |
Total release size: 16.5 kB
Release files / ponytail-0.9.3.tar.gz
| Download URL | ponytail-0.9.3.tar.gz |
|---|---|
| Size | 8.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ef076ae04636289f3b1ec90e471b361fbf863e731644695dd691a4de392a15a0
|
|
BLAKE2b-256 checksum How to use checksums |
b42a900b9bd4226cda378e0eac8a48823bf779496b9e6801d8c6e89eefe013c2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / ponytail-0.9.3-py3-none-any.whl
| Download URL | ponytail-0.9.3-py3-none-any.whl |
|---|---|
| Size | 8.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bc3bd3fa450f531899f21f5d28d50657fce3384cb33b4137fde5d9e307a1d715
|
|
BLAKE2b-256 checksum How to use checksums |
89a3836d498eb3500ee36781764d4a4bffec781c84d04773b4f4fb3fbae94a9f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Security for ponytail 0.9.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.