notice by sound or email
Project description
Introduction
README: English|中文
pynotice is a python3 module that can play a sound or send an email to inform you when your function finishes or goes wrong.
Features
- Use default or custom wav file
- Send email with an attachment of pictures or txt files
- python decorator
- No need specifying smtp server address, of course you can do it
Installation
only for python3
pip install pynotice
Usage
-Sound- [duplicated]
inform you by playing sound when your function finishes
from pynotice.sound.notice import noticeOnFinish
@noticeOnFinish()
def foo(name="foooo"): # your function
return name
ret = foo()
print(ret)
inform you by playing sound when your function goes wrong
from pynotice.sound.notice import noticeOnException, noticeOnFinish
@noticeOnFinish()
@noticeOnException()
def foo(name="aaa"):
return name
-Email-
Firstly, please confirm you have opened SMTP functions in your email. And the method depends on your email server (For @163.com and @gmail.com you need to set your app private password) gmail SMTP authorization | qq email SMTP authorization
inform you of your function result by sending an email when your function finishes
from pynotice.mail import noticeOnFinish
import numpy as np
sender = "xxx@gmail.com"
code = "xxxxxxxxxxxxxxxx" # SMTP authorization code
receiver = "xxx@foxmail.com" # list or str
# you can also send an attachments
@noticeOnFinish(sender, code, receiver, attachments=['demo.txt'])
def foo(name="aaa"):
x = np.array([[1, 2, 3], [2, 3, 4]])
for i in range(100):
if i%20==0:
print(i)
np.savetxt("demo.txt", x)
return x, [1,23,5,4], name
ret = foo()
print(ret)
inform you of the Exception by an email when the function throws exceptions
from pynotice.mail import noticeOnException, noticeOnFinish
sender = "xxx@qq.com"
code = "xxxxxxxxxxxxxxxx" # SMTP authorization code
receiver = "xxx@foxmail.com" # list or str
@noticeOnFinish(sender, code, receiver,attachments=[])
@noticeOnException(sender, code, receiver)
def foo(name="aaa"):
return "ccc"
re = foo()
Include
| module | description |
|---|---|
| filetype | get the file format |
| simpleaudio | play the wav audio |
| zmail | send emails simply |
Resource
Two wav sounds in module are downloaded from here. I have thought I can diy with my ipad, but I'm a green hand in that so ...
Project details
Release history Release notifications | RSS feed
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 pynotice-0.0.2.tar.gz.
File metadata
- Download URL: pynotice-0.0.2.tar.gz
- Upload date:
- Size: 4.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.33.0 CPython/3.6.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a78cad5528683b88d6be3ba0b4bcd0fd2a0af2946a06ee6b2624fb29b9b273ae
|
|
| MD5 |
9f4ea0b7f8d15555872695f31265cc6e
|
|
| BLAKE2b-256 |
32fc98da3fe2bf55b0ffdc59b004c9654c38b0420290e2eb785b9babc970818a
|
File details
Details for the file pynotice-0.0.2-py3-none-any.whl.
File metadata
- Download URL: pynotice-0.0.2-py3-none-any.whl
- Upload date:
- Size: 160.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.33.0 CPython/3.6.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
95d42722a9d92fc7a7c3b19a017300e7fbf323e3a087e20c4976380251fff554
|
|
| MD5 |
564dc42ef13f6b0551a8d6270a7c31f1
|
|
| BLAKE2b-256 |
e813a04ab8e0946ed49ef626b6f5819b5684234213fd504bd28882a94f12557d
|