xk-utils
xk-utils存放星矿公用模块,包括邮件模块, 日志模块等
打包
python3 -m pip install --upgrade build
python3 -m build
发布
pip install --upgrade twine
python3 -m twine upload --repository pypi dist/*
安装
pip install xk-utils
使用
1、发送邮件
from xk_utils.mail import MailProducer
redis_config = {
'host':'127.0.0.1',
'port': 6379,
'password': '****',
'db': 99
}
# 定义邮件key, 在服务端需要配置相关收件人, 邮件标题
m = MailProducer(key='log', **redis_config)
m.send(f'<邮件内容>')
2、记录日志
# 记录文件日志
import os
from xk_utils.logger import get_logger
logger = get_logger('log', 'werkzeug', write_file=True, file_path=os.path.join(os.path.dirname(__file__), 'log'))
logger.info("记录文件")
# 记录可以发送邮件的日志
logger = get_logger('log', 'celery', send_mail=True,
host='127.0.0.1',
port=6379,
password='****',
db=99
)
logger.info('这是一条正常日志, 不发送邮件')
logger.error('这是一条错误日志, 发送邮件, 邮件联系人、标题,请在服务器端配置, key=<log>')
Metadata
Release files for xk-utils 0.0.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| xk-utils-0.0.7.tar.gz | 6.8 kB | Without provenance | Details for xk-utils-0.0.7.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| xk_utils-0.0.7-py3-none-any.whl | Python 3 | none | any | Details for xk_utils-0.0.7-py3-none-any.whl |
Total release size: 14.2 kB
Release files / xk-utils-0.0.7.tar.gz
| Download URL | xk-utils-0.0.7.tar.gz |
|---|---|
| Size | 6.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
efe1b2d7f3bede6b195abed09fd948b8b7e5777778aa5e857b3566737ae618d2
|
|
BLAKE2b-256 checksum How to use checksums |
1c4a3e24a03b76629ac76f0c332a695eda1b2752e391cbf66897d73e853dd780
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.3rc1
|
Release files / xk_utils-0.0.7-py3-none-any.whl
| Download URL | xk_utils-0.0.7-py3-none-any.whl |
|---|---|
| Size | 7.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
48b11443bcce5ba0ba5e049fd70a85a04cf37af48cceeb285b9abc11521e29a0
|
|
BLAKE2b-256 checksum How to use checksums |
c2f7c827a64b60bfdffd13e8dbd9fc26f52506400007d383619951b92719e058
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.3rc1
|
Security for xk-utils 0.0.7
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.