Telewrap CLI
Project description
Telewrap
Telewrap is a Python package that can make your life as a developer so much easier. With this tool, you don't have to constantly check your shell to see if your code has finished compiling or if your model has finished training. Telewrap sends notifications straight to your telegram, freeing you up to focus on other tasks or take a break, knowing that you'll be alerted as soon as the job is done.
Getting started
TLDR
For those of you that just want it to work:
pip install telewrap
tl configure # then follow the instructions
tlw sleep 5
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 printed instructions:
bash tl configure
By default, the configuration file is saved in the expanded path ~/.config/.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 valuable tool that for any task that requires waiting, one example is checking the availability of a website. All you need to do is write a script that checks whether a website is ready or you can use the one in examples/is_website_ready.py.
Then just run:
tlw python examples/is_website_ready.py https://google.com
This will provide you with a notification as soon as the website is available.
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.2.0.tar.gz.
File metadata
- Download URL: telewrap-0.2.0.tar.gz
- Upload date:
- Size: 7.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
848012ccb3e01e34091734bb90c44357506c6d7537470d671d6c4a7be9125273
|
|
| MD5 |
e28e10a6507f9bf08cd219e035628fc0
|
|
| BLAKE2b-256 |
c6090e380cfcbf5a0b7817b8f7d83106377ec6c0e5037e5f2a11653d6029edc7
|
File details
Details for the file telewrap-0.2.0-py3-none-any.whl.
File metadata
- Download URL: telewrap-0.2.0-py3-none-any.whl
- Upload date:
- Size: 9.0 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 |
d107b3b1730766cab4ec2cda01b1069df4cf5eb039017ec2e1a16f47528bdd75
|
|
| MD5 |
55985b808e5442e2880e2e4f0263e286
|
|
| BLAKE2b-256 |
cda1993b310f40a1166a3680c61188572f11deb79ba981a1ee2d47e2b3dc16d0
|