2
2
3
3
import lyrebird
4
4
from lyrebird .mock import context
5
+ from lyrebird .log import get_logger
5
6
6
7
from lyrebird_api_coverage .client .context import app_context
7
8
from lyrebird_api_coverage .client .jsonscheme import check_schema , check_url_redundant
17
18
# 默认base 文件
18
19
DEFAULT_BASE = os .path .join (PLUGINS_CONF_DIR , 'base.json' )
19
20
21
+ logger = get_logger ()
22
+
20
23
'''
21
24
Base 处理器
22
25
'''
@@ -31,9 +34,10 @@ def get_base_source(self):
31
34
json_obj = context .make_fail_response ('暂无默认文件,需手动导入base文件' )
32
35
# 检查不为空的base文件是否符合标准,符合标准check_base返回0
33
36
else :
34
- if self .check_base (json_obj ):
37
+ error_response = self .check_base (json_obj )
38
+ if error_response :
35
39
# 遇到异常就返回
36
- return self . check_base ( json_obj )
40
+ return error_response
37
41
return json_obj
38
42
39
43
'''
@@ -46,6 +50,12 @@ def check_base(self, obj):
46
50
# 检查url是否有重复项存在
47
51
redundant_items = check_url_redundant (obj )
48
52
if redundant_items :
53
+ redundant_items_str = '\n ' .join (redundant_items )
54
+ logger .error (
55
+ f'API-Coverage import API file error: Duplicated API\n '
56
+ f'{ len (redundant_items )} duplicated API:\n '
57
+ f'{ redundant_items_str } \n '
58
+ )
49
59
resp = context .make_fail_response ('导入API有重复项' + str (redundant_items ))
50
60
lyrebird .publish ('api_coverage' , 'error' , name = 'import_base' )
51
61
return resp
@@ -57,7 +67,6 @@ def check_base(self, obj):
57
67
app_context .version_code = obj .get ('version_code' )
58
68
return
59
69
except Exception as e :
60
- resp = context .make_fail_response (
61
- '导入文件有误:' + '\n ' + e .__getattribute__ ('message' ) + '\n ' + '!请重新import base' )
70
+ resp = context .make_fail_response (f'导入文件有误: { e } \n 请重新import base' )
62
71
63
72
return resp
0 commit comments