Skip to main content

telefilebot

CI codecov Documentation Status PyPI PyPI - Downloads

alt text

Sometimes you have code that runs a long time and you do not want to continuously check if it has finished. If that code writes a file to the disk at the end, maybe you just want a text message when that file is created or modified?

telefilebot allows you to do this with as a simple background listener. All you need is an input YAML file and you can monitor multiple directories for various new files being created.

Installation

pip install telefilebot

Usage

Say you have two directories you want to monitor. In one of them you want to look for text files (files ending with a .txt extension) and the other you only want to scan the top two level directories.

First you need to create a telegram bot and attach it to some group where it can message you.

Now, create a YAML file that looks like this:

name: "file_monitor"
chat_id: "-XXXXXXXX"
token: "XXXXXXX"
logging:
  level: "INFO"
directories:
  "~/my_dir1":
    extensions:
      - .txt
  "~/my_dir2":
  recursion_limit: 0
wait_time: 1

What do these things mean?

  • The name just names the bot.
  • The chat_id and token are from the group and bot you created.
  • logging sets the verbosity of the printout in the terminal.
  • For each directory you want to monitor, create an entry with the directory path. If you want to monitor only certain file extensions, list them under the director. If you only want to recurse down to a certain level in the file structure, enter a recursion limit (here zero means only the path entered and no sub-folders will be scanned).
  • Finally, the wait_time argument specifies in minutes how long to wait between checks of the file system.

Now simply fire up a tmux session (or however you want to the bot to run in the background) and enter

telefilebot --file input.yml

and you are done! Your bot will let you know when new files are added or modified.

Metadata

Release files for telefilebot 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for telefilebot 0.2.0
File Size Uploaded
telefilebot-0.2.0.tar.gz 29.3 kB Details

Release files / telefilebot-0.2.0.tar.gz

Download URL telefilebot-0.2.0.tar.gz
Size 29.3 kB
Tags Source
SHA-256 checksum
How to use checksums
d3d04116e2f34b5e915780488af166716b8d8c258452234b330aa353412f508b
BLAKE2b-256 checksum
How to use checksums
4f60d69d3a7410ece437e4ac02ffccc2bd84476cc88e418ab55cc851a5ce9427
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

Release history Release notifications | RSS feed

This release

0.2.0 This release

1 release file

0.1.1

1 release file

0.0.2

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page