pytbox 0.3.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. pytbox-0.3.2/MANIFEST.in +15 -0
  2. pytbox-0.3.2/PKG-INFO +274 -0
  3. pytbox-0.3.2/README.md +246 -0
  4. pytbox-0.3.2/pyproject.toml +56 -0
  5. pytbox-0.3.2/setup.cfg +4 -0
  6. pytbox-0.3.2/src/pytbox/alert/alert_handler.py +139 -0
  7. pytbox-0.3.2/src/pytbox/alert/ping.py +24 -0
  8. pytbox-0.3.2/src/pytbox/alicloud/sls.py +88 -0
  9. pytbox-0.3.2/src/pytbox/base.py +121 -0
  10. pytbox-0.3.2/src/pytbox/categraf/build_config.py +143 -0
  11. pytbox-0.3.2/src/pytbox/categraf/instances.toml +39 -0
  12. pytbox-0.3.2/src/pytbox/categraf/jinja2/__init__.py +6 -0
  13. pytbox-0.3.2/src/pytbox/categraf/jinja2/input.cpu/cpu.toml.j2 +5 -0
  14. pytbox-0.3.2/src/pytbox/categraf/jinja2/input.disk/disk.toml.j2 +11 -0
  15. pytbox-0.3.2/src/pytbox/categraf/jinja2/input.diskio/diskio.toml.j2 +6 -0
  16. pytbox-0.3.2/src/pytbox/categraf/jinja2/input.dns_query/dns_query.toml.j2 +12 -0
  17. pytbox-0.3.2/src/pytbox/categraf/jinja2/input.http_response/http_response.toml.j2 +9 -0
  18. pytbox-0.3.2/src/pytbox/categraf/jinja2/input.mem/mem.toml.j2 +5 -0
  19. pytbox-0.3.2/src/pytbox/categraf/jinja2/input.net/net.toml.j2 +11 -0
  20. pytbox-0.3.2/src/pytbox/categraf/jinja2/input.net_response/net_response.toml.j2 +9 -0
  21. pytbox-0.3.2/src/pytbox/categraf/jinja2/input.ping/ping.toml.j2 +11 -0
  22. pytbox-0.3.2/src/pytbox/categraf/jinja2/input.prometheus/prometheus.toml.j2 +12 -0
  23. pytbox-0.3.2/src/pytbox/categraf/jinja2/input.snmp/cisco_interface.toml.j2 +96 -0
  24. pytbox-0.3.2/src/pytbox/categraf/jinja2/input.snmp/cisco_system.toml.j2 +41 -0
  25. pytbox-0.3.2/src/pytbox/categraf/jinja2/input.snmp/h3c_interface.toml.j2 +96 -0
  26. pytbox-0.3.2/src/pytbox/categraf/jinja2/input.snmp/h3c_system.toml.j2 +41 -0
  27. pytbox-0.3.2/src/pytbox/categraf/jinja2/input.snmp/huawei_interface.toml.j2 +96 -0
  28. pytbox-0.3.2/src/pytbox/categraf/jinja2/input.snmp/huawei_system.toml.j2 +41 -0
  29. pytbox-0.3.2/src/pytbox/categraf/jinja2/input.snmp/ruijie_interface.toml.j2 +96 -0
  30. pytbox-0.3.2/src/pytbox/categraf/jinja2/input.snmp/ruijie_system.toml.j2 +41 -0
  31. pytbox-0.3.2/src/pytbox/categraf/jinja2/input.vsphere/vsphere.toml.j2 +211 -0
  32. pytbox-0.3.2/src/pytbox/cli/__init__.py +7 -0
  33. pytbox-0.3.2/src/pytbox/cli/categraf/__init__.py +7 -0
  34. pytbox-0.3.2/src/pytbox/cli/categraf/commands.py +55 -0
  35. pytbox-0.3.2/src/pytbox/cli/commands/vm.py +22 -0
  36. pytbox-0.3.2/src/pytbox/cli/common/__init__.py +6 -0
  37. pytbox-0.3.2/src/pytbox/cli/common/options.py +42 -0
  38. pytbox-0.3.2/src/pytbox/cli/common/utils.py +269 -0
  39. pytbox-0.3.2/src/pytbox/cli/formatters/__init__.py +7 -0
  40. pytbox-0.3.2/src/pytbox/cli/formatters/output.py +155 -0
  41. pytbox-0.3.2/src/pytbox/cli/main.py +24 -0
  42. pytbox-0.3.2/src/pytbox/cli.py +9 -0
  43. pytbox-0.3.2/src/pytbox/common/__init__.py +7 -0
  44. pytbox-0.3.2/src/pytbox/database/mongo.py +99 -0
  45. pytbox-0.3.2/src/pytbox/database/victoriametrics.py +404 -0
  46. pytbox-0.3.2/src/pytbox/dida365.py +291 -0
  47. pytbox-0.3.2/src/pytbox/excel.py +64 -0
  48. pytbox-0.3.2/src/pytbox/feishu/client.py +183 -0
  49. pytbox-0.3.2/src/pytbox/feishu/endpoints.py +1052 -0
  50. pytbox-0.3.2/src/pytbox/feishu/errors.py +45 -0
  51. pytbox-0.3.2/src/pytbox/feishu/helpers.py +7 -0
  52. pytbox-0.3.2/src/pytbox/feishu/typing.py +7 -0
  53. pytbox-0.3.2/src/pytbox/log/logger.py +177 -0
  54. pytbox-0.3.2/src/pytbox/log/victorialog.py +125 -0
  55. pytbox-0.3.2/src/pytbox/mail/alimail.py +142 -0
  56. pytbox-0.3.2/src/pytbox/mail/client.py +171 -0
  57. pytbox-0.3.2/src/pytbox/mail/mail_detail.py +30 -0
  58. pytbox-0.3.2/src/pytbox/mingdao.py +164 -0
  59. pytbox-0.3.2/src/pytbox/network/meraki.py +537 -0
  60. pytbox-0.3.2/src/pytbox/notion.py +731 -0
  61. pytbox-0.3.2/src/pytbox/onepassword_connect.py +92 -0
  62. pytbox-0.3.2/src/pytbox/onepassword_sa.py +197 -0
  63. pytbox-0.3.2/src/pytbox/pyjira.py +612 -0
  64. pytbox-0.3.2/src/pytbox/utils/cronjob.py +79 -0
  65. pytbox-0.3.2/src/pytbox/utils/env.py +30 -0
  66. pytbox-0.3.2/src/pytbox/utils/load_config.py +132 -0
  67. pytbox-0.3.2/src/pytbox/utils/load_vm_devfile.py +45 -0
  68. pytbox-0.3.2/src/pytbox/utils/response.py +45 -0
  69. pytbox-0.3.2/src/pytbox/utils/richutils.py +31 -0
  70. pytbox-0.3.2/src/pytbox/utils/timeutils.py +505 -0
  71. pytbox-0.3.2/src/pytbox/vmware.py +120 -0
  72. pytbox-0.3.2/src/pytbox/win/ad.py +30 -0
  73. pytbox-0.3.2/src/pytbox.egg-info/PKG-INFO +274 -0
  74. pytbox-0.3.2/src/pytbox.egg-info/SOURCES.txt +87 -0
  75. pytbox-0.3.2/src/pytbox.egg-info/dependency_links.txt +1 -0
  76. pytbox-0.3.2/src/pytbox.egg-info/entry_points.txt +2 -0
  77. pytbox-0.3.2/src/pytbox.egg-info/requires.txt +21 -0
  78. pytbox-0.3.2/src/pytbox.egg-info/top_level.txt +1 -0
  79. pytbox-0.3.2/tests/test_base.py +9 -0
  80. pytbox-0.3.2/tests/test_feishu.py +11 -0
  81. pytbox-0.3.2/tests/test_jira_connection.py +55 -0
  82. pytbox-0.3.2/tests/test_load_jsonfile.py +14 -0
  83. pytbox-0.3.2/tests/test_logger.py +20 -0
  84. pytbox-0.3.2/tests/test_mingdao.py +37 -0
  85. pytbox-0.3.2/tests/test_notion.py +279 -0
  86. pytbox-0.3.2/tests/test_onepassword_connect.py +12 -0
  87. pytbox-0.3.2/tests/test_onepassword_sa.py +26 -0
  88. pytbox-0.3.2/tests/test_victoriametrics.py +48 -0
  89. pytbox-0.3.2/tests/test_vmware.py +6 -0
@@ -0,0 +1,15 @@
1
+ # 包含所有模板文件
2
+ recursive-include src/pytbox/categraf/jinja2 *.j2
3
+ recursive-include src/pytbox/categraf *.toml
4
+
5
+ # 包含文档文件
6
+ include README.md
7
+
8
+ # 包含配置文件
9
+ include pyproject.toml
10
+
11
+ # 排除缓存和临时文件
12
+ global-exclude *.pyc
13
+ global-exclude __pycache__
14
+ global-exclude .git*
15
+ global-exclude .DS_Store
pytbox-0.3.2/PKG-INFO ADDED
@@ -0,0 +1,274 @@
1
+ Metadata-Version: 2.4
2
+ Name: pytbox
3
+ Version: 0.3.2
4
+ Summary: A collection of Python integrations and utilities (Feishu, Dida365, VictoriaMetrics, ...)
5
+ Author-email: mingming hou <houm01@foxmail.com>
6
+ License-Expression: MIT
7
+ Requires-Python: >=3.8
8
+ Description-Content-Type: text/markdown
9
+ Requires-Dist: requests>=2.0
10
+ Requires-Dist: pydantic>=1.10
11
+ Requires-Dist: onepasswordconnectsdk>=1.0.0
12
+ Requires-Dist: loguru>=0.7.3
13
+ Requires-Dist: chinese_calendar>=1.10.0
14
+ Requires-Dist: click>=8.0.0
15
+ Requires-Dist: rich>=12.0.0
16
+ Requires-Dist: jinja2>=3.0.0
17
+ Requires-Dist: toml>=0.10.0
18
+ Requires-Dist: ldap3>=2.9.1
19
+ Requires-Dist: imap-tools>=1.11.0
20
+ Requires-Dist: yagmail>=0.15.293
21
+ Provides-Extra: dev
22
+ Requires-Dist: pytest; extra == "dev"
23
+ Requires-Dist: black; extra == "dev"
24
+ Requires-Dist: ruff; extra == "dev"
25
+ Requires-Dist: python-dotenv; extra == "dev"
26
+ Provides-Extra: cli
27
+ Requires-Dist: pyyaml>=6.0; extra == "cli"
28
+
29
+ # PytBox
30
+
31
+ [![PyPI version](https://img.shields.io/pypi/v/pytbox.svg)](https://pypi.org/project/pytbox/)
32
+ [![Python version](https://img.shields.io/pypi/pyversions/pytbox.svg)](https://pypi.org/project/pytbox/)
33
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
34
+
35
+ 一个集成了多种服务和实用工具的 Python 包,专为运维开发场景设计。包含 VictoriaMetrics、滴答清单(Dida365)、飞书等服务的集成工具,以及常用的时间处理等实用工具。
36
+
37
+ ## 特性
38
+
39
+ - 🔍 **VictoriaMetrics 集成** - 提供时序数据库查询功能
40
+ - ⏰ **时间工具** - 常用的时间戳处理工具
41
+ - 📊 **统一响应格式** - 标准化的 API 响应结构
42
+ - 🛠 **基础工具类** - 提供 API 基类和通用功能
43
+ - 🧪 **完整测试** - 包含单元测试确保代码质量
44
+
45
+ ## 安装
46
+
47
+ ### 从 PyPI 安装
48
+
49
+ ```bash
50
+ pip install pytbox
51
+ ```
52
+
53
+ ### 从源码安装
54
+
55
+ ```bash
56
+ git clone https://github.com/your-username/pytbox.git
57
+ cd pytbox
58
+ pip install -e .
59
+ ```
60
+
61
+ ## 快速开始
62
+
63
+ ### VictoriaMetrics 查询
64
+
65
+ ```python
66
+ from pytbox.victoriametrics import VictoriaMetrics
67
+
68
+ # 初始化 VictoriaMetrics 客户端
69
+ vm = VictoriaMetrics(url="http://localhost:8428", timeout=5)
70
+
71
+ # 查询指标数据
72
+ result = vm.query('ping_average_response_ms')
73
+
74
+ if result.is_success():
75
+ print("查询成功:", result.data)
76
+ else:
77
+ print("查询失败:", result.msg)
78
+ ```
79
+
80
+ ### 时间工具使用
81
+
82
+ ```python
83
+ from pytbox.utils.timeutils import TimeUtils
84
+
85
+ # 获取当前时间戳(秒)
86
+ timestamp = TimeUtils.get_timestamp()
87
+ print(f"当前时间戳: {timestamp}")
88
+
89
+ # 获取当前时间戳(毫秒)
90
+ timestamp_ms = TimeUtils.get_timestamp(now=False)
91
+ print(f"当前时间戳(毫秒): {timestamp_ms}")
92
+ ```
93
+
94
+ ### 使用基础 API 类
95
+
96
+ ```python
97
+ from pytbox.common.base import BaseAPI
98
+
99
+ class MyAPI(BaseAPI):
100
+ def __init__(self):
101
+ super().__init__(base_url="https://api.example.com")
102
+
103
+ def make_request(self):
104
+ # 记录请求日志
105
+ log = self.log_request("GET", "/users", {"param": "value"})
106
+ print("请求日志:", log)
107
+
108
+ # 检查会话存活时间
109
+ age = self.get_session_age()
110
+ print(f"会话存活时间: {age} 秒")
111
+
112
+ api = MyAPI()
113
+ api.make_request()
114
+ ```
115
+
116
+ ### 统一响应格式
117
+
118
+ ```python
119
+ from pytbox.utils.response import ReturnResponse
120
+
121
+ # 创建成功响应
122
+ success_response = ReturnResponse(
123
+ code=0,
124
+ msg="操作成功",
125
+ data={"user_id": 123, "username": "admin"}
126
+ )
127
+
128
+ # 创建错误响应
129
+ error_response = ReturnResponse(
130
+ code=1,
131
+ msg="用户未找到",
132
+ data=None
133
+ )
134
+
135
+ # 检查响应状态
136
+ if success_response.is_success():
137
+ print("操作成功:", success_response.data)
138
+
139
+ if error_response.is_error():
140
+ print("操作失败:", error_response.msg)
141
+ ```
142
+
143
+ ## API 文档
144
+
145
+ ### VictoriaMetrics
146
+
147
+ #### `VictoriaMetrics(url, timeout=3)`
148
+
149
+ VictoriaMetrics 时序数据库客户端。
150
+
151
+ **参数:**
152
+ - `url` (str): VictoriaMetrics 服务器地址
153
+ - `timeout` (int): 请求超时时间,默认 3 秒
154
+
155
+ **方法:**
156
+
157
+ ##### `query(query: str) -> ReturnResponse`
158
+
159
+ 执行 PromQL 查询。
160
+
161
+ **参数:**
162
+ - `query` (str): PromQL 查询语句
163
+
164
+ **返回:**
165
+ - `ReturnResponse`: 统一响应格式,包含查询结果
166
+
167
+ ### TimeUtils
168
+
169
+ #### `TimeUtils.get_timestamp(now=True) -> int`
170
+
171
+ 获取时间戳。
172
+
173
+ **参数:**
174
+ - `now` (bool): True 返回秒级时间戳,False 返回毫秒级时间戳
175
+
176
+ **返回:**
177
+ - `int`: 时间戳
178
+
179
+ ### ReturnResponse
180
+
181
+ 统一的响应格式类,包含以下状态码:
182
+
183
+ - `0` - 成功 (SUCCESS)
184
+ - `1` - 一般错误 (ERROR)
185
+ - `2` - 警告 (WARNING)
186
+ - `3` - 未授权 (UNAUTHORIZED)
187
+ - `4` - 资源未找到 (NOT_FOUND)
188
+ - `5` - 请求超时 (TIMEOUT)
189
+ - `6` - 参数错误 (INVALID_PARAMS)
190
+ - `7` - 权限不足 (PERMISSION_DENIED)
191
+ - `8` - 服务不可用 (SERVICE_UNAVAILABLE)
192
+ - `9` - 数据库错误 (DATABASE_ERROR)
193
+ - `10` - 网络错误 (NETWORK_ERROR)
194
+
195
+ **方法:**
196
+ - `is_success() -> bool`: 判断是否为成功响应
197
+ - `is_error() -> bool`: 判断是否为错误响应
198
+
199
+ ## 开发
200
+
201
+ ### 安装开发依赖
202
+
203
+ ```bash
204
+ pip install -e ".[dev]"
205
+ ```
206
+
207
+ ### 运行测试
208
+
209
+ ```bash
210
+ pytest tests/
211
+ ```
212
+
213
+ ### 代码格式化
214
+
215
+ ```bash
216
+ black src/ tests/
217
+ ```
218
+
219
+ ### 代码检查
220
+
221
+ ```bash
222
+ ruff check src/ tests/
223
+ ```
224
+
225
+ ## 环境变量
226
+
227
+ 可以通过以下环境变量进行配置:
228
+
229
+ - `VICTORIAMETRICS_URL`: VictoriaMetrics 服务器地址(默认: http://localhost:8428)
230
+
231
+ ## 发布流程
232
+
233
+ 项目使用 GitHub Actions 自动发布到 PyPI:
234
+
235
+ 1. 更新版本号(在 `pyproject.toml` 中)
236
+ 2. 使用发布脚本创建标签:
237
+ ```bash
238
+ ./publish.sh 0.1.1
239
+ ```
240
+ 3. GitHub Actions 会自动构建并发布到 PyPI
241
+
242
+ ## 贡献
243
+
244
+ 欢迎提交 Issue 和 Pull Request!
245
+
246
+ 1. Fork 项目
247
+ 2. 创建功能分支 (`git checkout -b feature/AmazingFeature`)
248
+ 3. 提交更改 (`git commit -m 'Add some AmazingFeature'`)
249
+ 4. 推送到分支 (`git push origin feature/AmazingFeature`)
250
+ 5. 开启 Pull Request
251
+
252
+ ## 许可证
253
+
254
+ 本项目采用 MIT 许可证 - 查看 [LICENSE](LICENSE) 文件了解详情。
255
+
256
+ ## 更新日志
257
+
258
+ ### v0.1.0
259
+ - 初始版本发布
260
+ - 添加 VictoriaMetrics 集成
261
+ - 添加时间工具类
262
+ - 添加统一响应格式
263
+ - 添加基础 API 工具类
264
+
265
+ ## 联系方式
266
+
267
+ 如有问题或建议,请通过以下方式联系:
268
+
269
+ - 提交 [Issue](https://github.com/your-username/pytbox/issues)
270
+ - 发送邮件至 houm01@foxmail.com
271
+
272
+ ---
273
+
274
+ **PytBox** - 让运维开发更简单! 🚀
pytbox-0.3.2/README.md ADDED
@@ -0,0 +1,246 @@
1
+ # PytBox
2
+
3
+ [![PyPI version](https://img.shields.io/pypi/v/pytbox.svg)](https://pypi.org/project/pytbox/)
4
+ [![Python version](https://img.shields.io/pypi/pyversions/pytbox.svg)](https://pypi.org/project/pytbox/)
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
6
+
7
+ 一个集成了多种服务和实用工具的 Python 包,专为运维开发场景设计。包含 VictoriaMetrics、滴答清单(Dida365)、飞书等服务的集成工具,以及常用的时间处理等实用工具。
8
+
9
+ ## 特性
10
+
11
+ - 🔍 **VictoriaMetrics 集成** - 提供时序数据库查询功能
12
+ - ⏰ **时间工具** - 常用的时间戳处理工具
13
+ - 📊 **统一响应格式** - 标准化的 API 响应结构
14
+ - 🛠 **基础工具类** - 提供 API 基类和通用功能
15
+ - 🧪 **完整测试** - 包含单元测试确保代码质量
16
+
17
+ ## 安装
18
+
19
+ ### 从 PyPI 安装
20
+
21
+ ```bash
22
+ pip install pytbox
23
+ ```
24
+
25
+ ### 从源码安装
26
+
27
+ ```bash
28
+ git clone https://github.com/your-username/pytbox.git
29
+ cd pytbox
30
+ pip install -e .
31
+ ```
32
+
33
+ ## 快速开始
34
+
35
+ ### VictoriaMetrics 查询
36
+
37
+ ```python
38
+ from pytbox.victoriametrics import VictoriaMetrics
39
+
40
+ # 初始化 VictoriaMetrics 客户端
41
+ vm = VictoriaMetrics(url="http://localhost:8428", timeout=5)
42
+
43
+ # 查询指标数据
44
+ result = vm.query('ping_average_response_ms')
45
+
46
+ if result.is_success():
47
+ print("查询成功:", result.data)
48
+ else:
49
+ print("查询失败:", result.msg)
50
+ ```
51
+
52
+ ### 时间工具使用
53
+
54
+ ```python
55
+ from pytbox.utils.timeutils import TimeUtils
56
+
57
+ # 获取当前时间戳(秒)
58
+ timestamp = TimeUtils.get_timestamp()
59
+ print(f"当前时间戳: {timestamp}")
60
+
61
+ # 获取当前时间戳(毫秒)
62
+ timestamp_ms = TimeUtils.get_timestamp(now=False)
63
+ print(f"当前时间戳(毫秒): {timestamp_ms}")
64
+ ```
65
+
66
+ ### 使用基础 API 类
67
+
68
+ ```python
69
+ from pytbox.common.base import BaseAPI
70
+
71
+ class MyAPI(BaseAPI):
72
+ def __init__(self):
73
+ super().__init__(base_url="https://api.example.com")
74
+
75
+ def make_request(self):
76
+ # 记录请求日志
77
+ log = self.log_request("GET", "/users", {"param": "value"})
78
+ print("请求日志:", log)
79
+
80
+ # 检查会话存活时间
81
+ age = self.get_session_age()
82
+ print(f"会话存活时间: {age} 秒")
83
+
84
+ api = MyAPI()
85
+ api.make_request()
86
+ ```
87
+
88
+ ### 统一响应格式
89
+
90
+ ```python
91
+ from pytbox.utils.response import ReturnResponse
92
+
93
+ # 创建成功响应
94
+ success_response = ReturnResponse(
95
+ code=0,
96
+ msg="操作成功",
97
+ data={"user_id": 123, "username": "admin"}
98
+ )
99
+
100
+ # 创建错误响应
101
+ error_response = ReturnResponse(
102
+ code=1,
103
+ msg="用户未找到",
104
+ data=None
105
+ )
106
+
107
+ # 检查响应状态
108
+ if success_response.is_success():
109
+ print("操作成功:", success_response.data)
110
+
111
+ if error_response.is_error():
112
+ print("操作失败:", error_response.msg)
113
+ ```
114
+
115
+ ## API 文档
116
+
117
+ ### VictoriaMetrics
118
+
119
+ #### `VictoriaMetrics(url, timeout=3)`
120
+
121
+ VictoriaMetrics 时序数据库客户端。
122
+
123
+ **参数:**
124
+ - `url` (str): VictoriaMetrics 服务器地址
125
+ - `timeout` (int): 请求超时时间,默认 3 秒
126
+
127
+ **方法:**
128
+
129
+ ##### `query(query: str) -> ReturnResponse`
130
+
131
+ 执行 PromQL 查询。
132
+
133
+ **参数:**
134
+ - `query` (str): PromQL 查询语句
135
+
136
+ **返回:**
137
+ - `ReturnResponse`: 统一响应格式,包含查询结果
138
+
139
+ ### TimeUtils
140
+
141
+ #### `TimeUtils.get_timestamp(now=True) -> int`
142
+
143
+ 获取时间戳。
144
+
145
+ **参数:**
146
+ - `now` (bool): True 返回秒级时间戳,False 返回毫秒级时间戳
147
+
148
+ **返回:**
149
+ - `int`: 时间戳
150
+
151
+ ### ReturnResponse
152
+
153
+ 统一的响应格式类,包含以下状态码:
154
+
155
+ - `0` - 成功 (SUCCESS)
156
+ - `1` - 一般错误 (ERROR)
157
+ - `2` - 警告 (WARNING)
158
+ - `3` - 未授权 (UNAUTHORIZED)
159
+ - `4` - 资源未找到 (NOT_FOUND)
160
+ - `5` - 请求超时 (TIMEOUT)
161
+ - `6` - 参数错误 (INVALID_PARAMS)
162
+ - `7` - 权限不足 (PERMISSION_DENIED)
163
+ - `8` - 服务不可用 (SERVICE_UNAVAILABLE)
164
+ - `9` - 数据库错误 (DATABASE_ERROR)
165
+ - `10` - 网络错误 (NETWORK_ERROR)
166
+
167
+ **方法:**
168
+ - `is_success() -> bool`: 判断是否为成功响应
169
+ - `is_error() -> bool`: 判断是否为错误响应
170
+
171
+ ## 开发
172
+
173
+ ### 安装开发依赖
174
+
175
+ ```bash
176
+ pip install -e ".[dev]"
177
+ ```
178
+
179
+ ### 运行测试
180
+
181
+ ```bash
182
+ pytest tests/
183
+ ```
184
+
185
+ ### 代码格式化
186
+
187
+ ```bash
188
+ black src/ tests/
189
+ ```
190
+
191
+ ### 代码检查
192
+
193
+ ```bash
194
+ ruff check src/ tests/
195
+ ```
196
+
197
+ ## 环境变量
198
+
199
+ 可以通过以下环境变量进行配置:
200
+
201
+ - `VICTORIAMETRICS_URL`: VictoriaMetrics 服务器地址(默认: http://localhost:8428)
202
+
203
+ ## 发布流程
204
+
205
+ 项目使用 GitHub Actions 自动发布到 PyPI:
206
+
207
+ 1. 更新版本号(在 `pyproject.toml` 中)
208
+ 2. 使用发布脚本创建标签:
209
+ ```bash
210
+ ./publish.sh 0.1.1
211
+ ```
212
+ 3. GitHub Actions 会自动构建并发布到 PyPI
213
+
214
+ ## 贡献
215
+
216
+ 欢迎提交 Issue 和 Pull Request!
217
+
218
+ 1. Fork 项目
219
+ 2. 创建功能分支 (`git checkout -b feature/AmazingFeature`)
220
+ 3. 提交更改 (`git commit -m 'Add some AmazingFeature'`)
221
+ 4. 推送到分支 (`git push origin feature/AmazingFeature`)
222
+ 5. 开启 Pull Request
223
+
224
+ ## 许可证
225
+
226
+ 本项目采用 MIT 许可证 - 查看 [LICENSE](LICENSE) 文件了解详情。
227
+
228
+ ## 更新日志
229
+
230
+ ### v0.1.0
231
+ - 初始版本发布
232
+ - 添加 VictoriaMetrics 集成
233
+ - 添加时间工具类
234
+ - 添加统一响应格式
235
+ - 添加基础 API 工具类
236
+
237
+ ## 联系方式
238
+
239
+ 如有问题或建议,请通过以下方式联系:
240
+
241
+ - 提交 [Issue](https://github.com/your-username/pytbox/issues)
242
+ - 发送邮件至 houm01@foxmail.com
243
+
244
+ ---
245
+
246
+ **PytBox** - 让运维开发更简单! 🚀
@@ -0,0 +1,56 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "pytbox"
7
+ version = "0.3.2"
8
+ description = "A collection of Python integrations and utilities (Feishu, Dida365, VictoriaMetrics, ...)"
9
+ authors = [{ name = "mingming hou", email = "houm01@foxmail.com" }]
10
+ license = "MIT"
11
+ readme = "README.md"
12
+ requires-python = ">=3.8"
13
+
14
+ dependencies = [
15
+ "requests>=2.0",
16
+ "pydantic>=1.10",
17
+ # 这个包 28M, 如果从官方源下载太慢了, 先禁用一下,等以后版本稳定了,同步到国内源了再取消注释
18
+ # "onepassword-sdk>=0.3.1",
19
+ "onepasswordconnectsdk>=1.0.0",
20
+ "loguru>=0.7.3",
21
+ "chinese_calendar>=1.10.0",
22
+ "click>=8.0.0", # 添加 click 依赖
23
+ "rich>=12.0.0", # 添加 rich 依赖
24
+ "jinja2>=3.0.0", # 模板渲染
25
+ "toml>=0.10.0", # TOML 输出支持
26
+ "ldap3>=2.9.1", # LDAP 支持
27
+ "imap-tools>=1.11.0",
28
+ "yagmail>=0.15.293"
29
+ ]
30
+
31
+ [project.scripts]
32
+ pytbox = "pytbox.cli:main" # 添加命令行入口点
33
+
34
+ [project.optional-dependencies]
35
+ dev = ["pytest", "black", "ruff", "python-dotenv"]
36
+ cli = [
37
+ "pyyaml>=6.0", # YAML 输出支持
38
+ ]
39
+
40
+ [tool.setuptools]
41
+ include-package-data = true
42
+
43
+ [tool.setuptools.packages.find]
44
+ where = ["src"]
45
+
46
+ [tool.pytest.ini_options]
47
+ filterwarnings = [
48
+ "ignore::DeprecationWarning:pyasn1.*",
49
+ "ignore:tagMap is deprecated:DeprecationWarning",
50
+ "ignore:typeMap is deprecated:DeprecationWarning",
51
+ ]
52
+ # 显示日志输出
53
+ log_cli = true
54
+ log_cli_level = "INFO"
55
+ log_cli_format = "%(asctime)s [%(levelname)8s] %(name)s: %(message)s"
56
+ log_cli_date_format = "%Y-%m-%d %H:%M:%S"
pytbox-0.3.2/setup.cfg ADDED
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+