pixelarraylib 1.0.7__tar.gz → 1.0.8__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.7/pixelarraylib.egg-info → pixelarraylib-1.0.8}/PKG-INFO +1 -1
- {pixelarraylib-1.0.7 → pixelarraylib-1.0.8}/pixelarraylib/__init__.py +1 -1
- {pixelarraylib-1.0.7 → pixelarraylib-1.0.8}/pixelarraylib/aliyun/acr.py +8 -8
- {pixelarraylib-1.0.7 → pixelarraylib-1.0.8}/pixelarraylib/aliyun/aliyun_email.py +2 -2
- {pixelarraylib-1.0.7 → pixelarraylib-1.0.8}/pixelarraylib/aliyun/billing.py +3 -3
- {pixelarraylib-1.0.7 → pixelarraylib-1.0.8}/pixelarraylib/aliyun/content_scanner.py +6 -6
- {pixelarraylib-1.0.7 → pixelarraylib-1.0.8}/pixelarraylib/aliyun/eci.py +6 -6
- {pixelarraylib-1.0.7 → pixelarraylib-1.0.8}/pixelarraylib/aliyun/eip.py +3 -3
- {pixelarraylib-1.0.7 → pixelarraylib-1.0.8}/pixelarraylib/aliyun/fc.py +2 -2
- {pixelarraylib-1.0.7 → pixelarraylib-1.0.8}/pixelarraylib/aliyun/oss.py +5 -5
- {pixelarraylib-1.0.7 → pixelarraylib-1.0.8}/pixelarraylib/aliyun/sms.py +2 -2
- {pixelarraylib-1.0.7 → pixelarraylib-1.0.8}/pixelarraylib/aliyun/sts.py +3 -3
- {pixelarraylib-1.0.7 → pixelarraylib-1.0.8}/pixelarraylib/db_utils/mysql.py +10 -10
- {pixelarraylib-1.0.7 → pixelarraylib-1.0.8}/pixelarraylib/db_utils/redis.py +18 -18
- {pixelarraylib-1.0.7 → pixelarraylib-1.0.8}/pixelarraylib/decorators/decorators.py +2 -2
- {pixelarraylib-1.0.7 → pixelarraylib-1.0.8}/pixelarraylib/scripts/__init__.py +1 -1
- {pixelarraylib-1.0.7 → pixelarraylib-1.0.8}/pixelarraylib/system/common.py +6 -8
- {pixelarraylib-1.0.7 → pixelarraylib-1.0.8/pixelarraylib.egg-info}/PKG-INFO +1 -1
- {pixelarraylib-1.0.7 → pixelarraylib-1.0.8}/pyproject.toml +1 -1
- {pixelarraylib-1.0.7 → pixelarraylib-1.0.8}/LICENSE +0 -0
- {pixelarraylib-1.0.7 → pixelarraylib-1.0.8}/MANIFEST.in +0 -0
- {pixelarraylib-1.0.7 → pixelarraylib-1.0.8}/README.md +0 -0
- {pixelarraylib-1.0.7 → pixelarraylib-1.0.8}/pixelarraylib/__main__.py +0 -0
- {pixelarraylib-1.0.7 → pixelarraylib-1.0.8}/pixelarraylib/aliyun/__init__.py +0 -0
- {pixelarraylib-1.0.7 → pixelarraylib-1.0.8}/pixelarraylib/aliyun/domain.py +0 -0
- {pixelarraylib-1.0.7 → pixelarraylib-1.0.8}/pixelarraylib/aliyun/ecs.py +0 -0
- {pixelarraylib-1.0.7 → pixelarraylib-1.0.8}/pixelarraylib/decorators/__init__.py +0 -0
- {pixelarraylib-1.0.7 → pixelarraylib-1.0.8}/pixelarraylib/gitlab/__init__.py +0 -0
- {pixelarraylib-1.0.7 → pixelarraylib-1.0.8}/pixelarraylib/gitlab/code_analyzer.py +0 -0
- {pixelarraylib-1.0.7 → pixelarraylib-1.0.8}/pixelarraylib/gitlab/pypi_package_manager.py +0 -0
- {pixelarraylib-1.0.7 → pixelarraylib-1.0.8}/pixelarraylib/monitor/__init__.py +0 -0
- {pixelarraylib-1.0.7 → pixelarraylib-1.0.8}/pixelarraylib/monitor/feishu.py +0 -0
- {pixelarraylib-1.0.7 → pixelarraylib-1.0.8}/pixelarraylib/net/request.py +0 -0
- {pixelarraylib-1.0.7 → pixelarraylib-1.0.8}/pixelarraylib/scripts/build_website.py +0 -0
- {pixelarraylib-1.0.7 → pixelarraylib-1.0.8}/pixelarraylib/scripts/collect_code_to_txt.py +0 -0
- {pixelarraylib-1.0.7 → pixelarraylib-1.0.8}/pixelarraylib/scripts/create_test_case_files.py +0 -0
- {pixelarraylib-1.0.7 → pixelarraylib-1.0.8}/pixelarraylib/scripts/nginx_proxy_to_ecs.py +0 -0
- {pixelarraylib-1.0.7 → pixelarraylib-1.0.8}/pixelarraylib/scripts/remove_empty_lines.py +0 -0
- {pixelarraylib-1.0.7 → pixelarraylib-1.0.8}/pixelarraylib/system/__init__.py +0 -0
- {pixelarraylib-1.0.7 → pixelarraylib-1.0.8}/pixelarraylib.egg-info/SOURCES.txt +0 -0
- {pixelarraylib-1.0.7 → pixelarraylib-1.0.8}/pixelarraylib.egg-info/dependency_links.txt +0 -0
- {pixelarraylib-1.0.7 → pixelarraylib-1.0.8}/pixelarraylib.egg-info/entry_points.txt +0 -0
- {pixelarraylib-1.0.7 → pixelarraylib-1.0.8}/pixelarraylib.egg-info/requires.txt +0 -0
- {pixelarraylib-1.0.7 → pixelarraylib-1.0.8}/pixelarraylib.egg-info/top_level.txt +0 -0
- {pixelarraylib-1.0.7 → pixelarraylib-1.0.8}/requirements.txt +0 -0
- {pixelarraylib-1.0.7 → pixelarraylib-1.0.8}/setup.cfg +0 -0
|
@@ -50,7 +50,7 @@ class ACRUtils:
|
|
|
50
50
|
response = self.client.list_instance(request)
|
|
51
51
|
return response.body.to_map(), True
|
|
52
52
|
except Exception as e:
|
|
53
|
-
|
|
53
|
+
print(f"列出实例失败: {e}")
|
|
54
54
|
return {}, False
|
|
55
55
|
|
|
56
56
|
def create_namespace(self, instance_id: str, namespace_name: str):
|
|
@@ -72,7 +72,7 @@ class ACRUtils:
|
|
|
72
72
|
response = self.client.create_namespace(request)
|
|
73
73
|
return response.body.to_map(), True
|
|
74
74
|
except Exception as e:
|
|
75
|
-
|
|
75
|
+
print(f"创建命名空间失败: {e}")
|
|
76
76
|
return {}, False
|
|
77
77
|
|
|
78
78
|
def delete_namespace(self, instance_id: str, namespace_name: str):
|
|
@@ -93,7 +93,7 @@ class ACRUtils:
|
|
|
93
93
|
response = self.client.delete_namespace(request)
|
|
94
94
|
return response.body.to_map(), True
|
|
95
95
|
except Exception as e:
|
|
96
|
-
|
|
96
|
+
print(f"删除命名空间失败: {e}")
|
|
97
97
|
return {}, False
|
|
98
98
|
|
|
99
99
|
def list_namespaces(self, instance_id: str):
|
|
@@ -111,7 +111,7 @@ class ACRUtils:
|
|
|
111
111
|
response = self.client.list_namespace(request)
|
|
112
112
|
return response.body.to_map(), True
|
|
113
113
|
except Exception as e:
|
|
114
|
-
|
|
114
|
+
print(f"列出命名空间失败: {e}")
|
|
115
115
|
return {}, False
|
|
116
116
|
|
|
117
117
|
def exists_namespace(self, instance_id: str, namespace_name: str):
|
|
@@ -167,7 +167,7 @@ class ACRUtils:
|
|
|
167
167
|
response = self.client.create_repository(request)
|
|
168
168
|
return response.body.to_map(), True
|
|
169
169
|
except Exception as e:
|
|
170
|
-
|
|
170
|
+
print(f"创建仓库失败: {e}")
|
|
171
171
|
return {}, False
|
|
172
172
|
|
|
173
173
|
def list_repositories(self, instance_id: str, namespace_name: str):
|
|
@@ -188,7 +188,7 @@ class ACRUtils:
|
|
|
188
188
|
response = self.client.list_repository(request)
|
|
189
189
|
return response.body.to_map(), True
|
|
190
190
|
except Exception as e:
|
|
191
|
-
|
|
191
|
+
print(f"列出仓库失败: {e}")
|
|
192
192
|
return {}, False
|
|
193
193
|
|
|
194
194
|
def exists_repository(
|
|
@@ -235,7 +235,7 @@ class ACRUtils:
|
|
|
235
235
|
response = self.client.delete_repository(request)
|
|
236
236
|
return response.body.to_map(), True
|
|
237
237
|
except Exception as e:
|
|
238
|
-
|
|
238
|
+
print(f"删除仓库失败: {e}")
|
|
239
239
|
return {}, False
|
|
240
240
|
|
|
241
241
|
def get_repository(
|
|
@@ -261,5 +261,5 @@ class ACRUtils:
|
|
|
261
261
|
response = self.client.get_repository(request)
|
|
262
262
|
return response.body.to_map(), True
|
|
263
263
|
except Exception as e:
|
|
264
|
-
|
|
264
|
+
print(f"获取仓库详情失败: {e}")
|
|
265
265
|
return {}, False
|
|
@@ -122,9 +122,9 @@ class AliyunEmailSender:
|
|
|
122
122
|
if response.status_code == 200:
|
|
123
123
|
return True
|
|
124
124
|
else:
|
|
125
|
-
|
|
125
|
+
print(f"发送验证邮件失败: {response}")
|
|
126
126
|
return False
|
|
127
127
|
|
|
128
128
|
except Exception as e:
|
|
129
|
-
|
|
129
|
+
print(traceback.format_exc())
|
|
130
130
|
return False
|
|
@@ -244,7 +244,7 @@ class BillingUtils:
|
|
|
244
244
|
return formatted_response
|
|
245
245
|
|
|
246
246
|
except Exception as e:
|
|
247
|
-
|
|
247
|
+
print(traceback.format_exc())
|
|
248
248
|
error_response = {
|
|
249
249
|
"Message": add_comment(f"Format error: {str(e)}", "Message"),
|
|
250
250
|
"RequestId": add_comment(
|
|
@@ -326,7 +326,7 @@ class BillingUtils:
|
|
|
326
326
|
return formatted_response
|
|
327
327
|
|
|
328
328
|
except Exception as error:
|
|
329
|
-
|
|
329
|
+
print(traceback.format_exc())
|
|
330
330
|
error_msg = getattr(error, "message", str(error))
|
|
331
331
|
# 诊断地址
|
|
332
332
|
diagnose_url = ""
|
|
@@ -473,5 +473,5 @@ class BillingUtils:
|
|
|
473
473
|
return output_path
|
|
474
474
|
|
|
475
475
|
except Exception as e:
|
|
476
|
-
|
|
476
|
+
print(traceback.format_exc())
|
|
477
477
|
raise Exception(f"保存账单数据失败: {str(e)}")
|
|
@@ -71,7 +71,7 @@ class ContentScanner:
|
|
|
71
71
|
else ({}, False)
|
|
72
72
|
)
|
|
73
73
|
except Exception as e:
|
|
74
|
-
|
|
74
|
+
print(traceback.format_exc())
|
|
75
75
|
return {}, False
|
|
76
76
|
|
|
77
77
|
def scan_image(
|
|
@@ -110,7 +110,7 @@ class ContentScanner:
|
|
|
110
110
|
else ({}, False)
|
|
111
111
|
)
|
|
112
112
|
except Exception as e:
|
|
113
|
-
|
|
113
|
+
print(traceback.format_exc())
|
|
114
114
|
return {}, False
|
|
115
115
|
|
|
116
116
|
def scan_video(
|
|
@@ -151,7 +151,7 @@ class ContentScanner:
|
|
|
151
151
|
else ("", False)
|
|
152
152
|
)
|
|
153
153
|
except Exception as e:
|
|
154
|
-
|
|
154
|
+
print(traceback.format_exc())
|
|
155
155
|
return "", False
|
|
156
156
|
|
|
157
157
|
def get_video_result(
|
|
@@ -181,7 +181,7 @@ class ContentScanner:
|
|
|
181
181
|
else ({}, False)
|
|
182
182
|
)
|
|
183
183
|
except Exception as e:
|
|
184
|
-
|
|
184
|
+
print(traceback.format_exc())
|
|
185
185
|
return {}, False
|
|
186
186
|
|
|
187
187
|
def scan_voice(
|
|
@@ -219,7 +219,7 @@ class ContentScanner:
|
|
|
219
219
|
else ("", False)
|
|
220
220
|
)
|
|
221
221
|
except Exception as e:
|
|
222
|
-
|
|
222
|
+
print(traceback.format_exc())
|
|
223
223
|
return "", False
|
|
224
224
|
|
|
225
225
|
def get_voice_result(
|
|
@@ -249,5 +249,5 @@ class ContentScanner:
|
|
|
249
249
|
else ({}, False)
|
|
250
250
|
)
|
|
251
251
|
except Exception as e:
|
|
252
|
-
|
|
252
|
+
print(traceback.format_exc())
|
|
253
253
|
return {}, False
|
|
@@ -82,7 +82,7 @@ class ECIUtils:
|
|
|
82
82
|
)
|
|
83
83
|
return response.body.to_map(), True
|
|
84
84
|
except Exception as error:
|
|
85
|
-
|
|
85
|
+
print(f"查询可用资源失败: {error}")
|
|
86
86
|
return {}
|
|
87
87
|
|
|
88
88
|
def create_container_group(
|
|
@@ -131,7 +131,7 @@ class ECIUtils:
|
|
|
131
131
|
if allocate_public_ip:
|
|
132
132
|
response, success = self.eip_utils.allocate_eip()
|
|
133
133
|
if not success:
|
|
134
|
-
|
|
134
|
+
print(f"创建容器组失败: 分配公网IP失败")
|
|
135
135
|
return {}, False
|
|
136
136
|
eip_instance_id = response["AllocationId"]
|
|
137
137
|
else:
|
|
@@ -163,7 +163,7 @@ class ECIUtils:
|
|
|
163
163
|
)
|
|
164
164
|
return response.body.to_map(), True
|
|
165
165
|
except Exception as error:
|
|
166
|
-
|
|
166
|
+
print(f"创建容器组失败: {error}")
|
|
167
167
|
return {}, False
|
|
168
168
|
|
|
169
169
|
def describe_container_group(self, container_group_id: str):
|
|
@@ -186,7 +186,7 @@ class ECIUtils:
|
|
|
186
186
|
)
|
|
187
187
|
return response.body.to_map()
|
|
188
188
|
except Exception as error:
|
|
189
|
-
|
|
189
|
+
print(f"查询容器组失败: {error}")
|
|
190
190
|
return {}
|
|
191
191
|
|
|
192
192
|
def list_container_groups(self):
|
|
@@ -208,7 +208,7 @@ class ECIUtils:
|
|
|
208
208
|
)
|
|
209
209
|
return response.body.to_map()
|
|
210
210
|
except Exception as error:
|
|
211
|
-
|
|
211
|
+
print(f"查询容器组列表失败: {error}")
|
|
212
212
|
return {}
|
|
213
213
|
|
|
214
214
|
def delete_container_group(self, container_group_id: str):
|
|
@@ -232,5 +232,5 @@ class ECIUtils:
|
|
|
232
232
|
)
|
|
233
233
|
return response.body.to_map(), True
|
|
234
234
|
except Exception as error:
|
|
235
|
-
|
|
235
|
+
print(f"删除容器组失败: {error}")
|
|
236
236
|
return {}, False
|
|
@@ -48,7 +48,7 @@ class EIPUtils:
|
|
|
48
48
|
)
|
|
49
49
|
return response.body.to_map(), True
|
|
50
50
|
except Exception as error:
|
|
51
|
-
|
|
51
|
+
print(f"分配EIP失败: {error}")
|
|
52
52
|
return {}, False
|
|
53
53
|
|
|
54
54
|
def release_eip(self, allocation_id: str):
|
|
@@ -71,7 +71,7 @@ class EIPUtils:
|
|
|
71
71
|
)
|
|
72
72
|
return response.body.to_map(), True
|
|
73
73
|
except Exception as error:
|
|
74
|
-
|
|
74
|
+
print(f"释放EIP失败: {error}")
|
|
75
75
|
return {}, False
|
|
76
76
|
|
|
77
77
|
def list_eips(self):
|
|
@@ -92,5 +92,5 @@ class EIPUtils:
|
|
|
92
92
|
)
|
|
93
93
|
return response.body.to_map(), True
|
|
94
94
|
except Exception as error:
|
|
95
|
-
|
|
95
|
+
print(f"查询EIP列表失败: {error}")
|
|
96
96
|
return {}, False
|
|
@@ -69,7 +69,7 @@ class FCUtils:
|
|
|
69
69
|
else:
|
|
70
70
|
return None, False
|
|
71
71
|
# 如果所有重试都失败,返回最后一次的异常信息
|
|
72
|
-
|
|
72
|
+
print(
|
|
73
73
|
f"aliyun fc invoke_function failed after {retry} retries. Last error: {last_exception}"
|
|
74
74
|
)
|
|
75
75
|
return None, False
|
|
@@ -136,7 +136,7 @@ class FCUtils:
|
|
|
136
136
|
else:
|
|
137
137
|
return False
|
|
138
138
|
# 如果所有重试都失败,返回最后一次的异常信息
|
|
139
|
-
|
|
139
|
+
print(
|
|
140
140
|
f"aliyun fc update_function failed after {retry} retries. Last error: {last_exception}"
|
|
141
141
|
)
|
|
142
142
|
return False
|
|
@@ -135,7 +135,7 @@ class OSSUtils:
|
|
|
135
135
|
self.client.delete_object(obj.key)
|
|
136
136
|
return True
|
|
137
137
|
except Exception as e:
|
|
138
|
-
|
|
138
|
+
print(traceback.format_exc())
|
|
139
139
|
return False
|
|
140
140
|
|
|
141
141
|
def ls(self, prefix):
|
|
@@ -206,7 +206,7 @@ class OSSUtils:
|
|
|
206
206
|
return True
|
|
207
207
|
return False
|
|
208
208
|
except Exception as e:
|
|
209
|
-
|
|
209
|
+
print(traceback.format_exc())
|
|
210
210
|
return False
|
|
211
211
|
|
|
212
212
|
def download_object(self, prefix, dir_path):
|
|
@@ -231,7 +231,7 @@ class OSSUtils:
|
|
|
231
231
|
self.client.get_object_to_file(prefix, download_path)
|
|
232
232
|
return True
|
|
233
233
|
except Exception as e:
|
|
234
|
-
|
|
234
|
+
print(f"oss download_object error: {traceback.format_exc()}")
|
|
235
235
|
return False
|
|
236
236
|
|
|
237
237
|
def upload_object(self, prefix, local_path):
|
|
@@ -255,7 +255,7 @@ class OSSUtils:
|
|
|
255
255
|
)
|
|
256
256
|
return True
|
|
257
257
|
except Exception as e:
|
|
258
|
-
|
|
258
|
+
print(traceback.format_exc())
|
|
259
259
|
return False
|
|
260
260
|
|
|
261
261
|
def copy_object(self, prefix, target_prefix):
|
|
@@ -274,7 +274,7 @@ class OSSUtils:
|
|
|
274
274
|
)
|
|
275
275
|
return True
|
|
276
276
|
except Exception as e:
|
|
277
|
-
|
|
277
|
+
print(traceback.format_exc())
|
|
278
278
|
return False
|
|
279
279
|
|
|
280
280
|
def generate_presigned_url(self, prefix, expires_in=60 * 60 * 24):
|
|
@@ -52,8 +52,8 @@ class SMSUtils:
|
|
|
52
52
|
response and response.status_code == 200 and response.body.code == "OK"
|
|
53
53
|
)
|
|
54
54
|
if not flag:
|
|
55
|
-
|
|
55
|
+
print(f"短信发送失败: {response}")
|
|
56
56
|
return flag
|
|
57
57
|
except Exception as e:
|
|
58
|
-
|
|
58
|
+
print("短信发送失败: " + traceback.format_exc())
|
|
59
59
|
return False
|
|
@@ -76,7 +76,7 @@ class STSUtils:
|
|
|
76
76
|
)
|
|
77
77
|
return credentials, True
|
|
78
78
|
except Exception as e:
|
|
79
|
-
|
|
79
|
+
print(traceback.format_exc())
|
|
80
80
|
return {}, False
|
|
81
81
|
|
|
82
82
|
def get_oss_sts_client(self, endpoint, bucket_name):
|
|
@@ -99,7 +99,7 @@ class STSUtils:
|
|
|
99
99
|
)
|
|
100
100
|
return oss2.Bucket(auth, endpoint, bucket_name), True
|
|
101
101
|
except Exception as e:
|
|
102
|
-
|
|
102
|
+
print(traceback.format_exc())
|
|
103
103
|
return None, False
|
|
104
104
|
|
|
105
105
|
def generate_presigned_url(self, prefix, expires_in=60 * 60 * 24):
|
|
@@ -120,5 +120,5 @@ class STSUtils:
|
|
|
120
120
|
return ""
|
|
121
121
|
return sts_oss_client.sign_url("GET", prefix, expires_in)
|
|
122
122
|
except Exception as e:
|
|
123
|
-
|
|
123
|
+
print(traceback.format_exc())
|
|
124
124
|
return ""
|
|
@@ -46,12 +46,12 @@ class MysqlUtils:
|
|
|
46
46
|
break # 连接成功,跳出重试循环
|
|
47
47
|
except OperationalError as e:
|
|
48
48
|
if attempt < self.max_retries - 1:
|
|
49
|
-
|
|
49
|
+
print(
|
|
50
50
|
f"MySQL连接失败,正在重试 ({attempt + 1}/{self.max_retries}): {str(e)}"
|
|
51
51
|
)
|
|
52
52
|
time.sleep(2**attempt) # 指数退避
|
|
53
53
|
else:
|
|
54
|
-
|
|
54
|
+
print(f"MySQL连接最终失败: {traceback.format_exc()}")
|
|
55
55
|
raise
|
|
56
56
|
|
|
57
57
|
def get_conn(self):
|
|
@@ -198,7 +198,7 @@ class MysqlUtils:
|
|
|
198
198
|
print(f"插入/更新 {i} / {len(rows)} 行到 {table_name}")
|
|
199
199
|
return True
|
|
200
200
|
except Exception as e:
|
|
201
|
-
|
|
201
|
+
print(f"mysql-insert_or_update error {traceback.format_exc()}")
|
|
202
202
|
return False
|
|
203
203
|
|
|
204
204
|
def query(self, sql, convert_to_dict=False):
|
|
@@ -225,7 +225,7 @@ class MysqlUtils:
|
|
|
225
225
|
return [dict(zip(columns, row)) for row in result]
|
|
226
226
|
return list(result)
|
|
227
227
|
except Exception as e:
|
|
228
|
-
|
|
228
|
+
print(f"mysql-query error {traceback.format_exc()}")
|
|
229
229
|
return []
|
|
230
230
|
finally:
|
|
231
231
|
cursor.close()
|
|
@@ -247,7 +247,7 @@ class MysqlUtils:
|
|
|
247
247
|
return True
|
|
248
248
|
except Exception as e:
|
|
249
249
|
self.mysql.rollback()
|
|
250
|
-
|
|
250
|
+
print(f"mysql-execute error {traceback.format_exc()}")
|
|
251
251
|
return False
|
|
252
252
|
finally:
|
|
253
253
|
cursor.close()
|
|
@@ -305,12 +305,12 @@ class MysqlUtilsAsync:
|
|
|
305
305
|
break # 连接成功,跳出重试循环
|
|
306
306
|
except Exception as e:
|
|
307
307
|
if attempt < self.max_retries - 1:
|
|
308
|
-
|
|
308
|
+
print(
|
|
309
309
|
f"异步MySQL连接失败,正在重试 ({attempt + 1}/{self.max_retries}): {str(e)}"
|
|
310
310
|
)
|
|
311
311
|
await asyncio.sleep(2**attempt) # 指数退避
|
|
312
312
|
else:
|
|
313
|
-
|
|
313
|
+
print(
|
|
314
314
|
f"异步MySQL连接最终失败: {traceback.format_exc()}"
|
|
315
315
|
)
|
|
316
316
|
raise
|
|
@@ -462,7 +462,7 @@ class MysqlUtilsAsync:
|
|
|
462
462
|
print(f"插入/更新 {i} / {len(rows)} 行到 {table_name}")
|
|
463
463
|
return True
|
|
464
464
|
except Exception as e:
|
|
465
|
-
|
|
465
|
+
print(
|
|
466
466
|
f"mysql-insert_or_update_async error {traceback.format_exc()}"
|
|
467
467
|
)
|
|
468
468
|
return False
|
|
@@ -493,7 +493,7 @@ class MysqlUtilsAsync:
|
|
|
493
493
|
return [dict(zip(columns, row)) for row in result]
|
|
494
494
|
return list(result)
|
|
495
495
|
except Exception as e:
|
|
496
|
-
|
|
496
|
+
print(f"mysql-query_async error {traceback.format_exc()}")
|
|
497
497
|
return []
|
|
498
498
|
finally:
|
|
499
499
|
if cursor:
|
|
@@ -519,7 +519,7 @@ class MysqlUtilsAsync:
|
|
|
519
519
|
except Exception as e:
|
|
520
520
|
async_mysql = await self.get_async_conn()
|
|
521
521
|
await async_mysql.rollback()
|
|
522
|
-
|
|
522
|
+
print(f"mysql-execute_async error {traceback.format_exc()}")
|
|
523
523
|
return False
|
|
524
524
|
finally:
|
|
525
525
|
if cursor:
|
|
@@ -34,7 +34,7 @@ class RedisUtils:
|
|
|
34
34
|
self.redis_client.set(key, value, ex=expire_seconds)
|
|
35
35
|
return True
|
|
36
36
|
except Exception as e:
|
|
37
|
-
|
|
37
|
+
print(traceback.format_exc())
|
|
38
38
|
return False
|
|
39
39
|
|
|
40
40
|
def get(self, key, default_value=""):
|
|
@@ -53,7 +53,7 @@ class RedisUtils:
|
|
|
53
53
|
return default_value
|
|
54
54
|
return value.decode()
|
|
55
55
|
except Exception as e:
|
|
56
|
-
|
|
56
|
+
print(traceback.format_exc())
|
|
57
57
|
return default_value
|
|
58
58
|
|
|
59
59
|
def delete(self, key):
|
|
@@ -69,7 +69,7 @@ class RedisUtils:
|
|
|
69
69
|
self.redis_client.delete(key)
|
|
70
70
|
return True
|
|
71
71
|
except Exception as e:
|
|
72
|
-
|
|
72
|
+
print(traceback.format_exc())
|
|
73
73
|
return False
|
|
74
74
|
|
|
75
75
|
def delete_many(self, keys: List[str]) -> bool:
|
|
@@ -85,7 +85,7 @@ class RedisUtils:
|
|
|
85
85
|
self.redis_client.delete(*keys)
|
|
86
86
|
return True
|
|
87
87
|
except Exception as e:
|
|
88
|
-
|
|
88
|
+
print(traceback.format_exc())
|
|
89
89
|
return False
|
|
90
90
|
|
|
91
91
|
def set_hash(self, key, field, value, expire_seconds=None):
|
|
@@ -106,7 +106,7 @@ class RedisUtils:
|
|
|
106
106
|
self.redis_client.expire(key, expire_seconds)
|
|
107
107
|
return True
|
|
108
108
|
except Exception as e:
|
|
109
|
-
|
|
109
|
+
print(traceback.format_exc())
|
|
110
110
|
return False
|
|
111
111
|
|
|
112
112
|
def get_hash(self, key, field):
|
|
@@ -125,7 +125,7 @@ class RedisUtils:
|
|
|
125
125
|
return ""
|
|
126
126
|
return value.decode()
|
|
127
127
|
except Exception as e:
|
|
128
|
-
|
|
128
|
+
print(traceback.format_exc())
|
|
129
129
|
return ""
|
|
130
130
|
|
|
131
131
|
def delete_hash(self, key, field):
|
|
@@ -142,7 +142,7 @@ class RedisUtils:
|
|
|
142
142
|
self.redis_client.hdel(key, field)
|
|
143
143
|
return True
|
|
144
144
|
except Exception as e:
|
|
145
|
-
|
|
145
|
+
print(traceback.format_exc())
|
|
146
146
|
return False
|
|
147
147
|
|
|
148
148
|
def list_hash_keys(self, key):
|
|
@@ -157,7 +157,7 @@ class RedisUtils:
|
|
|
157
157
|
try:
|
|
158
158
|
return [key.decode() for key in self.redis_client.hkeys(key)]
|
|
159
159
|
except Exception as e:
|
|
160
|
-
|
|
160
|
+
print(traceback.format_exc())
|
|
161
161
|
return []
|
|
162
162
|
|
|
163
163
|
def list_keys(self, prefix=""):
|
|
@@ -183,7 +183,7 @@ class RedisUtils:
|
|
|
183
183
|
break
|
|
184
184
|
return [key.decode() for key in keys]
|
|
185
185
|
except Exception as e:
|
|
186
|
-
|
|
186
|
+
print(traceback.format_exc())
|
|
187
187
|
return []
|
|
188
188
|
|
|
189
189
|
def __del__(self):
|
|
@@ -214,7 +214,7 @@ class RedisUtilsAsync:
|
|
|
214
214
|
await self.async_redis_client.set(key, value, ex=expire_seconds)
|
|
215
215
|
return True
|
|
216
216
|
except Exception as e:
|
|
217
|
-
|
|
217
|
+
print(traceback.format_exc())
|
|
218
218
|
return False
|
|
219
219
|
|
|
220
220
|
async def get(self, key, default_value=""):
|
|
@@ -233,7 +233,7 @@ class RedisUtilsAsync:
|
|
|
233
233
|
return default_value
|
|
234
234
|
return value.decode()
|
|
235
235
|
except Exception as e:
|
|
236
|
-
|
|
236
|
+
print(traceback.format_exc())
|
|
237
237
|
return default_value
|
|
238
238
|
|
|
239
239
|
async def delete(self, key):
|
|
@@ -249,7 +249,7 @@ class RedisUtilsAsync:
|
|
|
249
249
|
await self.async_redis_client.delete(key)
|
|
250
250
|
return True
|
|
251
251
|
except Exception as e:
|
|
252
|
-
|
|
252
|
+
print(traceback.format_exc())
|
|
253
253
|
return False
|
|
254
254
|
|
|
255
255
|
async def delete_many(self, keys: List[str]) -> bool:
|
|
@@ -265,7 +265,7 @@ class RedisUtilsAsync:
|
|
|
265
265
|
await self.async_redis_client.delete(*keys)
|
|
266
266
|
return True
|
|
267
267
|
except Exception as e:
|
|
268
|
-
|
|
268
|
+
print(traceback.format_exc())
|
|
269
269
|
return False
|
|
270
270
|
|
|
271
271
|
async def set_hash(self, key, field, value, expire_seconds=None):
|
|
@@ -286,7 +286,7 @@ class RedisUtilsAsync:
|
|
|
286
286
|
await self.async_redis_client.expire(key, expire_seconds)
|
|
287
287
|
return True
|
|
288
288
|
except Exception as e:
|
|
289
|
-
|
|
289
|
+
print(traceback.format_exc())
|
|
290
290
|
return False
|
|
291
291
|
|
|
292
292
|
async def get_hash(self, key, field):
|
|
@@ -305,7 +305,7 @@ class RedisUtilsAsync:
|
|
|
305
305
|
return ""
|
|
306
306
|
return value.decode()
|
|
307
307
|
except Exception as e:
|
|
308
|
-
|
|
308
|
+
print(traceback.format_exc())
|
|
309
309
|
return ""
|
|
310
310
|
|
|
311
311
|
async def delete_hash(self, key, field):
|
|
@@ -322,7 +322,7 @@ class RedisUtilsAsync:
|
|
|
322
322
|
await self.async_redis_client.hdel(key, field)
|
|
323
323
|
return True
|
|
324
324
|
except Exception as e:
|
|
325
|
-
|
|
325
|
+
print(traceback.format_exc())
|
|
326
326
|
return False
|
|
327
327
|
|
|
328
328
|
async def list_hash_keys(self, key):
|
|
@@ -338,7 +338,7 @@ class RedisUtilsAsync:
|
|
|
338
338
|
keys = await self.async_redis_client.hkeys(key)
|
|
339
339
|
return [key.decode() for key in keys]
|
|
340
340
|
except Exception as e:
|
|
341
|
-
|
|
341
|
+
print(traceback.format_exc())
|
|
342
342
|
return []
|
|
343
343
|
|
|
344
344
|
async def list_keys(self, prefix=""):
|
|
@@ -364,7 +364,7 @@ class RedisUtilsAsync:
|
|
|
364
364
|
break
|
|
365
365
|
return [key.decode() for key in keys]
|
|
366
366
|
except Exception as e:
|
|
367
|
-
|
|
367
|
+
print(traceback.format_exc())
|
|
368
368
|
return []
|
|
369
369
|
|
|
370
370
|
async def close(self):
|
|
@@ -38,7 +38,7 @@ def catch_exception(
|
|
|
38
38
|
alert_message = f"文件{os.path.relpath(inspect.getfile(func))}中的函数{get_caller_function_name()}执行失败,{alert_params_str},错误信息如下:\n {traceback.format_exc()}"
|
|
39
39
|
if addtional_alert:
|
|
40
40
|
alert_message += f"\n{addtional_alert}"
|
|
41
|
-
|
|
41
|
+
print(alert_message)
|
|
42
42
|
return exception_return
|
|
43
43
|
|
|
44
44
|
@wraps(func)
|
|
@@ -50,7 +50,7 @@ def catch_exception(
|
|
|
50
50
|
alert_message = f"文件{os.path.relpath(inspect.getfile(func))}中的函数{get_caller_function_name()}执行失败,{alert_params_str},错误信息如下:\n {traceback.format_exc()}"
|
|
51
51
|
if addtional_alert:
|
|
52
52
|
alert_message += f"\n{addtional_alert}"
|
|
53
|
-
|
|
53
|
+
print(alert_message)
|
|
54
54
|
return exception_return
|
|
55
55
|
|
|
56
56
|
if asyncio.iscoroutinefunction(func):
|
|
@@ -216,7 +216,7 @@ def split_content_into_sentences(
|
|
|
216
216
|
sentences = [re.sub(r"[^\w\s]", "", s) for s in sentences]
|
|
217
217
|
return sentences, True
|
|
218
218
|
except Exception as e:
|
|
219
|
-
|
|
219
|
+
print(f"分割内容时发生错误: {traceback.format_exc()}")
|
|
220
220
|
return [], False
|
|
221
221
|
|
|
222
222
|
|
|
@@ -234,7 +234,7 @@ def remove_all_punctuation(text: str) -> tuple[str, bool]:
|
|
|
234
234
|
# 使用正则表达式去除所有标点符号
|
|
235
235
|
return re.sub(r"[^\w\s]", "", text), True
|
|
236
236
|
except Exception as e:
|
|
237
|
-
|
|
237
|
+
print(f"去除标点符号时发生错误: {traceback.format_exc()}")
|
|
238
238
|
return text, False
|
|
239
239
|
|
|
240
240
|
|
|
@@ -263,16 +263,15 @@ def execute_command(command: Union[str, List[str]]) -> str:
|
|
|
263
263
|
try:
|
|
264
264
|
if isinstance(command, str):
|
|
265
265
|
command = command.split()
|
|
266
|
-
print(command)
|
|
267
266
|
result = subprocess.run(
|
|
268
267
|
command, check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE
|
|
269
268
|
)
|
|
270
269
|
return result.stdout.decode(), True
|
|
271
270
|
except subprocess.CalledProcessError as e:
|
|
272
|
-
|
|
271
|
+
print(
|
|
273
272
|
f"执行命令失败,命令: {command},错误信息: {e.stderr.decode() if e.stderr else str(e)}"
|
|
274
273
|
)
|
|
275
|
-
return
|
|
274
|
+
return e.stderr.decode() if e.stderr else "", False
|
|
276
275
|
|
|
277
276
|
|
|
278
277
|
async def execute_command_async(command: Union[str, List[str]]) -> str:
|
|
@@ -287,17 +286,16 @@ async def execute_command_async(command: Union[str, List[str]]) -> str:
|
|
|
287
286
|
try:
|
|
288
287
|
if isinstance(command, str):
|
|
289
288
|
command = command.split()
|
|
290
|
-
print(command)
|
|
291
289
|
result = await asyncio.create_subprocess_exec(
|
|
292
290
|
*command, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE
|
|
293
291
|
)
|
|
294
292
|
stdout, stderr = await result.communicate()
|
|
295
293
|
return stdout.decode(), True
|
|
296
294
|
except subprocess.CalledProcessError as e:
|
|
297
|
-
|
|
295
|
+
print(
|
|
298
296
|
f"异步执行命令失败,命令: {command},错误信息: {e.stderr.decode() if e.stderr else str(e)}"
|
|
299
297
|
)
|
|
300
|
-
return
|
|
298
|
+
return e.stderr.decode() if e.stderr else "", False
|
|
301
299
|
|
|
302
300
|
|
|
303
301
|
def get_variable_type(variable: object) -> str:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|