Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
test_platform
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Wallen姚文辉
test_platform
Commits
cb0ac646
Commit
cb0ac646
authored
Apr 18, 2025
by
Wallen姚文辉
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
处理改为多线程
parent
2fa437de
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
8 deletions
+20
-8
a.py
a.py
+4
-0
codeCover.py
controller/codeCover.py
+16
-8
No files found.
a.py
0 → 100644
View file @
cb0ac646
res
=
'[]'
for
i
in
range
(
18
):
res
+=
";err"
print
(
res
)
\ No newline at end of file
controller/codeCover.py
View file @
cb0ac646
...
...
@@ -6,6 +6,8 @@ import copy
from
model.Model
import
CodeCoverLog
from
manager.serverCenter
import
server
from
manager.tools
import
sqlOrmToJson
,
get_config
from
concurrent.futures
import
ThreadPoolExecutor
# import threading
diff_path
=
get_config
()[
'other'
][
'gitdiff'
]
...
...
@@ -21,22 +23,23 @@ lajiluoji={
}
def
getFileCover
(
key
,
a1
,
a2
,
a3
):
def
getFileCover
(
key
,
a1
,
a2
,
a3
,
nowPath
):
res
=
requests
.
post
(
diff_path
+
'/get_gitcode'
,
json
=
{
'input1'
:
a1
,
'input2'
:
a2
,
'input3'
:
a3
})
.
json
()[
"data"
][
"result"
]
print
(
res
)
data
=
[]
for
key_
,
value
in
res
.
items
():
data
.
append
({
"path"
:
key_
.
replace
(
lajiluoji
[
a3
],
''
),
"change_fun"
:
value
,
"cover_function"
:
0
,
'cover_line'
:
0
,
'chang_line'
:
0
})
for
each
in
data
:
def
get_
(
each
):
res
=
requests
.
get
(
"https://test-code-coverage.galaxy-immi.com/"
+
key
+
each
[
'path'
]
+
".html"
)
soup
=
BeautifulSoup
(
res
.
text
,
"html.parser"
)
functionInfo
=
[]
m
=
soup
.
find
(
"tbody"
)
.
find_all
(
"tr"
)
try
:
m
=
soup
.
find
(
"tbody"
)
.
find_all
(
"tr"
)
except
:
return
for
i
in
m
:
f
=
i
.
find_all
(
"td"
)
if
f
[
0
]
.
find
(
"a"
):
...
...
@@ -66,6 +69,12 @@ def getFileCover(key,a1,a2,a3):
if
i
[
'covered'
]:
each
[
'cover_function'
]
+=
1
each
[
'cover_line'
]
+=
len
(
i
[
'lines'
])
executor
=
ThreadPoolExecutor
(
max_workers
=
20
)
for
each
in
data
:
if
(
nowPath
in
each
[
'path'
]):
executor
.
submit
(
get_
,
each
)
executor
.
shutdown
(
wait
=
True
)
del
(
executor
)
return
data
...
...
@@ -78,9 +87,9 @@ def find_():
path
=
request
.
args
.
get
(
"path"
)
info
=
db
.
session
.
query
(
CodeCoverLog
)
.
filter
(
CodeCoverLog
.
user_id
==
session
.
get
(
'id'
),
CodeCoverLog
.
product_key
==
key
)
.
first
()
db
.
session
.
close
()
data
=
getFileCover
(
key
,
info
.
commit_source
,
info
.
commit_target
,
info
.
product
)
#
data=getFileCover(key,info.commit_source,info.commit_target,info.product)
try
:
data
=
getFileCover
(
key
,
info
.
commit_source
,
info
.
commit_target
,
info
.
product
)
data
=
getFileCover
(
key
,
info
.
commit_source
,
info
.
commit_target
,
info
.
product
,
path
)
except
:
return
jsonify
({
"code"
:
500
,
"message"
:
"获取差异文件接口异常"
}),
500
res
=
requests
.
get
(
...
...
@@ -170,7 +179,6 @@ def fileInfo():
info
=
db
.
session
.
query
(
CodeCoverLog
)
.
filter
(
CodeCoverLog
.
user_id
==
session
.
get
(
'id'
),
CodeCoverLog
.
product_key
==
key
)
.
first
()
db
.
session
.
close
()
res
=
requests
.
post
(
diff_path
+
'/get_gitcode'
,
json
=
{
'input1'
:
info
.
commit_source
,
'input2'
:
info
.
commit_target
,
'input3'
:
info
.
product
})
.
json
()[
'data'
][
'result'
]
print
(
res
)
data
=
[]
for
key_
,
value
in
res
.
items
():
data
.
append
({
"path"
:
key_
.
replace
(
lajiluoji
[
info
.
product
],
''
),
"change_fun"
:
value
,
"cover_function"
:
0
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment