pixelarraylib 1.1.4__tar.gz → 1.1.6__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.1.4/pixelarraylib.egg-info → pixelarraylib-1.1.6}/PKG-INFO +35 -33
- {pixelarraylib-1.1.4 → pixelarraylib-1.1.6}/README.md +8 -7
- {pixelarraylib-1.1.4 → pixelarraylib-1.1.6}/pixelarraylib/__init__.py +1 -1
- {pixelarraylib-1.1.4 → pixelarraylib-1.1.6}/pixelarraylib/__main__.py +4 -0
- {pixelarraylib-1.1.4 → pixelarraylib-1.1.6}/pixelarraylib/aliyun/acr.py +14 -0
- {pixelarraylib-1.1.4 → pixelarraylib-1.1.6}/pixelarraylib/aliyun/aliyun_email.py +7 -0
- {pixelarraylib-1.1.4 → pixelarraylib-1.1.6}/pixelarraylib/aliyun/billing.py +17 -1
- {pixelarraylib-1.1.4 → pixelarraylib-1.1.6}/pixelarraylib/aliyun/content_scanner.py +8 -0
- {pixelarraylib-1.1.4 → pixelarraylib-1.1.6}/pixelarraylib/aliyun/domain.py +17 -0
- {pixelarraylib-1.1.4 → pixelarraylib-1.1.6}/pixelarraylib/aliyun/ecs.py +8 -0
- {pixelarraylib-1.1.4 → pixelarraylib-1.1.6}/pixelarraylib/aliyun/eip.py +14 -0
- {pixelarraylib-1.1.4 → pixelarraylib-1.1.6}/pixelarraylib/aliyun/fc.py +31 -0
- {pixelarraylib-1.1.4 → pixelarraylib-1.1.6}/pixelarraylib/aliyun/oss.py +10 -0
- {pixelarraylib-1.1.4 → pixelarraylib-1.1.6}/pixelarraylib/aliyun/sms.py +17 -3
- {pixelarraylib-1.1.4 → pixelarraylib-1.1.6}/pixelarraylib/aliyun/sts.py +11 -0
- {pixelarraylib-1.1.4 → pixelarraylib-1.1.6}/pixelarraylib/db_utils/mysql.py +96 -14
- {pixelarraylib-1.1.4 → pixelarraylib-1.1.6}/pixelarraylib/db_utils/redis.py +29 -1
- {pixelarraylib-1.1.4 → pixelarraylib-1.1.6}/pixelarraylib/decorators/decorators.py +97 -0
- {pixelarraylib-1.1.4 → pixelarraylib-1.1.6}/pixelarraylib/gitlab/code_analyzer.py +31 -4
- {pixelarraylib-1.1.4 → pixelarraylib-1.1.6}/pixelarraylib/gitlab/pypi_package_manager.py +8 -0
- {pixelarraylib-1.1.4 → pixelarraylib-1.1.6}/pixelarraylib/monitor/feishu.py +8 -0
- {pixelarraylib-1.1.4 → pixelarraylib-1.1.6}/pixelarraylib/net/request.py +32 -0
- {pixelarraylib-1.1.4 → pixelarraylib-1.1.6}/pixelarraylib/scripts/__init__.py +1 -1
- {pixelarraylib-1.1.4 → pixelarraylib-1.1.6}/pixelarraylib/scripts/build_website.py +34 -0
- {pixelarraylib-1.1.4 → pixelarraylib-1.1.6}/pixelarraylib/scripts/collect_code_to_txt.py +96 -10
- {pixelarraylib-1.1.4 → pixelarraylib-1.1.6}/pixelarraylib/scripts/create_test_case_files.py +12 -0
- {pixelarraylib-1.1.4 → pixelarraylib-1.1.6}/pixelarraylib/scripts/nginx_proxy_to_ecs.py +33 -0
- {pixelarraylib-1.1.4 → pixelarraylib-1.1.6}/pixelarraylib/scripts/remove_empty_lines.py +4 -1
- {pixelarraylib-1.1.4 → pixelarraylib-1.1.6}/pixelarraylib/system/tson.py +4 -0
- {pixelarraylib-1.1.4 → pixelarraylib-1.1.6/pixelarraylib.egg-info}/PKG-INFO +35 -33
- {pixelarraylib-1.1.4 → pixelarraylib-1.1.6}/pixelarraylib.egg-info/requires.txt +27 -25
- {pixelarraylib-1.1.4 → pixelarraylib-1.1.6}/pyproject.toml +29 -26
- {pixelarraylib-1.1.4 → pixelarraylib-1.1.6}/LICENSE +0 -0
- {pixelarraylib-1.1.4 → pixelarraylib-1.1.6}/MANIFEST.in +0 -0
- {pixelarraylib-1.1.4 → pixelarraylib-1.1.6}/pixelarraylib/aliyun/__init__.py +0 -0
- {pixelarraylib-1.1.4 → pixelarraylib-1.1.6}/pixelarraylib/aliyun/eci.py +0 -0
- {pixelarraylib-1.1.4 → pixelarraylib-1.1.6}/pixelarraylib/decorators/__init__.py +0 -0
- {pixelarraylib-1.1.4 → pixelarraylib-1.1.6}/pixelarraylib/gitlab/__init__.py +0 -0
- {pixelarraylib-1.1.4 → pixelarraylib-1.1.6}/pixelarraylib/monitor/__init__.py +0 -0
- {pixelarraylib-1.1.4 → pixelarraylib-1.1.6}/pixelarraylib/scripts/tson_convert.py +0 -0
- {pixelarraylib-1.1.4 → pixelarraylib-1.1.6}/pixelarraylib/system/__init__.py +0 -0
- {pixelarraylib-1.1.4 → pixelarraylib-1.1.6}/pixelarraylib/system/common.py +0 -0
- {pixelarraylib-1.1.4 → pixelarraylib-1.1.6}/pixelarraylib.egg-info/SOURCES.txt +0 -0
- {pixelarraylib-1.1.4 → pixelarraylib-1.1.6}/pixelarraylib.egg-info/dependency_links.txt +0 -0
- {pixelarraylib-1.1.4 → pixelarraylib-1.1.6}/pixelarraylib.egg-info/entry_points.txt +0 -0
- {pixelarraylib-1.1.4 → pixelarraylib-1.1.6}/pixelarraylib.egg-info/top_level.txt +0 -0
- {pixelarraylib-1.1.4 → pixelarraylib-1.1.6}/requirements.txt +0 -0
- {pixelarraylib-1.1.4 → pixelarraylib-1.1.6}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pixelarraylib
|
|
3
|
-
Version: 1.1.
|
|
3
|
+
Version: 1.1.6
|
|
4
4
|
Summary: PixelArray Python开发工具库 - 包含阿里云服务、数据库工具、装饰器、监控等功能
|
|
5
5
|
Author-email: Lu qi <qi.lu@pixelarrayai.com>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -23,31 +23,6 @@ Classifier: Topic :: Utilities
|
|
|
23
23
|
Requires-Python: >=3.8
|
|
24
24
|
Description-Content-Type: text/markdown
|
|
25
25
|
License-File: LICENSE
|
|
26
|
-
Requires-Dist: alibabacloud_tea_util
|
|
27
|
-
Requires-Dist: alibabacloud_cms20190101
|
|
28
|
-
Requires-Dist: alibabacloud_green20220302
|
|
29
|
-
Requires-Dist: alibabacloud_dm20151123
|
|
30
|
-
Requires-Dist: alibabacloud_fc20230330
|
|
31
|
-
Requires-Dist: alibabacloud_darabonba_stream
|
|
32
|
-
Requires-Dist: alibabacloud_dysmsapi20170525
|
|
33
|
-
Requires-Dist: alibabacloud_sts20150401
|
|
34
|
-
Requires-Dist: alibabacloud_alidns20150109
|
|
35
|
-
Requires-Dist: alibabacloud_eci20180808
|
|
36
|
-
Requires-Dist: alibabacloud_bssopenapi20171214
|
|
37
|
-
Requires-Dist: alibabacloud_cr20181201
|
|
38
|
-
Requires-Dist: alibabacloud_vpc20160428
|
|
39
|
-
Requires-Dist: alibabacloud_tea_openapi
|
|
40
|
-
Requires-Dist: alibabacloud_credentials
|
|
41
|
-
Requires-Dist: oss2
|
|
42
|
-
Requires-Dist: pymysql
|
|
43
|
-
Requires-Dist: aiomysql
|
|
44
|
-
Requires-Dist: redis
|
|
45
|
-
Requires-Dist: cryptography
|
|
46
|
-
Requires-Dist: paramiko
|
|
47
|
-
Requires-Dist: requests
|
|
48
|
-
Requires-Dist: aiohttp
|
|
49
|
-
Requires-Dist: aiofiles
|
|
50
|
-
Requires-Dist: pandas
|
|
51
26
|
Provides-Extra: monitor
|
|
52
27
|
Requires-Dist: requests; extra == "monitor"
|
|
53
28
|
Provides-Extra: system
|
|
@@ -160,6 +135,32 @@ Requires-Dist: cryptography; extra == "aliyun"
|
|
|
160
135
|
Requires-Dist: paramiko; extra == "aliyun"
|
|
161
136
|
Requires-Dist: redis; extra == "aliyun"
|
|
162
137
|
Requires-Dist: pandas; extra == "aliyun"
|
|
138
|
+
Provides-Extra: all
|
|
139
|
+
Requires-Dist: alibabacloud_tea_util; extra == "all"
|
|
140
|
+
Requires-Dist: alibabacloud_cms20190101; extra == "all"
|
|
141
|
+
Requires-Dist: alibabacloud_green20220302; extra == "all"
|
|
142
|
+
Requires-Dist: alibabacloud_dm20151123; extra == "all"
|
|
143
|
+
Requires-Dist: alibabacloud_fc20230330; extra == "all"
|
|
144
|
+
Requires-Dist: alibabacloud_darabonba_stream; extra == "all"
|
|
145
|
+
Requires-Dist: alibabacloud_dysmsapi20170525; extra == "all"
|
|
146
|
+
Requires-Dist: alibabacloud_sts20150401; extra == "all"
|
|
147
|
+
Requires-Dist: alibabacloud_alidns20150109; extra == "all"
|
|
148
|
+
Requires-Dist: alibabacloud_eci20180808; extra == "all"
|
|
149
|
+
Requires-Dist: alibabacloud_bssopenapi20171214; extra == "all"
|
|
150
|
+
Requires-Dist: alibabacloud_cr20181201; extra == "all"
|
|
151
|
+
Requires-Dist: alibabacloud_vpc20160428; extra == "all"
|
|
152
|
+
Requires-Dist: alibabacloud_tea_openapi; extra == "all"
|
|
153
|
+
Requires-Dist: alibabacloud_credentials; extra == "all"
|
|
154
|
+
Requires-Dist: oss2; extra == "all"
|
|
155
|
+
Requires-Dist: pymysql; extra == "all"
|
|
156
|
+
Requires-Dist: aiomysql; extra == "all"
|
|
157
|
+
Requires-Dist: redis; extra == "all"
|
|
158
|
+
Requires-Dist: cryptography; extra == "all"
|
|
159
|
+
Requires-Dist: paramiko; extra == "all"
|
|
160
|
+
Requires-Dist: requests; extra == "all"
|
|
161
|
+
Requires-Dist: aiohttp; extra == "all"
|
|
162
|
+
Requires-Dist: aiofiles; extra == "all"
|
|
163
|
+
Requires-Dist: pandas; extra == "all"
|
|
163
164
|
Dynamic: license-file
|
|
164
165
|
|
|
165
166
|
# PixelArrayLib - PixelArray Python开发工具库
|
|
@@ -174,7 +175,14 @@ PixelArrayLib是一个功能丰富的Python开发工具库,包含阿里云服
|
|
|
174
175
|
pip install pixelarraylib
|
|
175
176
|
```
|
|
176
177
|
|
|
177
|
-
**注意**:
|
|
178
|
+
**注意**: 基础安装不包含任何依赖,只安装核心包。使用功能模块前需要安装相应的依赖。
|
|
179
|
+
|
|
180
|
+
### 安装所有依赖
|
|
181
|
+
|
|
182
|
+
```bash
|
|
183
|
+
# 安装所有依赖(推荐,适合需要使用多个模块的场景)
|
|
184
|
+
pip install pixelarraylib[all]
|
|
185
|
+
```
|
|
178
186
|
|
|
179
187
|
### 可选依赖安装
|
|
180
188
|
|
|
@@ -251,12 +259,6 @@ pip install pixelarraylib[aliyun]
|
|
|
251
259
|
pip install pixelarraylib[aliyun-oss,aliyun-sms]
|
|
252
260
|
```
|
|
253
261
|
|
|
254
|
-
#### 完整安装
|
|
255
|
-
|
|
256
|
-
```bash
|
|
257
|
-
# 安装所有可选依赖
|
|
258
|
-
pip install pixelarraylib[all]
|
|
259
|
-
```
|
|
260
262
|
|
|
261
263
|
**可选依赖说明:**
|
|
262
264
|
|
|
@@ -10,7 +10,14 @@ PixelArrayLib是一个功能丰富的Python开发工具库,包含阿里云服
|
|
|
10
10
|
pip install pixelarraylib
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
-
**注意**:
|
|
13
|
+
**注意**: 基础安装不包含任何依赖,只安装核心包。使用功能模块前需要安装相应的依赖。
|
|
14
|
+
|
|
15
|
+
### 安装所有依赖
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
# 安装所有依赖(推荐,适合需要使用多个模块的场景)
|
|
19
|
+
pip install pixelarraylib[all]
|
|
20
|
+
```
|
|
14
21
|
|
|
15
22
|
### 可选依赖安装
|
|
16
23
|
|
|
@@ -87,12 +94,6 @@ pip install pixelarraylib[aliyun]
|
|
|
87
94
|
pip install pixelarraylib[aliyun-oss,aliyun-sms]
|
|
88
95
|
```
|
|
89
96
|
|
|
90
|
-
#### 完整安装
|
|
91
|
-
|
|
92
|
-
```bash
|
|
93
|
-
# 安装所有可选依赖
|
|
94
|
-
pip install pixelarraylib[all]
|
|
95
|
-
```
|
|
96
97
|
|
|
97
98
|
**可选依赖说明:**
|
|
98
99
|
|
|
@@ -18,12 +18,26 @@ feishu_alert = Feishu("devtoolkit服务报警")
|
|
|
18
18
|
|
|
19
19
|
class ACRUtils:
|
|
20
20
|
def __init__(self, region_id: str, access_key_id: str, access_key_secret: str):
|
|
21
|
+
"""
|
|
22
|
+
description:
|
|
23
|
+
初始化ACR(容器镜像服务)工具类
|
|
24
|
+
parameters:
|
|
25
|
+
region_id(str): 阿里云区域ID
|
|
26
|
+
access_key_id(str): 阿里云访问密钥ID
|
|
27
|
+
access_key_secret(str): 阿里云访问密钥Secret
|
|
28
|
+
"""
|
|
21
29
|
self.region_id = region_id
|
|
22
30
|
self.access_key_id = access_key_id
|
|
23
31
|
self.access_key_secret = access_key_secret
|
|
24
32
|
self.client = self._create_client()
|
|
25
33
|
|
|
26
34
|
def _create_client(self):
|
|
35
|
+
"""
|
|
36
|
+
description:
|
|
37
|
+
创建ACR客户端
|
|
38
|
+
return:
|
|
39
|
+
client(cr20181201Client): ACR客户端对象
|
|
40
|
+
"""
|
|
27
41
|
credential = CredentialClient()
|
|
28
42
|
config = open_api_models.Config(
|
|
29
43
|
credential=credential,
|
|
@@ -14,6 +14,13 @@ feishu_alert = Feishu("devtoolkit服务报警")
|
|
|
14
14
|
|
|
15
15
|
class AliyunEmailSender:
|
|
16
16
|
def __init__(self, access_key_id, access_key_secret):
|
|
17
|
+
"""
|
|
18
|
+
description:
|
|
19
|
+
初始化阿里云邮件发送工具类
|
|
20
|
+
parameters:
|
|
21
|
+
access_key_id(str): 阿里云访问密钥ID
|
|
22
|
+
access_key_secret(str): 阿里云访问密钥Secret
|
|
23
|
+
"""
|
|
17
24
|
self.client = Dm20151123Client(
|
|
18
25
|
open_api_models.Config(
|
|
19
26
|
access_key_id=access_key_id,
|
|
@@ -87,7 +87,15 @@ class BillingUtils:
|
|
|
87
87
|
}
|
|
88
88
|
|
|
89
89
|
def add_comment(value, field_name):
|
|
90
|
-
"""
|
|
90
|
+
"""
|
|
91
|
+
description:
|
|
92
|
+
为字段值添加注释
|
|
93
|
+
parameters:
|
|
94
|
+
value(Any): 字段值
|
|
95
|
+
field_name(str): 字段名称
|
|
96
|
+
return:
|
|
97
|
+
value_with_comment(str): 带注释的字段值
|
|
98
|
+
"""
|
|
91
99
|
if with_comments and field_name in field_comments:
|
|
92
100
|
return f"{value} # {field_comments[field_name]}"
|
|
93
101
|
return value
|
|
@@ -391,6 +399,14 @@ class BillingUtils:
|
|
|
391
399
|
# 2) 去除首尾空白,并将内部连续空白压缩为一个空格
|
|
392
400
|
# 3) 去除常见的不可见空白字符(如不间断空格、零宽空格)
|
|
393
401
|
def _clean_string(value):
|
|
402
|
+
"""
|
|
403
|
+
description:
|
|
404
|
+
清洗字符串,去除注释、不可见字符并规范化空白
|
|
405
|
+
parameters:
|
|
406
|
+
value(Any): 需要清洗的值
|
|
407
|
+
return:
|
|
408
|
+
cleaned_value(Any): 清洗后的值
|
|
409
|
+
"""
|
|
394
410
|
if not isinstance(value, str):
|
|
395
411
|
return value
|
|
396
412
|
# 去注释
|
|
@@ -18,6 +18,14 @@ feishu_alert = Feishu("devtoolkit服务报警")
|
|
|
18
18
|
|
|
19
19
|
class ContentScanner:
|
|
20
20
|
def __init__(self, access_key_id, access_key_secret, region_id):
|
|
21
|
+
"""
|
|
22
|
+
description:
|
|
23
|
+
初始化内容安全扫描工具类
|
|
24
|
+
parameters:
|
|
25
|
+
access_key_id(str): 阿里云访问密钥ID
|
|
26
|
+
access_key_secret(str): 阿里云访问密钥Secret
|
|
27
|
+
region_id(str): 阿里云区域ID
|
|
28
|
+
"""
|
|
21
29
|
self.client = Client(
|
|
22
30
|
Config(
|
|
23
31
|
access_key_id=access_key_id,
|
|
@@ -7,12 +7,29 @@ from typing import Optional, Dict, Any
|
|
|
7
7
|
|
|
8
8
|
class DomainUtils:
|
|
9
9
|
def __init__(self, access_key_id: str, access_key_secret: str, domain_name: str):
|
|
10
|
+
"""
|
|
11
|
+
description:
|
|
12
|
+
初始化域名服务工具类
|
|
13
|
+
parameters:
|
|
14
|
+
access_key_id(str): 阿里云访问密钥ID
|
|
15
|
+
access_key_secret(str): 阿里云访问密钥Secret
|
|
16
|
+
domain_name(str): 域名名称
|
|
17
|
+
"""
|
|
10
18
|
self.domain_name = domain_name
|
|
11
19
|
self.client = self._create_client(access_key_id, access_key_secret)
|
|
12
20
|
|
|
13
21
|
def _create_client(
|
|
14
22
|
self, access_key_id: str, access_key_secret: str
|
|
15
23
|
) -> Alidns20150109Client:
|
|
24
|
+
"""
|
|
25
|
+
description:
|
|
26
|
+
创建阿里云DNS客户端
|
|
27
|
+
parameters:
|
|
28
|
+
access_key_id(str): 阿里云访问密钥ID
|
|
29
|
+
access_key_secret(str): 阿里云访问密钥Secret
|
|
30
|
+
return:
|
|
31
|
+
client(Alidns20150109Client): DNS客户端对象
|
|
32
|
+
"""
|
|
16
33
|
config = open_api_models.Config(
|
|
17
34
|
access_key_id=access_key_id,
|
|
18
35
|
access_key_secret=access_key_secret,
|
|
@@ -8,6 +8,14 @@ from alibabacloud_tea_util import models as util_models
|
|
|
8
8
|
|
|
9
9
|
class ECSUtils:
|
|
10
10
|
def __init__(self, access_key_id: str, access_key_secret: str, region_id: str):
|
|
11
|
+
"""
|
|
12
|
+
description:
|
|
13
|
+
初始化ECS(弹性计算服务)工具类
|
|
14
|
+
parameters:
|
|
15
|
+
access_key_id(str): 阿里云访问密钥ID
|
|
16
|
+
access_key_secret(str): 阿里云访问密钥Secret
|
|
17
|
+
region_id(str): 阿里云区域ID
|
|
18
|
+
"""
|
|
11
19
|
self.cms_client = Cms20190101Client(
|
|
12
20
|
open_api_models.Config(
|
|
13
21
|
type="access_key",
|
|
@@ -15,12 +15,26 @@ feishu_alert = Feishu("devtoolkit服务报警")
|
|
|
15
15
|
|
|
16
16
|
class EIPUtils:
|
|
17
17
|
def __init__(self, region_id: str, access_key_id: str, access_key_secret: str):
|
|
18
|
+
"""
|
|
19
|
+
description:
|
|
20
|
+
初始化EIP工具类
|
|
21
|
+
parameters:
|
|
22
|
+
region_id(str): 地域ID
|
|
23
|
+
access_key_id(str): 访问密钥ID
|
|
24
|
+
access_key_secret(str): 访问密钥Secret
|
|
25
|
+
"""
|
|
18
26
|
self.region_id = region_id
|
|
19
27
|
self.access_key_id = access_key_id
|
|
20
28
|
self.access_key_secret = access_key_secret
|
|
21
29
|
self.client = self._create_client()
|
|
22
30
|
|
|
23
31
|
def _create_client(self) -> Vpc20160428Client:
|
|
32
|
+
"""
|
|
33
|
+
description:
|
|
34
|
+
创建EIP客户端
|
|
35
|
+
return:
|
|
36
|
+
Vpc20160428Client: EIP客户端实例
|
|
37
|
+
"""
|
|
24
38
|
config = open_api_models.Config(
|
|
25
39
|
access_key_id=self.access_key_id,
|
|
26
40
|
access_key_secret=self.access_key_secret,
|
|
@@ -16,6 +16,15 @@ feishu_alert = Feishu("devtoolkit服务报警")
|
|
|
16
16
|
|
|
17
17
|
class FCUtils:
|
|
18
18
|
def __init__(self, access_key_id, access_key_secret, account_id, region_id):
|
|
19
|
+
"""
|
|
20
|
+
description:
|
|
21
|
+
初始化函数计算(FC)工具类
|
|
22
|
+
parameters:
|
|
23
|
+
access_key_id(str): 阿里云访问密钥ID
|
|
24
|
+
access_key_secret(str): 阿里云访问密钥Secret
|
|
25
|
+
account_id(str): 阿里云账号ID
|
|
26
|
+
region_id(str): 阿里云区域ID
|
|
27
|
+
"""
|
|
19
28
|
self.client = FC20230330Client(
|
|
20
29
|
open_api_models.Config(
|
|
21
30
|
access_key_id=access_key_id,
|
|
@@ -31,6 +40,18 @@ class FCUtils:
|
|
|
31
40
|
retry: int = 5,
|
|
32
41
|
timeout: int = 6000 * 1000,
|
|
33
42
|
) -> tuple[str, bool]:
|
|
43
|
+
"""
|
|
44
|
+
description:
|
|
45
|
+
调用函数计算服务中的函数
|
|
46
|
+
parameters:
|
|
47
|
+
function_name(str): 函数名称
|
|
48
|
+
params(dict): 函数参数
|
|
49
|
+
retry(int): 重试次数,默认为5
|
|
50
|
+
timeout(int): 超时时间(毫秒),默认为6000秒
|
|
51
|
+
return:
|
|
52
|
+
result(str): 函数执行结果
|
|
53
|
+
success(bool): 是否调用成功
|
|
54
|
+
"""
|
|
34
55
|
last_exception = None
|
|
35
56
|
for i in range(retry):
|
|
36
57
|
try:
|
|
@@ -80,6 +101,16 @@ class FCUtils:
|
|
|
80
101
|
dir_path: str,
|
|
81
102
|
retry: int = 5,
|
|
82
103
|
) -> tuple[str, bool]:
|
|
104
|
+
"""
|
|
105
|
+
description:
|
|
106
|
+
更新函数计算服务中的函数代码
|
|
107
|
+
parameters:
|
|
108
|
+
function_name(str): 函数名称
|
|
109
|
+
dir_path(str): 代码目录路径
|
|
110
|
+
retry(int): 重试次数,默认为5
|
|
111
|
+
return:
|
|
112
|
+
success(bool): 是否更新成功
|
|
113
|
+
"""
|
|
83
114
|
last_exception = None
|
|
84
115
|
for i in range(retry):
|
|
85
116
|
try:
|
|
@@ -29,6 +29,16 @@ class OSSUtils:
|
|
|
29
29
|
bucket_name,
|
|
30
30
|
use_vpc=False,
|
|
31
31
|
):
|
|
32
|
+
"""
|
|
33
|
+
description:
|
|
34
|
+
初始化OSS工具类
|
|
35
|
+
parameters:
|
|
36
|
+
access_key_id(str): 阿里云访问密钥ID
|
|
37
|
+
access_key_secret(str): 阿里云访问密钥Secret
|
|
38
|
+
region_id(str): 阿里云区域ID
|
|
39
|
+
bucket_name(str): OSS存储桶名称
|
|
40
|
+
use_vpc(bool): 是否使用VPC内网端点,默认为False
|
|
41
|
+
"""
|
|
32
42
|
self.bucket_name = bucket_name
|
|
33
43
|
if use_vpc:
|
|
34
44
|
self.endpoint = f"https://oss-{region_id}-internal.aliyuncs.com"
|
|
@@ -12,6 +12,13 @@ feishu_alert = Feishu("devtoolkit服务报警")
|
|
|
12
12
|
|
|
13
13
|
class SMSUtils:
|
|
14
14
|
def __init__(self, access_key_id, access_key_secret):
|
|
15
|
+
"""
|
|
16
|
+
description:
|
|
17
|
+
初始化短信服务工具类
|
|
18
|
+
parameters:
|
|
19
|
+
access_key_id(str): 阿里云访问密钥ID
|
|
20
|
+
access_key_secret(str): 阿里云访问密钥Secret
|
|
21
|
+
"""
|
|
15
22
|
self.sms_cilent = Dysmsapi20170525Client(
|
|
16
23
|
open_api_models.Config(
|
|
17
24
|
type="access_key",
|
|
@@ -36,9 +43,9 @@ class SMSUtils:
|
|
|
36
43
|
"""
|
|
37
44
|
description:
|
|
38
45
|
发送验证码给指定手机号
|
|
39
|
-
|
|
40
|
-
phone_numbers: 手机号
|
|
41
|
-
verification_code: 验证码(6位数字)
|
|
46
|
+
parameters:
|
|
47
|
+
phone_numbers(str): 手机号
|
|
48
|
+
verification_code(str): 验证码(6位数字)
|
|
42
49
|
return:
|
|
43
50
|
flag(bool): 是否发送成功
|
|
44
51
|
"""
|
|
@@ -64,6 +71,13 @@ class SMSUtils:
|
|
|
64
71
|
|
|
65
72
|
class SMSUtilsAsync:
|
|
66
73
|
def __init__(self, access_key_id, access_key_secret):
|
|
74
|
+
"""
|
|
75
|
+
description:
|
|
76
|
+
初始化异步短信服务工具类
|
|
77
|
+
parameters:
|
|
78
|
+
access_key_id(str): 阿里云访问密钥ID
|
|
79
|
+
access_key_secret(str): 阿里云访问密钥Secret
|
|
80
|
+
"""
|
|
67
81
|
self.sms_cilent = Dysmsapi20170525Client(
|
|
68
82
|
open_api_models.Config(
|
|
69
83
|
type="access_key",
|
|
@@ -15,6 +15,17 @@ class STSUtils:
|
|
|
15
15
|
def __init__(
|
|
16
16
|
self, access_key_id, access_key_secret, role_arn, region_id, bucket_name, redis_utils
|
|
17
17
|
):
|
|
18
|
+
"""
|
|
19
|
+
description:
|
|
20
|
+
初始化STS(安全令牌服务)工具类
|
|
21
|
+
parameters:
|
|
22
|
+
access_key_id(str): 阿里云访问密钥ID
|
|
23
|
+
access_key_secret(str): 阿里云访问密钥Secret
|
|
24
|
+
role_arn(str): 角色ARN
|
|
25
|
+
region_id(str): 阿里云区域ID
|
|
26
|
+
bucket_name(str): OSS存储桶名称
|
|
27
|
+
redis_utils(RedisUtils): Redis工具类实例,用于缓存STS令牌
|
|
28
|
+
"""
|
|
18
29
|
assert isinstance(redis_utils, RedisUtils), "redis_utils must be a RedisUtils instance"
|
|
19
30
|
self.access_key_id = access_key_id
|
|
20
31
|
self.access_key_secret = access_key_secret
|
|
@@ -19,6 +19,17 @@ class MysqlUtils:
|
|
|
19
19
|
port,
|
|
20
20
|
max_retries=3,
|
|
21
21
|
):
|
|
22
|
+
"""
|
|
23
|
+
description:
|
|
24
|
+
初始化MySQL工具类
|
|
25
|
+
parameters:
|
|
26
|
+
host(str): 数据库主机地址
|
|
27
|
+
database(str): 数据库名称
|
|
28
|
+
user(str): 数据库用户名
|
|
29
|
+
password(str): 数据库密码
|
|
30
|
+
port(int): 数据库端口
|
|
31
|
+
max_retries(int): 最大重试次数,默认为3
|
|
32
|
+
"""
|
|
22
33
|
self.host = host
|
|
23
34
|
self.database = database
|
|
24
35
|
self.user = user
|
|
@@ -29,7 +40,10 @@ class MysqlUtils:
|
|
|
29
40
|
self._connect()
|
|
30
41
|
|
|
31
42
|
def _connect(self):
|
|
32
|
-
"""
|
|
43
|
+
"""
|
|
44
|
+
description:
|
|
45
|
+
建立数据库连接,支持重试机制
|
|
46
|
+
"""
|
|
33
47
|
for attempt in range(self.max_retries):
|
|
34
48
|
try:
|
|
35
49
|
self.mysql = pymysql.connect(
|
|
@@ -55,10 +69,19 @@ class MysqlUtils:
|
|
|
55
69
|
raise
|
|
56
70
|
|
|
57
71
|
def get_conn(self):
|
|
72
|
+
"""
|
|
73
|
+
description:
|
|
74
|
+
获取MySQL连接对象
|
|
75
|
+
return:
|
|
76
|
+
mysql_conn(pymysql.Connection): MySQL连接对象
|
|
77
|
+
"""
|
|
58
78
|
return self.mysql
|
|
59
79
|
|
|
60
80
|
def _ensure_connection(self):
|
|
61
|
-
"""
|
|
81
|
+
"""
|
|
82
|
+
description:
|
|
83
|
+
确保连接有效,如果断开则重新连接
|
|
84
|
+
"""
|
|
62
85
|
try:
|
|
63
86
|
self.mysql.ping(reconnect=True)
|
|
64
87
|
except Exception:
|
|
@@ -77,12 +100,13 @@ class MysqlUtils:
|
|
|
77
100
|
|
|
78
101
|
def create_table(self, table_name, columns):
|
|
79
102
|
"""
|
|
80
|
-
|
|
103
|
+
description:
|
|
104
|
+
创建数据表
|
|
81
105
|
parameters:
|
|
82
106
|
table_name(str): 表名
|
|
83
|
-
columns(list(tuple)):
|
|
84
|
-
|
|
85
|
-
flag(bool):
|
|
107
|
+
columns(list(tuple)): 列名和类型的元组列表
|
|
108
|
+
return:
|
|
109
|
+
flag(bool): 是否创建成功
|
|
86
110
|
"""
|
|
87
111
|
sql = f"""
|
|
88
112
|
CREATE TABLE {table_name} (
|
|
@@ -253,12 +277,28 @@ class MysqlUtils:
|
|
|
253
277
|
cursor.close()
|
|
254
278
|
|
|
255
279
|
def clear_table(self, table_name):
|
|
280
|
+
"""
|
|
281
|
+
description:
|
|
282
|
+
清空数据表
|
|
283
|
+
parameters:
|
|
284
|
+
table_name(str): 表名
|
|
285
|
+
return:
|
|
286
|
+
flag(bool): 是否清空成功
|
|
287
|
+
"""
|
|
256
288
|
sql = f"""
|
|
257
289
|
TRUNCATE TABLE {table_name};
|
|
258
290
|
"""
|
|
259
291
|
return self.execute_sql(sql)
|
|
260
292
|
|
|
261
293
|
def delete_table(self, table_name):
|
|
294
|
+
"""
|
|
295
|
+
description:
|
|
296
|
+
删除数据表
|
|
297
|
+
parameters:
|
|
298
|
+
table_name(str): 表名
|
|
299
|
+
return:
|
|
300
|
+
flag(bool): 是否删除成功
|
|
301
|
+
"""
|
|
262
302
|
sql = f"""
|
|
263
303
|
DROP TABLE {table_name};
|
|
264
304
|
"""
|
|
@@ -275,6 +315,17 @@ class MysqlUtilsAsync:
|
|
|
275
315
|
port,
|
|
276
316
|
max_retries=3,
|
|
277
317
|
):
|
|
318
|
+
"""
|
|
319
|
+
description:
|
|
320
|
+
初始化异步MySQL工具类
|
|
321
|
+
parameters:
|
|
322
|
+
host(str): 数据库主机地址
|
|
323
|
+
database(str): 数据库名称
|
|
324
|
+
user(str): 数据库用户名
|
|
325
|
+
password(str): 数据库密码
|
|
326
|
+
port(int): 数据库端口
|
|
327
|
+
max_retries(int): 最大重试次数,默认为3
|
|
328
|
+
"""
|
|
278
329
|
self.host = host
|
|
279
330
|
self.database = database
|
|
280
331
|
self.user = user
|
|
@@ -284,13 +335,21 @@ class MysqlUtilsAsync:
|
|
|
284
335
|
self.async_mysql = None
|
|
285
336
|
|
|
286
337
|
async def get_async_conn(self):
|
|
287
|
-
"""
|
|
338
|
+
"""
|
|
339
|
+
description:
|
|
340
|
+
获取异步MySQL连接对象
|
|
341
|
+
return:
|
|
342
|
+
async_mysql_conn(aiomysql.Connection): 异步MySQL连接对象
|
|
343
|
+
"""
|
|
288
344
|
if self.async_mysql is None:
|
|
289
345
|
await self._async_connect()
|
|
290
346
|
return self.async_mysql
|
|
291
347
|
|
|
292
348
|
async def _async_connect(self):
|
|
293
|
-
"""
|
|
349
|
+
"""
|
|
350
|
+
description:
|
|
351
|
+
建立异步数据库连接,支持重试机制
|
|
352
|
+
"""
|
|
294
353
|
for attempt in range(self.max_retries):
|
|
295
354
|
try:
|
|
296
355
|
self.async_mysql = await aiomysql.connect(
|
|
@@ -316,7 +375,10 @@ class MysqlUtilsAsync:
|
|
|
316
375
|
raise
|
|
317
376
|
|
|
318
377
|
async def _async_ensure_connection(self):
|
|
319
|
-
"""
|
|
378
|
+
"""
|
|
379
|
+
description:
|
|
380
|
+
确保异步连接有效,如果断开则重新连接
|
|
381
|
+
"""
|
|
320
382
|
try:
|
|
321
383
|
if self.async_mysql is None:
|
|
322
384
|
await self._async_connect()
|
|
@@ -341,12 +403,13 @@ class MysqlUtilsAsync:
|
|
|
341
403
|
|
|
342
404
|
async def create_table(self, table_name, columns):
|
|
343
405
|
"""
|
|
344
|
-
|
|
406
|
+
description:
|
|
407
|
+
异步创建数据表
|
|
345
408
|
parameters:
|
|
346
409
|
table_name(str): 表名
|
|
347
|
-
columns(list(tuple)):
|
|
348
|
-
|
|
349
|
-
flag(bool):
|
|
410
|
+
columns(list(tuple)): 列名和类型的元组列表
|
|
411
|
+
return:
|
|
412
|
+
flag(bool): 是否创建成功
|
|
350
413
|
"""
|
|
351
414
|
sql = f"""
|
|
352
415
|
CREATE TABLE {table_name} (
|
|
@@ -526,19 +589,38 @@ class MysqlUtilsAsync:
|
|
|
526
589
|
await cursor.close()
|
|
527
590
|
|
|
528
591
|
async def clear_table(self, table_name):
|
|
592
|
+
"""
|
|
593
|
+
description:
|
|
594
|
+
异步清空数据表
|
|
595
|
+
parameters:
|
|
596
|
+
table_name(str): 表名
|
|
597
|
+
return:
|
|
598
|
+
flag(bool): 是否清空成功
|
|
599
|
+
"""
|
|
529
600
|
sql = f"""
|
|
530
601
|
TRUNCATE TABLE {table_name};
|
|
531
602
|
"""
|
|
532
603
|
return await self.execute_sql(sql)
|
|
533
604
|
|
|
534
605
|
async def delete_table(self, table_name):
|
|
606
|
+
"""
|
|
607
|
+
description:
|
|
608
|
+
异步删除数据表
|
|
609
|
+
parameters:
|
|
610
|
+
table_name(str): 表名
|
|
611
|
+
return:
|
|
612
|
+
flag(bool): 是否删除成功
|
|
613
|
+
"""
|
|
535
614
|
sql = f"""
|
|
536
615
|
DROP TABLE {table_name};
|
|
537
616
|
"""
|
|
538
617
|
return await self.execute_sql(sql)
|
|
539
618
|
|
|
540
619
|
async def close(self):
|
|
541
|
-
"""
|
|
620
|
+
"""
|
|
621
|
+
description:
|
|
622
|
+
关闭异步MySQL连接
|
|
623
|
+
"""
|
|
542
624
|
if self.async_mysql:
|
|
543
625
|
self.async_mysql.close()
|
|
544
626
|
await self.async_mysql.wait_closed()
|