pixelarraylib 1.0.0__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.
- pixelarraylib-1.0.0/LICENSE +21 -0
- pixelarraylib-1.0.0/MANIFEST.in +7 -0
- pixelarraylib-1.0.0/PKG-INFO +141 -0
- pixelarraylib-1.0.0/README.md +92 -0
- pixelarraylib-1.0.0/arraylib/__init__.py +36 -0
- pixelarraylib-1.0.0/arraylib/__main__.py +126 -0
- pixelarraylib-1.0.0/arraylib/aliyun/__init__.py +0 -0
- pixelarraylib-1.0.0/arraylib/aliyun/aliyun_email.py +130 -0
- pixelarraylib-1.0.0/arraylib/aliyun/billing.py +477 -0
- pixelarraylib-1.0.0/arraylib/aliyun/content_scanner.py +253 -0
- pixelarraylib-1.0.0/arraylib/aliyun/domain.py +434 -0
- pixelarraylib-1.0.0/arraylib/aliyun/eci.py +47 -0
- pixelarraylib-1.0.0/arraylib/aliyun/ecs.py +68 -0
- pixelarraylib-1.0.0/arraylib/aliyun/fc.py +142 -0
- pixelarraylib-1.0.0/arraylib/aliyun/oss.py +649 -0
- pixelarraylib-1.0.0/arraylib/aliyun/sms.py +59 -0
- pixelarraylib-1.0.0/arraylib/aliyun/sts.py +124 -0
- pixelarraylib-1.0.0/arraylib/db_utils/mysql.py +544 -0
- pixelarraylib-1.0.0/arraylib/db_utils/redis.py +373 -0
- pixelarraylib-1.0.0/arraylib/decorators/__init__.py +13 -0
- pixelarraylib-1.0.0/arraylib/decorators/decorators.py +194 -0
- pixelarraylib-1.0.0/arraylib/gitlab/__init__.py +0 -0
- pixelarraylib-1.0.0/arraylib/gitlab/code_analyzer.py +344 -0
- pixelarraylib-1.0.0/arraylib/gitlab/pypi_package_manager.py +61 -0
- pixelarraylib-1.0.0/arraylib/monitor/__init__.py +0 -0
- pixelarraylib-1.0.0/arraylib/monitor/feishu.py +132 -0
- pixelarraylib-1.0.0/arraylib/net/request.py +143 -0
- pixelarraylib-1.0.0/arraylib/scripts/__init__.py +22 -0
- pixelarraylib-1.0.0/arraylib/scripts/collect_code_to_txt.py +327 -0
- pixelarraylib-1.0.0/arraylib/scripts/create_test_case_files.py +100 -0
- pixelarraylib-1.0.0/arraylib/scripts/nginx_proxy_to_ecs.py +119 -0
- pixelarraylib-1.0.0/arraylib/scripts/remove_empty_lines.py +120 -0
- pixelarraylib-1.0.0/arraylib/scripts/summary_code_count.py +430 -0
- pixelarraylib-1.0.0/arraylib/system/__init__.py +0 -0
- pixelarraylib-1.0.0/arraylib/system/common.py +390 -0
- pixelarraylib-1.0.0/pixelarraylib.egg-info/PKG-INFO +141 -0
- pixelarraylib-1.0.0/pixelarraylib.egg-info/SOURCES.txt +42 -0
- pixelarraylib-1.0.0/pixelarraylib.egg-info/dependency_links.txt +1 -0
- pixelarraylib-1.0.0/pixelarraylib.egg-info/entry_points.txt +2 -0
- pixelarraylib-1.0.0/pixelarraylib.egg-info/requires.txt +24 -0
- pixelarraylib-1.0.0/pixelarraylib.egg-info/top_level.txt +1 -0
- pixelarraylib-1.0.0/pyproject.toml +72 -0
- pixelarraylib-1.0.0/requirements.txt +24 -0
- pixelarraylib-1.0.0/setup.cfg +4 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 PixelArray
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pixelarraylib
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: PixelArray Python开发工具库 - 包含阿里云服务、数据库工具、装饰器、监控等功能
|
|
5
|
+
Author-email: Lu qi <qi.lu@pixelarrayai.com>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://gitlab.com/pixelarrayai/general_pythondevutils_lib
|
|
8
|
+
Project-URL: Bug Reports, https://gitlab.com/pixelarrayai/general_pythondevutils_lib/-/issues
|
|
9
|
+
Project-URL: Source, https://gitlab.com/pixelarrayai/general_pythondevutils_lib
|
|
10
|
+
Keywords: python,utils,aliyun,database,tools,pixelarray
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Operating System :: OS Independent
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
20
|
+
Classifier: Topic :: Utilities
|
|
21
|
+
Requires-Python: >=3.8
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
License-File: LICENSE
|
|
24
|
+
Requires-Dist: alibabacloud_tea_util
|
|
25
|
+
Requires-Dist: alibabacloud_cms20190101
|
|
26
|
+
Requires-Dist: alibabacloud_green20220302
|
|
27
|
+
Requires-Dist: alibabacloud_dm20151123
|
|
28
|
+
Requires-Dist: alibabacloud_fc20230330
|
|
29
|
+
Requires-Dist: alibabacloud_darabonba_stream
|
|
30
|
+
Requires-Dist: alibabacloud_dysmsapi20170525
|
|
31
|
+
Requires-Dist: alibabacloud_sts20150401
|
|
32
|
+
Requires-Dist: alibabacloud_alidns20150109
|
|
33
|
+
Requires-Dist: alibabacloud_eci20180808
|
|
34
|
+
Requires-Dist: alibabacloud_bssopenapi20171214
|
|
35
|
+
Requires-Dist: oss2
|
|
36
|
+
Requires-Dist: pymysql
|
|
37
|
+
Requires-Dist: aiomysql
|
|
38
|
+
Requires-Dist: redis
|
|
39
|
+
Requires-Dist: redis[async]
|
|
40
|
+
Requires-Dist: requests
|
|
41
|
+
Requires-Dist: aiohttp
|
|
42
|
+
Requires-Dist: asyncio
|
|
43
|
+
Requires-Dist: setuptools
|
|
44
|
+
Requires-Dist: cffi
|
|
45
|
+
Requires-Dist: cryptography
|
|
46
|
+
Requires-Dist: pandas
|
|
47
|
+
Requires-Dist: paramiko
|
|
48
|
+
Dynamic: license-file
|
|
49
|
+
|
|
50
|
+
# PixelArrayLib - PixelArray Python开发工具库
|
|
51
|
+
|
|
52
|
+
PixelArrayLib是一个功能丰富的Python开发工具库,包含阿里云服务、数据库工具、装饰器、监控等功能,同时提供便捷的命令行工具。
|
|
53
|
+
|
|
54
|
+
## 安装
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
pip install pixelarraylib
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## 使用方法
|
|
61
|
+
|
|
62
|
+
### 1. Python程序中使用
|
|
63
|
+
|
|
64
|
+
```python
|
|
65
|
+
# 导入pixelarraylib模块
|
|
66
|
+
import arraylib
|
|
67
|
+
|
|
68
|
+
# 使用各种功能模块
|
|
69
|
+
from arraylib.aliyun import some_service
|
|
70
|
+
from arraylib.db_utils import database_tools
|
|
71
|
+
from arraylib.decorators import useful_decorators
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### 2. 命令行工具使用
|
|
75
|
+
|
|
76
|
+
安装后,你可以在命令行中直接使用 `pixelarraylib` 命令:
|
|
77
|
+
|
|
78
|
+
#### 创建测试用例文件
|
|
79
|
+
```bash
|
|
80
|
+
# 一键创建所有测试用例文件
|
|
81
|
+
pixelarraylib create_test_case_files
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
#### 代码提交统计
|
|
85
|
+
```bash
|
|
86
|
+
# 统计最近30天的代码提交
|
|
87
|
+
pixelarraylib summary_code_count
|
|
88
|
+
|
|
89
|
+
# 统计指定日期范围的提交
|
|
90
|
+
pixelarraylib summary_code_count --since="2025-05-09"
|
|
91
|
+
|
|
92
|
+
# 统计特定作者的提交
|
|
93
|
+
pixelarraylib summary_code_count --author="张三"
|
|
94
|
+
|
|
95
|
+
# 输出到CSV文件
|
|
96
|
+
pixelarraylib summary_code_count --output=stats.csv
|
|
97
|
+
|
|
98
|
+
# 只统计特定文件类型
|
|
99
|
+
pixelarraylib summary_code_count --file-types="py,js,vue"
|
|
100
|
+
|
|
101
|
+
# 查看帮助信息
|
|
102
|
+
pixelarraylib summary_code_count --help
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## 功能特性
|
|
106
|
+
|
|
107
|
+
- **阿里云服务集成**: 包含CMS、Green、DM、FC、SMS、STS等服务
|
|
108
|
+
- **数据库工具**: MySQL、Redis等数据库操作工具
|
|
109
|
+
- **Web框架**: FastAPI集成
|
|
110
|
+
- **实用工具**: 二维码生成、加密解密、XML处理等
|
|
111
|
+
- **命令行工具**: 测试用例生成、代码统计等实用脚本
|
|
112
|
+
|
|
113
|
+
## 开发
|
|
114
|
+
|
|
115
|
+
### 本地开发安装
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
# 克隆仓库
|
|
119
|
+
git clone https://gitlab.com/pixelarrayai/general_pythondevutils_lib.git
|
|
120
|
+
cd general_pythondevutils_lib
|
|
121
|
+
|
|
122
|
+
# 安装开发依赖
|
|
123
|
+
pip install -e .
|
|
124
|
+
|
|
125
|
+
# 测试命令行工具
|
|
126
|
+
pixelarraylib --help
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
### 添加新的命令行工具
|
|
130
|
+
|
|
131
|
+
1. 在 `arraylib/scripts/` 目录下创建新的脚本文件
|
|
132
|
+
2. 在 `arraylib/__main__.py` 中添加新的命令选项
|
|
133
|
+
3. 更新 `arraylib/scripts/__init__.py` 导出新功能
|
|
134
|
+
|
|
135
|
+
## 许可证
|
|
136
|
+
|
|
137
|
+
MIT License
|
|
138
|
+
|
|
139
|
+
## 作者
|
|
140
|
+
|
|
141
|
+
Lu qi (qi.lu@pixelarrayai.com)
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# PixelArrayLib - PixelArray Python开发工具库
|
|
2
|
+
|
|
3
|
+
PixelArrayLib是一个功能丰富的Python开发工具库,包含阿里云服务、数据库工具、装饰器、监控等功能,同时提供便捷的命令行工具。
|
|
4
|
+
|
|
5
|
+
## 安装
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pip install pixelarraylib
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## 使用方法
|
|
12
|
+
|
|
13
|
+
### 1. Python程序中使用
|
|
14
|
+
|
|
15
|
+
```python
|
|
16
|
+
# 导入pixelarraylib模块
|
|
17
|
+
import arraylib
|
|
18
|
+
|
|
19
|
+
# 使用各种功能模块
|
|
20
|
+
from arraylib.aliyun import some_service
|
|
21
|
+
from arraylib.db_utils import database_tools
|
|
22
|
+
from arraylib.decorators import useful_decorators
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### 2. 命令行工具使用
|
|
26
|
+
|
|
27
|
+
安装后,你可以在命令行中直接使用 `pixelarraylib` 命令:
|
|
28
|
+
|
|
29
|
+
#### 创建测试用例文件
|
|
30
|
+
```bash
|
|
31
|
+
# 一键创建所有测试用例文件
|
|
32
|
+
pixelarraylib create_test_case_files
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
#### 代码提交统计
|
|
36
|
+
```bash
|
|
37
|
+
# 统计最近30天的代码提交
|
|
38
|
+
pixelarraylib summary_code_count
|
|
39
|
+
|
|
40
|
+
# 统计指定日期范围的提交
|
|
41
|
+
pixelarraylib summary_code_count --since="2025-05-09"
|
|
42
|
+
|
|
43
|
+
# 统计特定作者的提交
|
|
44
|
+
pixelarraylib summary_code_count --author="张三"
|
|
45
|
+
|
|
46
|
+
# 输出到CSV文件
|
|
47
|
+
pixelarraylib summary_code_count --output=stats.csv
|
|
48
|
+
|
|
49
|
+
# 只统计特定文件类型
|
|
50
|
+
pixelarraylib summary_code_count --file-types="py,js,vue"
|
|
51
|
+
|
|
52
|
+
# 查看帮助信息
|
|
53
|
+
pixelarraylib summary_code_count --help
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## 功能特性
|
|
57
|
+
|
|
58
|
+
- **阿里云服务集成**: 包含CMS、Green、DM、FC、SMS、STS等服务
|
|
59
|
+
- **数据库工具**: MySQL、Redis等数据库操作工具
|
|
60
|
+
- **Web框架**: FastAPI集成
|
|
61
|
+
- **实用工具**: 二维码生成、加密解密、XML处理等
|
|
62
|
+
- **命令行工具**: 测试用例生成、代码统计等实用脚本
|
|
63
|
+
|
|
64
|
+
## 开发
|
|
65
|
+
|
|
66
|
+
### 本地开发安装
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
# 克隆仓库
|
|
70
|
+
git clone https://gitlab.com/pixelarrayai/general_pythondevutils_lib.git
|
|
71
|
+
cd general_pythondevutils_lib
|
|
72
|
+
|
|
73
|
+
# 安装开发依赖
|
|
74
|
+
pip install -e .
|
|
75
|
+
|
|
76
|
+
# 测试命令行工具
|
|
77
|
+
pixelarraylib --help
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### 添加新的命令行工具
|
|
81
|
+
|
|
82
|
+
1. 在 `arraylib/scripts/` 目录下创建新的脚本文件
|
|
83
|
+
2. 在 `arraylib/__main__.py` 中添加新的命令选项
|
|
84
|
+
3. 更新 `arraylib/scripts/__init__.py` 导出新功能
|
|
85
|
+
|
|
86
|
+
## 许可证
|
|
87
|
+
|
|
88
|
+
MIT License
|
|
89
|
+
|
|
90
|
+
## 作者
|
|
91
|
+
|
|
92
|
+
Lu qi (qi.lu@pixelarrayai.com)
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
# -*- coding: utf-8 -*-
|
|
3
|
+
|
|
4
|
+
"""
|
|
5
|
+
PixelArray Python开发工具库
|
|
6
|
+
|
|
7
|
+
这个库包含了常用的开发工具和服务集成:
|
|
8
|
+
- aliyun: 阿里云服务集成 (STS, SMS, OSS, FC, Email, ECS, 内容扫描等)
|
|
9
|
+
- db_utils: 数据库工具 (Redis, MySQL)
|
|
10
|
+
- decorators: 装饰器工具
|
|
11
|
+
- gitlab: GitLab工具 (PyPI包管理)
|
|
12
|
+
- monitor: 监控工具 (飞书通知)
|
|
13
|
+
- net: 网络请求工具
|
|
14
|
+
- system: 系统工具
|
|
15
|
+
|
|
16
|
+
使用示例:
|
|
17
|
+
from arraylib.aliyun import oss
|
|
18
|
+
from arraylib.db_utils import mysql
|
|
19
|
+
from arraylib.decorators import decorators
|
|
20
|
+
from arraylib.gitlab import pypi_package_manager
|
|
21
|
+
"""
|
|
22
|
+
|
|
23
|
+
__version__ = "1.0.0"
|
|
24
|
+
__author__ = "PixelArray"
|
|
25
|
+
__email__ = "qi.lu@pixelarrayai.com"
|
|
26
|
+
|
|
27
|
+
# 导出主要模块
|
|
28
|
+
__all__ = [
|
|
29
|
+
'aliyun',
|
|
30
|
+
'db_utils',
|
|
31
|
+
'decorators',
|
|
32
|
+
'gitlab',
|
|
33
|
+
'monitor',
|
|
34
|
+
'net',
|
|
35
|
+
'system',
|
|
36
|
+
]
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
ArrayLib 命令行工具入口点
|
|
4
|
+
支持的命令:
|
|
5
|
+
- arraylib create_test_case_files
|
|
6
|
+
- arraylib summary_code_count [options]
|
|
7
|
+
- arraylib collect_code_to_txt [options]
|
|
8
|
+
- arraylib nginx_proxy_to_ecs [options]
|
|
9
|
+
- arraylib remove_empty_lines <input_file> [output_file]
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
import sys
|
|
13
|
+
import argparse
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def main():
|
|
17
|
+
# 检查是否有子命令
|
|
18
|
+
if len(sys.argv) < 2:
|
|
19
|
+
parser = argparse.ArgumentParser(
|
|
20
|
+
description="ArrayLib 命令行工具",
|
|
21
|
+
formatter_class=argparse.RawDescriptionHelpFormatter,
|
|
22
|
+
epilog="""
|
|
23
|
+
示例用法:
|
|
24
|
+
arraylib create_test_case_files --help # 创建测试用例文件
|
|
25
|
+
arraylib summary_code_count --help # 查看统计工具帮助
|
|
26
|
+
arraylib collect_code_to_txt --help # 查看收集工具帮助
|
|
27
|
+
arraylib nginx_proxy_to_ecs --help # 查看Nginx反向代理到ECS工具帮助
|
|
28
|
+
arraylib remove_empty_lines --help # 查看去除空行工具帮助
|
|
29
|
+
""",
|
|
30
|
+
)
|
|
31
|
+
parser.print_help()
|
|
32
|
+
sys.exit(1)
|
|
33
|
+
|
|
34
|
+
command = sys.argv[1]
|
|
35
|
+
|
|
36
|
+
if command == "create_test_case_files":
|
|
37
|
+
# 导入并执行创建测试用例文件功能
|
|
38
|
+
try:
|
|
39
|
+
from arraylib.scripts.create_test_case_files import main as create_test_main
|
|
40
|
+
|
|
41
|
+
create_test_main()
|
|
42
|
+
except ImportError as e:
|
|
43
|
+
print(f"错误:无法导入 create_test_case_files 模块: {e}")
|
|
44
|
+
sys.exit(1)
|
|
45
|
+
|
|
46
|
+
elif command == "summary_code_count":
|
|
47
|
+
# 导入并执行代码统计功能
|
|
48
|
+
try:
|
|
49
|
+
from arraylib.scripts.summary_code_count import main as summary_main
|
|
50
|
+
|
|
51
|
+
# 修改sys.argv,移除第一个参数(arraylib),让summary_code_count正确处理参数
|
|
52
|
+
original_argv = sys.argv
|
|
53
|
+
sys.argv = [original_argv[0]] + original_argv[2:]
|
|
54
|
+
summary_main()
|
|
55
|
+
sys.argv = original_argv
|
|
56
|
+
except ImportError as e:
|
|
57
|
+
print(f"错误:无法导入 summary_code_count 模块: {e}")
|
|
58
|
+
sys.exit(1)
|
|
59
|
+
|
|
60
|
+
elif command == "collect_code_to_txt":
|
|
61
|
+
# 导入并执行代码收集功能
|
|
62
|
+
try:
|
|
63
|
+
from arraylib.scripts.collect_code_to_txt import main as collect_main
|
|
64
|
+
|
|
65
|
+
# 修改sys.argv,移除第一个参数(arraylib),让collect_code_to_txt正确处理参数
|
|
66
|
+
original_argv = sys.argv
|
|
67
|
+
sys.argv = [original_argv[0]] + original_argv[2:]
|
|
68
|
+
collect_main()
|
|
69
|
+
sys.argv = original_argv
|
|
70
|
+
except ImportError as e:
|
|
71
|
+
print(f"错误:无法导入 collect_code_to_txt 模块: {e}")
|
|
72
|
+
sys.exit(1)
|
|
73
|
+
|
|
74
|
+
elif command == "nginx_proxy_to_ecs":
|
|
75
|
+
# 导入并执行Nginx反向代理到ECS功能
|
|
76
|
+
try:
|
|
77
|
+
from arraylib.scripts.nginx_proxy_to_ecs import main as nginx_proxy_to_ecs
|
|
78
|
+
|
|
79
|
+
# 修改sys.argv,移除第一个参数(arraylib),让nginx_proxy_to_ecs正确处理参数
|
|
80
|
+
original_argv = sys.argv
|
|
81
|
+
sys.argv = [original_argv[0]] + original_argv[2:]
|
|
82
|
+
nginx_proxy_to_ecs()
|
|
83
|
+
sys.argv = original_argv
|
|
84
|
+
except ImportError as e:
|
|
85
|
+
print(f"错误:无法导入 nginx_proxy_to_ecs 模块: {e}")
|
|
86
|
+
sys.exit(1)
|
|
87
|
+
|
|
88
|
+
elif command == "remove_empty_lines":
|
|
89
|
+
# 导入并执行去除空行功能
|
|
90
|
+
try:
|
|
91
|
+
from arraylib.scripts.remove_empty_lines import main as remove_empty_lines_main
|
|
92
|
+
|
|
93
|
+
# 修改sys.argv,移除第一个参数(arraylib),让remove_empty_lines正确处理参数
|
|
94
|
+
original_argv = sys.argv
|
|
95
|
+
sys.argv = [original_argv[0]] + original_argv[2:]
|
|
96
|
+
remove_empty_lines_main()
|
|
97
|
+
sys.argv = original_argv
|
|
98
|
+
except ImportError as e:
|
|
99
|
+
print(f"错误:无法导入 remove_empty_lines 模块: {e}")
|
|
100
|
+
sys.exit(1)
|
|
101
|
+
|
|
102
|
+
elif command in ["-h", "--help"]:
|
|
103
|
+
parser = argparse.ArgumentParser(
|
|
104
|
+
description="ArrayLib 命令行工具",
|
|
105
|
+
formatter_class=argparse.RawDescriptionHelpFormatter,
|
|
106
|
+
epilog="""
|
|
107
|
+
示例用法:
|
|
108
|
+
arraylib create_test_case_files --help # 创建测试用例文件
|
|
109
|
+
arraylib summary_code_count --help # 查看统计工具帮助
|
|
110
|
+
arraylib collect_code_to_txt --help # 查看收集工具帮助
|
|
111
|
+
arraylib nginx_proxy_to_ecs --help # 查看Nginx反向代理到ECS工具帮助
|
|
112
|
+
arraylib remove_empty_lines --help # 查看去除空行工具帮助
|
|
113
|
+
""",
|
|
114
|
+
)
|
|
115
|
+
parser.print_help()
|
|
116
|
+
else:
|
|
117
|
+
print(f"错误:未知命令 '{command}'")
|
|
118
|
+
print(
|
|
119
|
+
"可用命令:create_test_case_files, summary_code_count, collect_code_to_txt, nginx_proxy_to_ecs, remove_empty_lines"
|
|
120
|
+
)
|
|
121
|
+
print("使用 'arraylib --help' 查看帮助")
|
|
122
|
+
sys.exit(1)
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
if __name__ == "__main__":
|
|
126
|
+
main()
|
|
File without changes
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import time
|
|
3
|
+
import random
|
|
4
|
+
import traceback
|
|
5
|
+
from alibabacloud_dm20151123.client import Client as Dm20151123Client
|
|
6
|
+
from alibabacloud_tea_openapi import models as open_api_models
|
|
7
|
+
from alibabacloud_dm20151123 import models as dm_20151123_models
|
|
8
|
+
from alibabacloud_tea_util import models as util_models
|
|
9
|
+
from arraylib.monitor.feishu import Feishu
|
|
10
|
+
|
|
11
|
+
feishu_alert = Feishu("devtoolkit服务报警")
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class AliyunEmailSender:
|
|
15
|
+
def __init__(self, access_key_id, access_key_secret):
|
|
16
|
+
self.client = Dm20151123Client(
|
|
17
|
+
open_api_models.Config(
|
|
18
|
+
access_key_id=access_key_id,
|
|
19
|
+
access_key_secret=access_key_secret,
|
|
20
|
+
endpoint="dm.aliyuncs.com",
|
|
21
|
+
)
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
def generate_verification_code(self, length=6):
|
|
25
|
+
"""
|
|
26
|
+
description:
|
|
27
|
+
生成数字验证码
|
|
28
|
+
parameters:
|
|
29
|
+
length(int): 验证码长度
|
|
30
|
+
return:
|
|
31
|
+
str: 验证码
|
|
32
|
+
"""
|
|
33
|
+
return "".join(str(random.randint(0, 9)) for _ in range(length))
|
|
34
|
+
|
|
35
|
+
def create_verification_email_content(
|
|
36
|
+
self, username, verification_code, email_type, validity=15
|
|
37
|
+
):
|
|
38
|
+
"""
|
|
39
|
+
description:
|
|
40
|
+
创建邮件HTML内容
|
|
41
|
+
parameters:
|
|
42
|
+
username(str): 用户名
|
|
43
|
+
validity(int): 验证码有效期
|
|
44
|
+
return:
|
|
45
|
+
str: 邮件HTML内容
|
|
46
|
+
"""
|
|
47
|
+
email_type_str = "注册" if email_type == "register" else "找回密码"
|
|
48
|
+
return f"""
|
|
49
|
+
<html>
|
|
50
|
+
<head>
|
|
51
|
+
<style>
|
|
52
|
+
body {{ font-family: Arial, sans-serif; line-height: 1.6; }}
|
|
53
|
+
.container {{ max-width: 600px; margin: 0 auto; padding: 20px; border: 1px solid #e1e8f7; border-radius: 10px; }}
|
|
54
|
+
.header {{ background: linear-gradient(to right, #1a2980, #26d0ce); color: white; padding: 15px; text-align: center; border-radius: 8px; }}
|
|
55
|
+
.code {{ font-size: 28px; font-weight: bold; text-align: center; margin: 25px 0; letter-spacing: 5px; color: #e74c3c; }}
|
|
56
|
+
.footer {{ margin-top: 30px; text-align: center; color: #777; font-size: 12px; }}
|
|
57
|
+
</style>
|
|
58
|
+
</head>
|
|
59
|
+
<body>
|
|
60
|
+
<div class="container">
|
|
61
|
+
<div class="header">
|
|
62
|
+
<h2>北京矩阵像素科技有限公司</h2>
|
|
63
|
+
</div>
|
|
64
|
+
|
|
65
|
+
<p>尊敬的 <strong>{username}</strong>:</p>
|
|
66
|
+
<p>您正在进行邮箱{email_type_str}验证,您的验证码为:</p>
|
|
67
|
+
<div class="code">{verification_code}</div>
|
|
68
|
+
<p>该验证码 <strong>{validity}分钟</strong> 内有效,请尽快完成验证。</p>
|
|
69
|
+
<p>如非本人操作,请忽略此邮件。</p>
|
|
70
|
+
|
|
71
|
+
<div class="footer">
|
|
72
|
+
<p>阿里云邮件推送服务 | 安全验证</p>
|
|
73
|
+
<p>© {time.strftime('%Y')} 企业注册系统 版权所有</p>
|
|
74
|
+
</div>
|
|
75
|
+
</div>
|
|
76
|
+
</body>
|
|
77
|
+
</html>
|
|
78
|
+
"""
|
|
79
|
+
|
|
80
|
+
def get_email_subject(self, email_type):
|
|
81
|
+
if email_type == "register":
|
|
82
|
+
return "您的注册验证码"
|
|
83
|
+
elif email_type == "forgot":
|
|
84
|
+
return "您的找回密码验证码"
|
|
85
|
+
else:
|
|
86
|
+
return "您的验证码"
|
|
87
|
+
|
|
88
|
+
def send_verification_email(
|
|
89
|
+
self, to_address, verification_code, email_type, username="用户"
|
|
90
|
+
):
|
|
91
|
+
"""
|
|
92
|
+
description:
|
|
93
|
+
发送验证邮件
|
|
94
|
+
parameters:
|
|
95
|
+
to_address(str): 收件人邮箱地址
|
|
96
|
+
email_type(str): 邮件类型
|
|
97
|
+
username(str): 用户名
|
|
98
|
+
return:
|
|
99
|
+
dict: 发送结果
|
|
100
|
+
"""
|
|
101
|
+
assert email_type in [
|
|
102
|
+
"register",
|
|
103
|
+
"forgot",
|
|
104
|
+
], "邮件类型错误,当前只有register和forgot两种类型"
|
|
105
|
+
try:
|
|
106
|
+
response = self.client.single_send_mail_with_options(
|
|
107
|
+
dm_20151123_models.SingleSendMailRequest(
|
|
108
|
+
account_name="captcha_new@captcha.pixelarrayai.com",
|
|
109
|
+
address_type=1,
|
|
110
|
+
to_address=to_address,
|
|
111
|
+
subject=self.get_email_subject(email_type),
|
|
112
|
+
html_body=self.create_verification_email_content(
|
|
113
|
+
username=username,
|
|
114
|
+
verification_code=verification_code,
|
|
115
|
+
email_type=email_type,
|
|
116
|
+
),
|
|
117
|
+
reply_to_address=False,
|
|
118
|
+
from_alias="系统验证", # 发信人昵称
|
|
119
|
+
),
|
|
120
|
+
util_models.RuntimeOptions(),
|
|
121
|
+
)
|
|
122
|
+
if response.status_code == 200:
|
|
123
|
+
return True
|
|
124
|
+
else:
|
|
125
|
+
feishu_alert.send(f"发送验证邮件失败: {response}")
|
|
126
|
+
return False
|
|
127
|
+
|
|
128
|
+
except Exception as e:
|
|
129
|
+
feishu_alert.send(traceback.format_exc())
|
|
130
|
+
return False
|