Telewrap CLI
Project description
Telewrap
Telewrap is a Python package for easily sending notifications and reports to your Telegram chat.
Getting started
Installation
To install Telewrap, run:
pip install telewrap
This will install two command line interfaces: tl and tlw.
Configuration
To configure Telewrap, run the following command and follow the instructions:
bash tl configure
By default, the configuration file is saved in the expanded local directory ~/.config under the name .telewrap.config. If you want to save it to a different directory, you can use the environment variable TELEWRAP_CONFIG_DIR. For example, the following command will save the configuration file under /tmp/.telewrap.config:
TELEWRAP_CONFIG_DIR=/tmp tl configure
Usage
Command line
To wrap a command line program until it finishes and get the result in your Telegram chat, run:
tlw my_program
If your command has any flags that are conflicting with tl you can use the following forms
tlw -- my_program --help # preferable as it allows for autocomplete
tlw "my_program --help"
In a Python script
It's possible to use telewrap to keep track of the progress when executing lengthy blocks of code. The following example works in Python scripts and Python notebooks.
from telewrap import Telewrap
with Telewrap():
while i < 10:
long_function()
i += 1
If you're using it in code you can even set the status_func and end_func to change the messages so that they fit your needs:
from telewrap import Telewrap, message_funcs
import time
i = 0
def status_func(x): return f"Current iteration {i}\n{message_funcs.default_status_func(x)}"
def end_func(x): return f"Tada!!"
with Telewrap(status_func=status_func, end_func=end_func):
while i < 10:
# A long function
time.sleep(1)
i += 1
Some Useful Examples
Telewrap is a useful tool for checking whether a website is ready for use. You can either write your own script that verifies the website's status or use the provided examples/is_website_ready.py script as a starting point. Once you have your script ready, simply execute the following command in your terminal:
tlw python is_website_ready.py https://google.com
This will provide you with a notification as soon as the website is available.x
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file telewrap-0.1.8.tar.gz.
File metadata
- Download URL: telewrap-0.1.8.tar.gz
- Upload date:
- Size: 7.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d998b134e67305cb2ac8792fba37588dc15c5360e1ade48f9463c56446eb1905
|
|
| MD5 |
805b6d2c013c4b3a02eb19765d9540d4
|
|
| BLAKE2b-256 |
c1433c6130b68aec95fb949e3695892298f6833556dd50616b47d70842bef5aa
|
File details
Details for the file telewrap-0.1.8-py3-none-any.whl.
File metadata
- Download URL: telewrap-0.1.8-py3-none-any.whl
- Upload date:
- Size: 8.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6a2bfb7bea125b4e2f8e3447977b170e9fd9929f6a4bda65dec26d6dbd3d315c
|
|
| MD5 |
4e879536154b18453d875f1278988681
|
|
| BLAKE2b-256 |
5f27e9a2d0d324fbb60dccda26d303a5267fcd48cd9b548f582956f0489c33e1
|