xtn-tools-pro 1.0.0.8.6__py3-none-any.whl → 1.0.0.8.8__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.
- xtn_tools_pro/flask_demo/__init__.py +10 -0
- xtn_tools_pro/flask_demo/ai_server_api/__init__.py +10 -0
- xtn_tools_pro/flask_demo/ai_server_api/app/__init__.py +38 -0
- xtn_tools_pro/flask_demo/ai_server_api/app/app.py +19 -0
- xtn_tools_pro/flask_demo/ai_server_api/recognize_ai_server_pro.py +33 -0
- xtn_tools_pro/flask_demo/cli.py +90 -0
- xtn_tools_pro/flask_demo/templates/__init__.py +10 -0
- xtn_tools_pro/flask_demo/templates/app/__init__.py +38 -0
- xtn_tools_pro/flask_demo/templates/app/app.py +19 -0
- xtn_tools_pro/flask_demo/templates/recognize_ai_server_pro.py +33 -0
- xtn_tools_pro/task_pro/go_fun_v3.py +0 -8
- {xtn_tools_pro-1.0.0.8.6.dist-info → xtn_tools_pro-1.0.0.8.8.dist-info}/METADATA +1 -1
- {xtn_tools_pro-1.0.0.8.6.dist-info → xtn_tools_pro-1.0.0.8.8.dist-info}/RECORD +17 -6
- xtn_tools_pro-1.0.0.8.8.dist-info/entry_points.txt +2 -0
- {xtn_tools_pro-1.0.0.8.6.dist-info → xtn_tools_pro-1.0.0.8.8.dist-info}/LICENSE +0 -0
- {xtn_tools_pro-1.0.0.8.6.dist-info → xtn_tools_pro-1.0.0.8.8.dist-info}/WHEEL +0 -0
- {xtn_tools_pro-1.0.0.8.6.dist-info → xtn_tools_pro-1.0.0.8.8.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,10 @@
|
|
1
|
+
#!/usr/bin/env python
|
2
|
+
# -*- coding: utf-8 -*-
|
3
|
+
|
4
|
+
# 说明:
|
5
|
+
# 程序说明xxxxxxxxxxxxxxxxxxx
|
6
|
+
# History:
|
7
|
+
# Date Author Version Modification
|
8
|
+
# --------------------------------------------------------------------------------------------------
|
9
|
+
# 2025/3/13 xiatn V00.01.000 新建
|
10
|
+
# --------------------------------------------------------------------------------------------------
|
@@ -0,0 +1,10 @@
|
|
1
|
+
#!/usr/bin/env python
|
2
|
+
# -*- coding: utf-8 -*-
|
3
|
+
|
4
|
+
# 说明:
|
5
|
+
# 程序说明xxxxxxxxxxxxxxxxxxx
|
6
|
+
# History:
|
7
|
+
# Date Author Version Modification
|
8
|
+
# --------------------------------------------------------------------------------------------------
|
9
|
+
# 2025/3/13 xiatn V00.01.000 新建
|
10
|
+
# --------------------------------------------------------------------------------------------------
|
@@ -0,0 +1,38 @@
|
|
1
|
+
#!/usr/bin/env python
|
2
|
+
# -*- coding: utf-8 -*-
|
3
|
+
|
4
|
+
from .app import Flask, JSONEncoder
|
5
|
+
|
6
|
+
|
7
|
+
def register_blueprint(app):
|
8
|
+
# 注册蓝图
|
9
|
+
from app.api.v1 import create_blueprint_v1
|
10
|
+
# url_prefix 前缀
|
11
|
+
app.register_blueprint(create_blueprint_v1(), url_prefix="/v1")
|
12
|
+
|
13
|
+
|
14
|
+
def register_mongodb(app):
|
15
|
+
return
|
16
|
+
from app.models.base import mongo_db_01
|
17
|
+
mongo_db_01.init_app(app, uri=app.config['MONGO_URI_01'])
|
18
|
+
|
19
|
+
|
20
|
+
def register_redisdb(app):
|
21
|
+
return
|
22
|
+
from app.models.base import redis_db_01,redis_db_02
|
23
|
+
redis_db.init_app(app)
|
24
|
+
|
25
|
+
|
26
|
+
def create_app():
|
27
|
+
app = Flask(__name__)
|
28
|
+
app.json_encoder = JSONEncoder
|
29
|
+
app.config.from_object('app.config.secure')
|
30
|
+
app.config.from_object('app.config.setting')
|
31
|
+
|
32
|
+
# 注册蓝图
|
33
|
+
register_blueprint(app)
|
34
|
+
# 注册 mongodb
|
35
|
+
register_mongodb(app)
|
36
|
+
# 注册 redis
|
37
|
+
register_redisdb(app)
|
38
|
+
return app
|
@@ -0,0 +1,19 @@
|
|
1
|
+
#!/usr/bin/env python
|
2
|
+
# -*- coding: utf-8 -*-
|
3
|
+
|
4
|
+
from flask import Flask as _Flask
|
5
|
+
from app.libs.error_code import ServerError500
|
6
|
+
from flask.json import JSONEncoder as _JSONEncoder
|
7
|
+
|
8
|
+
|
9
|
+
class JSONEncoder(_JSONEncoder):
|
10
|
+
# 改写 flask的JSONEncoder
|
11
|
+
def default(self, o):
|
12
|
+
if hasattr(o, 'keys') and hasattr(o, '__getitem__'):
|
13
|
+
return dict(o)
|
14
|
+
raise ServerError500()
|
15
|
+
|
16
|
+
|
17
|
+
class Flask(_Flask):
|
18
|
+
# json_encoder = JSONEncoder
|
19
|
+
pass
|
@@ -0,0 +1,33 @@
|
|
1
|
+
#!/usr/bin/env python
|
2
|
+
# -*- coding: utf-8 -*-
|
3
|
+
|
4
|
+
from app import create_app
|
5
|
+
from app.libs.error import APIException
|
6
|
+
from werkzeug.exceptions import HTTPException
|
7
|
+
from app.libs.error_code import ServerError500, MethodException
|
8
|
+
|
9
|
+
app = create_app()
|
10
|
+
|
11
|
+
|
12
|
+
@app.errorhandler(Exception)
|
13
|
+
def framework_error(e):
|
14
|
+
print("发生错误啦 => ", e)
|
15
|
+
if isinstance(e, APIException):
|
16
|
+
return e
|
17
|
+
elif isinstance(e, HTTPException):
|
18
|
+
if e.code == 405:
|
19
|
+
# 请求的URL不允许使用该方法
|
20
|
+
return MethodException()
|
21
|
+
else:
|
22
|
+
code = e.code
|
23
|
+
msg = e.description
|
24
|
+
error_code = 4999
|
25
|
+
return APIException(msg + "HTTP Exception 4999", code, error_code)
|
26
|
+
else:
|
27
|
+
print(e)
|
28
|
+
return ServerError500()
|
29
|
+
|
30
|
+
|
31
|
+
if __name__ == '__main__':
|
32
|
+
app.run(host="0.0.0.0", port=10089, debug=True)
|
33
|
+
|
@@ -0,0 +1,90 @@
|
|
1
|
+
#!/usr/bin/env python
|
2
|
+
# -*- coding: utf-8 -*-
|
3
|
+
|
4
|
+
# 说明:
|
5
|
+
# 程序说明xxxxxxxxxxxxxxxxxxx
|
6
|
+
# History:
|
7
|
+
# Date Author Version Modification
|
8
|
+
# --------------------------------------------------------------------------------------------------
|
9
|
+
# 2025/3/13 xiatn V00.01.000 新建
|
10
|
+
# --------------------------------------------------------------------------------------------------
|
11
|
+
import os
|
12
|
+
import shutil
|
13
|
+
import argparse
|
14
|
+
|
15
|
+
|
16
|
+
def replace_placeholders(file_path, project_name):
|
17
|
+
"""
|
18
|
+
替换文件中的占位符 {{ project_name }} 为实际的项目名称
|
19
|
+
"""
|
20
|
+
with open(file_path, 'r', encoding='utf-8') as file:
|
21
|
+
content = file.read()
|
22
|
+
|
23
|
+
# 替换占位符
|
24
|
+
content = content.replace("{{ project_name }}", project_name)
|
25
|
+
|
26
|
+
with open(file_path, 'w', encoding='utf-8') as file:
|
27
|
+
file.write(content)
|
28
|
+
|
29
|
+
|
30
|
+
def create_project(args):
|
31
|
+
"""
|
32
|
+
创建 flask 常用项目结构
|
33
|
+
"""
|
34
|
+
# 获取当前目录
|
35
|
+
project_name = args.obj_name
|
36
|
+
current_dir = os.getcwd()
|
37
|
+
project_dir = os.path.join(current_dir, project_name)
|
38
|
+
|
39
|
+
# 创建项目目录
|
40
|
+
os.makedirs(project_dir, exist_ok=True)
|
41
|
+
|
42
|
+
# 复制模板文件到项目目录
|
43
|
+
template_dir = os.path.join(os.path.dirname(__file__), 'templates')
|
44
|
+
for item in os.listdir(template_dir):
|
45
|
+
src = os.path.join(template_dir, item)
|
46
|
+
dst = os.path.join(project_dir, item)
|
47
|
+
|
48
|
+
if os.path.isdir(src):
|
49
|
+
shutil.copytree(src, dst) # 判断是否为目录,递归地复制整个目录树
|
50
|
+
else:
|
51
|
+
shutil.copy2(src, dst)
|
52
|
+
|
53
|
+
# 如果是文件,替换占位符
|
54
|
+
if os.path.isfile(dst):
|
55
|
+
replace_placeholders(dst, project_name)
|
56
|
+
|
57
|
+
|
58
|
+
class CustomArgumentParser(argparse.ArgumentParser):
|
59
|
+
def error(self, message):
|
60
|
+
# 自定义错误消息
|
61
|
+
# self.print_help()
|
62
|
+
print("错误:缺少必需的参数!")
|
63
|
+
print("请使用以下格式运行:python cli.py startobj <项目名称>")
|
64
|
+
self.exit(2) # 退出程序,返回状态码 2
|
65
|
+
|
66
|
+
|
67
|
+
def main():
|
68
|
+
"""
|
69
|
+
命令行入口
|
70
|
+
"""
|
71
|
+
parser = CustomArgumentParser(description="创建一个常用的flask项目结构") # 创建 ArgumentParser 对象
|
72
|
+
subparsers = parser.add_subparsers(title="命令", dest="command")
|
73
|
+
|
74
|
+
parser_startobj = subparsers.add_parser('startobj', help="项目名称") # 添加位置参数
|
75
|
+
parser_startobj.add_argument("obj_name", type=str, help="项目的名称")
|
76
|
+
parser_startobj.set_defaults(func=create_project) # 绑定处理函数
|
77
|
+
|
78
|
+
args = parser.parse_args()
|
79
|
+
|
80
|
+
# 如果没有提供子命令,显示帮助信息
|
81
|
+
if not hasattr(args, "func"):
|
82
|
+
parser.print_help()
|
83
|
+
return
|
84
|
+
|
85
|
+
# 调用子命令对应的处理函数
|
86
|
+
args.func(args)
|
87
|
+
|
88
|
+
|
89
|
+
if __name__ == "__main__":
|
90
|
+
main()
|
@@ -0,0 +1,10 @@
|
|
1
|
+
#!/usr/bin/env python
|
2
|
+
# -*- coding: utf-8 -*-
|
3
|
+
|
4
|
+
# 说明:
|
5
|
+
# 程序说明xxxxxxxxxxxxxxxxxxx
|
6
|
+
# History:
|
7
|
+
# Date Author Version Modification
|
8
|
+
# --------------------------------------------------------------------------------------------------
|
9
|
+
# 2025/3/13 xiatn V00.01.000 新建
|
10
|
+
# --------------------------------------------------------------------------------------------------
|
@@ -0,0 +1,38 @@
|
|
1
|
+
#!/usr/bin/env python
|
2
|
+
# -*- coding: utf-8 -*-
|
3
|
+
|
4
|
+
from .app import Flask, JSONEncoder
|
5
|
+
|
6
|
+
|
7
|
+
def register_blueprint(app):
|
8
|
+
# 注册蓝图
|
9
|
+
from app.api.v1 import create_blueprint_v1
|
10
|
+
# url_prefix 前缀
|
11
|
+
app.register_blueprint(create_blueprint_v1(), url_prefix="/v1")
|
12
|
+
|
13
|
+
|
14
|
+
def register_mongodb(app):
|
15
|
+
return
|
16
|
+
from app.models.base import mongo_db_01
|
17
|
+
mongo_db_01.init_app(app, uri=app.config['MONGO_URI_01'])
|
18
|
+
|
19
|
+
|
20
|
+
def register_redisdb(app):
|
21
|
+
return
|
22
|
+
from app.models.base import redis_db_01,redis_db_02
|
23
|
+
redis_db.init_app(app)
|
24
|
+
|
25
|
+
|
26
|
+
def create_app():
|
27
|
+
app = Flask(__name__)
|
28
|
+
app.json_encoder = JSONEncoder
|
29
|
+
app.config.from_object('app.config.secure')
|
30
|
+
app.config.from_object('app.config.setting')
|
31
|
+
|
32
|
+
# 注册蓝图
|
33
|
+
register_blueprint(app)
|
34
|
+
# 注册 mongodb
|
35
|
+
register_mongodb(app)
|
36
|
+
# 注册 redis
|
37
|
+
register_redisdb(app)
|
38
|
+
return app
|
@@ -0,0 +1,19 @@
|
|
1
|
+
#!/usr/bin/env python
|
2
|
+
# -*- coding: utf-8 -*-
|
3
|
+
|
4
|
+
from flask import Flask as _Flask
|
5
|
+
from app.libs.error_code import ServerError500
|
6
|
+
from flask.json import JSONEncoder as _JSONEncoder
|
7
|
+
|
8
|
+
|
9
|
+
class JSONEncoder(_JSONEncoder):
|
10
|
+
# 改写 flask的JSONEncoder
|
11
|
+
def default(self, o):
|
12
|
+
if hasattr(o, 'keys') and hasattr(o, '__getitem__'):
|
13
|
+
return dict(o)
|
14
|
+
raise ServerError500()
|
15
|
+
|
16
|
+
|
17
|
+
class Flask(_Flask):
|
18
|
+
# json_encoder = JSONEncoder
|
19
|
+
pass
|
@@ -0,0 +1,33 @@
|
|
1
|
+
#!/usr/bin/env python
|
2
|
+
# -*- coding: utf-8 -*-
|
3
|
+
|
4
|
+
from app import create_app
|
5
|
+
from app.libs.error import APIException
|
6
|
+
from werkzeug.exceptions import HTTPException
|
7
|
+
from app.libs.error_code import ServerError500, MethodException
|
8
|
+
|
9
|
+
app = create_app()
|
10
|
+
|
11
|
+
|
12
|
+
@app.errorhandler(Exception)
|
13
|
+
def framework_error(e):
|
14
|
+
print("发生错误啦 => ", e)
|
15
|
+
if isinstance(e, APIException):
|
16
|
+
return e
|
17
|
+
elif isinstance(e, HTTPException):
|
18
|
+
if e.code == 405:
|
19
|
+
# 请求的URL不允许使用该方法
|
20
|
+
return MethodException()
|
21
|
+
else:
|
22
|
+
code = e.code
|
23
|
+
msg = e.description
|
24
|
+
error_code = 4999
|
25
|
+
return APIException(msg + "HTTP Exception 4999", code, error_code)
|
26
|
+
else:
|
27
|
+
print(e)
|
28
|
+
return ServerError500()
|
29
|
+
|
30
|
+
|
31
|
+
if __name__ == '__main__':
|
32
|
+
app.run(host="0.0.0.0", port=10089, debug=True)
|
33
|
+
|
@@ -197,7 +197,6 @@ class GoFunTaskV3:
|
|
197
197
|
resp = requests.get(download_url, headers=headers, params=params, timeout=5)
|
198
198
|
json_data = resp.json()
|
199
199
|
result_list = json_data.get("result", [])
|
200
|
-
logger.warning(f"result_list {len(result_list)}")
|
201
200
|
if not result_list or len(result_list) <= 0:
|
202
201
|
# 判断任务响应是否为空
|
203
202
|
download_queue_exist_cnt -= 1
|
@@ -207,15 +206,10 @@ class GoFunTaskV3:
|
|
207
206
|
time.sleep(10)
|
208
207
|
continue
|
209
208
|
|
210
|
-
logger.warning(f"aaaaa {len(result_list)}")
|
211
|
-
|
212
209
|
download_queue_exist_cnt = 10
|
213
210
|
manager_info["gofun_kill_status"] = False
|
214
|
-
logger.warning(f"bbbb {len(result_list)}")
|
215
|
-
logger.warning(f"cccc {result_list[0]}")
|
216
211
|
|
217
212
|
for task_item in result_list:
|
218
|
-
logger.warning(f"task_item {task_item}")
|
219
213
|
phone_item = task_item["phone"]
|
220
214
|
if not phone_item.isdigit(): # 判断是否全是整数(不包括小数点或负号)
|
221
215
|
continue
|
@@ -225,8 +219,6 @@ class GoFunTaskV3:
|
|
225
219
|
logger.critical(f"获取任务请求异常:{e}")
|
226
220
|
time.sleep(2)
|
227
221
|
|
228
|
-
logger.warning(f"wwww {download_not_task_time} {download_task_qsize}")
|
229
|
-
|
230
222
|
def __upload_task(self, upload_queue, ini_info, logger):
|
231
223
|
"""
|
232
224
|
回写任务
|
@@ -6,13 +6,23 @@ xtn_tools_pro/db/MongoDB.py,sha256=CljtA5NnutOPL0j2ClrCE4RXW-9N_306D3PAdRANmuk,5
|
|
6
6
|
xtn_tools_pro/db/MysqlDB.py,sha256=SBJrcjbZdxmtTKPGwl57NthPhs4uX8J3P6o_rK01O4k,13373
|
7
7
|
xtn_tools_pro/db/RedisDB.py,sha256=YSWxYEPE2jp6r1ZKam2LyPgL0S2S9lGDmt36PLSwThg,6470
|
8
8
|
xtn_tools_pro/db/__init__.py,sha256=Zg91UWS02TO0Ba_0AY56s0oabRy93xLNFkpIIL_6mMM,416
|
9
|
+
xtn_tools_pro/flask_demo/__init__.py,sha256=2hSMIjKC8-T_9aTJU35DjkwWKa1-ZzMgwfFajs69TWI,418
|
10
|
+
xtn_tools_pro/flask_demo/cli.py,sha256=Dmfr1_o38vzWfKFCititljyy6C2LvwWsBAJZGspmU1U,2896
|
11
|
+
xtn_tools_pro/flask_demo/ai_server_api/__init__.py,sha256=2hSMIjKC8-T_9aTJU35DjkwWKa1-ZzMgwfFajs69TWI,418
|
12
|
+
xtn_tools_pro/flask_demo/ai_server_api/recognize_ai_server_pro.py,sha256=l3VGFGGSVh2PjWodwOGCWfdCQ6ERXf3ZIccURIxUYqk,896
|
13
|
+
xtn_tools_pro/flask_demo/ai_server_api/app/__init__.py,sha256=GtoReIEP40zQZUH8yzouon-YWLctoexY_DlW-eIbojw,912
|
14
|
+
xtn_tools_pro/flask_demo/ai_server_api/app/app.py,sha256=1X6pp3yD5iygTv6SRJGwEZEFTQZw-oSaO2i45T2oyKM,476
|
15
|
+
xtn_tools_pro/flask_demo/templates/__init__.py,sha256=2hSMIjKC8-T_9aTJU35DjkwWKa1-ZzMgwfFajs69TWI,418
|
16
|
+
xtn_tools_pro/flask_demo/templates/recognize_ai_server_pro.py,sha256=l3VGFGGSVh2PjWodwOGCWfdCQ6ERXf3ZIccURIxUYqk,896
|
17
|
+
xtn_tools_pro/flask_demo/templates/app/__init__.py,sha256=GtoReIEP40zQZUH8yzouon-YWLctoexY_DlW-eIbojw,912
|
18
|
+
xtn_tools_pro/flask_demo/templates/app/app.py,sha256=1X6pp3yD5iygTv6SRJGwEZEFTQZw-oSaO2i45T2oyKM,476
|
9
19
|
xtn_tools_pro/proxy/XiaoXiangProxy.py,sha256=45SsMZDc-3Ta4THX38vScjaeRBJSp420AJwBeogC_-I,11049
|
10
20
|
xtn_tools_pro/proxy/__init__.py,sha256=WRwh6s2lruMu5buh0ejo9EK54kWT_VQhCsFGNFAmcyo,418
|
11
21
|
xtn_tools_pro/proxy/proxy.py,sha256=No6E1pFY5yx2F4976pXPrLtq-QEVp79KupzcufjSN58,8703
|
12
22
|
xtn_tools_pro/task_pro/__init__.py,sha256=nK3U47hWwE1H875ieEToH9r-jzXHS-PXk8cDstOvRE8,418
|
13
23
|
xtn_tools_pro/task_pro/go_fun.py,sha256=hWEt2uJ9FCvJH7PhVZttS-11A7J6zbRKwX7c5YLYQag,19144
|
14
24
|
xtn_tools_pro/task_pro/go_fun_v2.py,sha256=SgcXgtEBGSVL1V2LyqO0z8Md2H8JZxucYrLLIwqtiLM,18489
|
15
|
-
xtn_tools_pro/task_pro/go_fun_v3.py,sha256=
|
25
|
+
xtn_tools_pro/task_pro/go_fun_v3.py,sha256=PdmT59wTJYS3gYS8d3LQX8JvQcREqfZENiy3MARb0UY,17991
|
16
26
|
xtn_tools_pro/utils/__init__.py,sha256=I1_n_NP23F2lBqlF4EOlnOdLYxM8M4pbn63UhJN1hRE,418
|
17
27
|
xtn_tools_pro/utils/crypto.py,sha256=oyzFqWum_oimUtzhfVCELQhdMjxDbLu-nOWfcNmazcc,4087
|
18
28
|
xtn_tools_pro/utils/file_utils.py,sha256=obaBP7CaBCsXxzqGeWzV2l0yw7vicgKOaXzmpMV8ips,2567
|
@@ -22,8 +32,9 @@ xtn_tools_pro/utils/retry.py,sha256=0wjHsR5DBBKpv4naMfxiky8kprrZes4WURIfFQ4H708,
|
|
22
32
|
xtn_tools_pro/utils/set_data.py,sha256=IthfAclck7AbaxOIKOgJZ2wdcfEmlvC-C63Tywcr4bA,11180
|
23
33
|
xtn_tools_pro/utils/sql.py,sha256=EAKzbkZP7Q09j15Gm6o0_uq0qgQmcCQT6EAawbpp4v0,6263
|
24
34
|
xtn_tools_pro/utils/time_utils.py,sha256=TUtzG61PeVYXhaQd6pBrXAdlz7tBispNIRQRcGhE2No,4859
|
25
|
-
xtn_tools_pro-1.0.0.8.
|
26
|
-
xtn_tools_pro-1.0.0.8.
|
27
|
-
xtn_tools_pro-1.0.0.8.
|
28
|
-
xtn_tools_pro-1.0.0.8.
|
29
|
-
xtn_tools_pro-1.0.0.8.
|
35
|
+
xtn_tools_pro-1.0.0.8.8.dist-info/LICENSE,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
36
|
+
xtn_tools_pro-1.0.0.8.8.dist-info/METADATA,sha256=olzHetclLvOyVR_YM2g9FtCvkPjx8Xz4hgInDvY3jG0,498
|
37
|
+
xtn_tools_pro-1.0.0.8.8.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
|
38
|
+
xtn_tools_pro-1.0.0.8.8.dist-info/entry_points.txt,sha256=t8CtXWOgw7nRDW3XNlZh8MT_P4l8EzsFnyWi5b3ovrc,68
|
39
|
+
xtn_tools_pro-1.0.0.8.8.dist-info/top_level.txt,sha256=jyB3FLDEr8zE1U7wHczTgIbvUpALhR-ULF7RVEO7O2U,14
|
40
|
+
xtn_tools_pro-1.0.0.8.8.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|