ezKit 1.1.0__py3-none-any.whl → 1.1.2__py3-none-any.whl
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.
- ezKit/utils.py +47 -3
- {ezKit-1.1.0.dist-info → ezKit-1.1.2.dist-info}/METADATA +1 -1
- {ezKit-1.1.0.dist-info → ezKit-1.1.2.dist-info}/RECORD +6 -6
- {ezKit-1.1.0.dist-info → ezKit-1.1.2.dist-info}/LICENSE +0 -0
- {ezKit-1.1.0.dist-info → ezKit-1.1.2.dist-info}/WHEEL +0 -0
- {ezKit-1.1.0.dist-info → ezKit-1.1.2.dist-info}/top_level.txt +0 -0
ezKit/utils.py
CHANGED
@@ -5,10 +5,11 @@ import os
|
|
5
5
|
import subprocess
|
6
6
|
import time
|
7
7
|
from copy import deepcopy
|
8
|
-
from multiprocessing import Pool
|
8
|
+
from multiprocessing import Pool, Process
|
9
9
|
from multiprocessing.pool import ThreadPool
|
10
10
|
from pathlib import Path
|
11
11
|
from shutil import rmtree
|
12
|
+
from threading import Thread
|
12
13
|
from typing import Callable
|
13
14
|
from uuid import uuid4
|
14
15
|
|
@@ -1137,7 +1138,7 @@ def process_pool(
|
|
1137
1138
|
process_func: Callable = None,
|
1138
1139
|
process_data: any = None,
|
1139
1140
|
process_num: int = 2,
|
1140
|
-
thread: bool =
|
1141
|
+
thread: bool = False,
|
1141
1142
|
debug: bool = False,
|
1142
1143
|
**kwargs
|
1143
1144
|
) -> list | bool:
|
@@ -1162,7 +1163,7 @@ def process_pool(
|
|
1162
1163
|
logger.info(f"data: {_data}") if debug is True else next
|
1163
1164
|
|
1164
1165
|
# 执行函数
|
1165
|
-
if thread
|
1166
|
+
if v_true(thread, bool):
|
1166
1167
|
# 多线程
|
1167
1168
|
logger.info(f"execute multi thread ......") if debug is True else next
|
1168
1169
|
with ThreadPool(process_num, **kwargs) as p:
|
@@ -1178,6 +1179,27 @@ def process_pool(
|
|
1178
1179
|
return False
|
1179
1180
|
|
1180
1181
|
|
1182
|
+
def new_process(
|
1183
|
+
process_func: Callable = None,
|
1184
|
+
process_data: any = None,
|
1185
|
+
thread: bool = False,
|
1186
|
+
daemon: bool = True,
|
1187
|
+
debug: bool = False,
|
1188
|
+
**kwargs
|
1189
|
+
) -> Thread | Process | bool:
|
1190
|
+
try:
|
1191
|
+
if v_true(thread, bool):
|
1192
|
+
process = Thread(target=process_func, args=process_data, **kwargs)
|
1193
|
+
else:
|
1194
|
+
process = Process(target=process_func, args=process_data, **kwargs)
|
1195
|
+
process.daemon = daemon
|
1196
|
+
process.start()
|
1197
|
+
return process
|
1198
|
+
except Exception as e:
|
1199
|
+
logger.exception(e) if v_true(debug, bool) else next
|
1200
|
+
return False
|
1201
|
+
|
1202
|
+
|
1181
1203
|
# --------------------------------------------------------------------------------------------------
|
1182
1204
|
|
1183
1205
|
|
@@ -1273,3 +1295,25 @@ def load_toml_file(file: str = None, debug: bool = False):
|
|
1273
1295
|
logger.error(f'{info}[失败]')
|
1274
1296
|
logger.exception(e) if v_true(debug, bool) else next
|
1275
1297
|
return None
|
1298
|
+
|
1299
|
+
|
1300
|
+
def git_clone(git_repository: str = None, local_repository: str = None, delete: bool = False, debug: bool = False) -> bool:
|
1301
|
+
try:
|
1302
|
+
info = 'Git克隆'
|
1303
|
+
# 获取应用程序Git仓库
|
1304
|
+
logger.info(f'[{info}]Git仓库: {git_repository}')
|
1305
|
+
logger.info(f'[{info}]本地仓库: {local_repository}')
|
1306
|
+
logger.info(f'[{info}]开始克隆')
|
1307
|
+
# 删除本地仓库
|
1308
|
+
delete_directory(local_repository) if v_true(delete, bool) else next
|
1309
|
+
result = shell(f'git clone {git_repository} {local_repository}', universal_newlines=True, stderr=subprocess.PIPE, stdout=subprocess.PIPE)
|
1310
|
+
if result.returncode == 0:
|
1311
|
+
logger.success(f'[{info}]克隆成功')
|
1312
|
+
return True
|
1313
|
+
else:
|
1314
|
+
logger.error(f'[{info}]克隆失败')
|
1315
|
+
return False
|
1316
|
+
except Exception as e:
|
1317
|
+
logger.error(f'[{info}]克隆失败')
|
1318
|
+
logger.exception(e) if v_true(debug, bool) else next
|
1319
|
+
return False
|
@@ -9,12 +9,12 @@ ezKit/plots.py,sha256=QUtoVfZ49ZSNcY8gcQ2TYVkMjDDzoW-myMtqTi5WN2U,5322
|
|
9
9
|
ezKit/redis.py,sha256=pY4SPlcgQ7S8IeY2xoDpxy-xCZxzZQrQJNAoWRsC1dI,1773
|
10
10
|
ezKit/reports.py,sha256=dBBggggCCLuk5YD6SjdUPuxTr3wiJojP3lA7dQfg6Pk,8898
|
11
11
|
ezKit/sendemail.py,sha256=PItznLBcZ6Om8NU7rep69m3QNZ9YkmOovup7pPGyY58,4840
|
12
|
-
ezKit/utils.py,sha256=
|
12
|
+
ezKit/utils.py,sha256=59kM_fi8Bx3NakmXPjwdDtP51GFNbVAAs8u93Fd70s0,42102
|
13
13
|
ezKit/weixin.py,sha256=Sxm_yNEvcztFNCZyjZetVwqxoGoL2PJHlQABIWkd1pk,5075
|
14
14
|
ezKit/xftp.py,sha256=qbCqFcGe22TDBSisj0Zoz78tnydDWoOfvywWpXdfaGw,6982
|
15
15
|
ezKit/zabbix.py,sha256=EF0-tQ1FTMBqawXKf3JEoPYoAJmYENXXIm9T5ICSdHM,32345
|
16
|
-
ezKit-1.1.
|
17
|
-
ezKit-1.1.
|
18
|
-
ezKit-1.1.
|
19
|
-
ezKit-1.1.
|
20
|
-
ezKit-1.1.
|
16
|
+
ezKit-1.1.2.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
17
|
+
ezKit-1.1.2.dist-info/METADATA,sha256=qUFiixoXP7NcXaWMpUPXpI7QHhfy8GRC-xWULNnlsOo,226
|
18
|
+
ezKit-1.1.2.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
|
19
|
+
ezKit-1.1.2.dist-info/top_level.txt,sha256=aYLB_1WODsqNTsTFWcKP-BN0KCTKcV-HZJ4zlHkCFw8,6
|
20
|
+
ezKit-1.1.2.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|