运维工具集
Project description
otl 工具集
安装方式
pip install otl
封装企业微信接口
from otl.wechat.wechat_api import WechatApi
GLOBAL_WECHAR_CONFIG = {
'NAME': 'xxx',
#企业的id,在管理端->"我的企业" 可以看到
'CORP_ID': '',
#应用列表 可以配置多个应用
'APP_LIST': {
'warning_robot': { #报警机器人
'APP_ID': '', #APPID
'APP_SECRET': '', #APP密钥
'switch': 'on', #是否开启
},
}
}
if __name__ == '__main__':
we = WechatApi(GLOBAL_WECHAR_CONFIG)
status, res = we.apps['warning_robot'].send(
msg_type='text',
to_users_list=['xxx'],
msg_string='xxx'
)
if not status:
print(res)
封装mysql方法
from otl.db import MysqlDbBase
class Db1(MysqlDbBase):
host = '1.1.1.1'
port = 3306
user = 'test_user'
password = 'test_pwd'
db = 'test_db'
# 实例化
db1 = Db1()
# 查询操作 -> 返回数据: list
db1.query("select ***")
# 写入操作 -> 返回影响行数: int
db1.insert("insert into ***")
# 更新操作 -> 返回影响行数: int
db1.update("update ***")
# 删除操作 -> 返回影响行数: int
db1.delete("delete ***")
发送邮件
# -*- coding: utf-8 -*-
from otl.email import EmailApi
CONFIG = {
# 组 支持多个组
'team1': {
'name': '', # 组名 即邮件主题
'user': '', # 发件人
'password': '', # 发件人密码
'smtp': '', # smtp服务器
'port': 25,
'to_list': ['aaa@aa.com'], # 收件人列表
'cc_list': [] # 抄送列表
}
}
if __name__ == '__main__':
ea = EmailApi(CONFIG).team1 # 组名
# 添加文本
ea.add_str('lalala')
# 添加图片
ea.add_image("/a/b/123.jpg")
# 添加表格
ea.add_table([['姓名', '年龄', '性别'], ['aaa', 25, '男'], ['ccc', 25, '男']])
# 添加附件
ea.add_attr("/a/b/wechat.tgz")
status, res = ea.send_email()
if status:
print('success')
else:
print('error: {}'.format(res))
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
otl-1.10.2.tar.gz
(12.7 kB
view details)
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
otl-1.10.2-py3-none-any.whl
(14.2 kB
view details)
File details
Details for the file otl-1.10.2.tar.gz.
File metadata
- Download URL: otl-1.10.2.tar.gz
- Upload date:
- Size: 12.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
208040f3e915af3a6fe59f5c47c70e1fc214a1739cbc7a5602934b43c1df45ba
|
|
| MD5 |
6cc315f9268c7d039a4bb31c827aa303
|
|
| BLAKE2b-256 |
fc50eb5b0ee54000bc8c29c2dd1af7292c4d932a600bb79cc9fbaf9fa86b08e4
|
File details
Details for the file otl-1.10.2-py3-none-any.whl.
File metadata
- Download URL: otl-1.10.2-py3-none-any.whl
- Upload date:
- Size: 14.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
899910f1aee917226b8b33798c976995e79825b781506a64b686e3d01de19ee2
|
|
| MD5 |
8218c8f9ff56b74d79926644c4e81559
|
|
| BLAKE2b-256 |
149db3980acaa51bc5dbbcc28682ca26c54a9891d17094fb26bd3c1750bf4ee6
|