增加报错的具体显示内容,方便调试

This commit is contained in:
xaoyaoo 2024-01-22 18:30:33 +08:00
parent d3f8288911
commit 61047c1ac9
2 changed files with 74 additions and 65 deletions

View File

@ -14,7 +14,7 @@ import shutil
from flask import Flask, request, render_template, g, Blueprint, send_file, make_response, session from flask import Flask, request, render_template, g, Blueprint, send_file, make_response, session
from pywxdump import analyzer, read_img_dat, read_audio, get_wechat_db, get_core_db from pywxdump import analyzer, read_img_dat, read_audio, get_wechat_db, get_core_db
from pywxdump.api.rjson import ReJson, RqJson from pywxdump.api.rjson import ReJson, RqJson
from pywxdump.api.utils import read_session, save_session from pywxdump.api.utils import read_session, save_session, error9999
from pywxdump import read_info, VERSION_LIST, batch_decrypt, BiasAddr, merge_db, decrypt_merge from pywxdump import read_info, VERSION_LIST, batch_decrypt, BiasAddr, merge_db, decrypt_merge
import pywxdump import pywxdump
@ -25,19 +25,19 @@ api.debug = False
@api.route('/api/init', methods=["GET", 'POST']) @api.route('/api/init', methods=["GET", 'POST'])
@error9999
def init(): def init():
""" """
初始化 设置微信数据库路径图片路径解密需要的数据库 初始化 设置微信数据库路径图片路径解密需要的数据库
:return: :return:
""" """
try:
msg_path = request.json.get("msg_path", "").strip() msg_path = request.json.get("msg_path", "").strip()
micro_path = request.json.get("micro_path", "").strip() micro_path = request.json.get("micro_path", "").strip()
media_path = request.json.get("media_path", "").strip() media_path = request.json.get("media_path", "").strip()
wx_path = request.json.get("wx_path", "").strip() wx_path = request.json.get("wx_path", "").strip()
key = request.json.get("key", "").strip() key = request.json.get("key", "").strip()
my_wxid = request.json.get("my_wxid", "").strip() my_wxid = request.json.get("my_wxid", "").strip()
raise Exception("test")
if key: # 如果key不为空表示是解密模式 if key: # 如果key不为空表示是解密模式
if not wx_path: if not wx_path:
return ReJson(1002) return ReJson(1002)
@ -99,10 +99,6 @@ def init():
} }
return ReJson(0, rdata) return ReJson(0, rdata)
except Exception as e:
rdata = f"{e.__traceback__.tb_lineno}____{e.__traceback__.tb_frame.f_globals['__file__']}____{e}"
return ReJson(9999, body=rdata)
@api.route('/api/version', methods=["GET", 'POST']) @api.route('/api/version', methods=["GET", 'POST'])
def version(): def version():

View File

@ -6,6 +6,10 @@
# Date: 2024/01/16 # Date: 2024/01/16
# ------------------------------------------------------------------------------- # -------------------------------------------------------------------------------
import json import json
import logging
import traceback
from .rjson import ReJson
from functools import wraps
def read_session(session_file, arg): def read_session(session_file, arg):
@ -26,5 +30,14 @@ def save_session(session_file, arg, value):
return True return True
if __name__ == '__main__': def error9999(func):
pass @wraps(func)
def wrapper(*args, **kwargs):
try:
return func(*args, **kwargs)
except Exception as e:
traceback_data = traceback.format_exc()
rdata = f"{traceback_data}"
return ReJson(9999, body=rdata)
return wrapper