This package provides a simple interface to interact with If This Then That (https://ifttt.com/) webhook events.
This project was born from the need to receive push notifications on a smartphone after long running jobs had finished running, particularly using a free service such as IFTTT.
Copyright ® 2019, Ruben Branco <ruben.branco@outlook.pt>. All rights reserved.
Links: https://github.com/RubenBranco/pyifttt | https://pypi.org/project/pyifttt/
Installation
Install pyifttt using pip:
pip3 install pyifttt
Usage
There are three essential items to interact with a webhook:
Event Name: The event name for the webhook defined in the website.
Key: Your personal ifttt maker key.
Data: The values of each declared form variables.
General Usage
from pyifttt.webhook import send_notification
data = dict(value1="Testing this event")
key = "MySuperPrivateKey"
send_notification("test_event", data, key)
This will send a notification to an webhook whose event is named test_event with value1 variable as “Testing this event” and with a key.
Since including a private key in script files can be bothersome and repetitive, ifttt has three ways of key input:
Through the function as a key kwarg.
As a system env variable named IFTTT_KEY (export IFTTT_KEY="MySuperPrivateKey).
As a home file (~/.ifttt). The only contents this file should have is the key.
Job Completion Notification
pyifttt implements a general notification system for push notification of program exits.
In your IFTTT webhook you should include the following message:
The program {{Value1}}, running on host machine {{Value2}} , finished at {{OccurredAt}}. {{Value3}}
Here’s how you would use pyifttt to receive push notifications for when your long running program finishes using a context manager:
from pyifttt.webhook import SendCompletionNotification
with SendCompletionNotification('test_event'):
execute_long_job()
This will send a push notification to your smartphone or other device with the following structure:
The program long_job.py, running on host machine Server1, finished at November 22, 2019 at 09:30PM.
If it had found an exception, it would show the following message:
The program long_job.py, running on host machine Server1, finished at November 22, 2019 at 09:30PM. Got exception KeyboardInterrupt.
An optional argument to SendCompletionNotification is the IFTTT key, which as previously described, has several ways of input.
If you prefer to not use it as a context manager, you also use it in the following way:
from pyifttt.webhook import send_completion_notification
execute_long_job()
send_completion_notification('test_event')
License
Distributed under GPL-3.0 License. See the LICENSE file for details.
Metadata
Release files for pyifttt 0.1.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pyifttt-0.1.4.tar.gz | 3.6 kB | Details |
Release files / pyifttt-0.1.4.tar.gz
| Download URL | pyifttt-0.1.4.tar.gz |
|---|---|
| Size | 3.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f0f4154ffe5b9c096971c43342e9858f3ad0c4f434e75cc3466495fd591141e1
|
|
BLAKE2b-256 checksum How to use checksums |
3e98eac33c1f43e237a3aee45bbf530c497594537fbb153d37628c14dd126251
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.39.0 CPython/3.7.4
|