Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
debomatic-webui
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
debomatic-webui-admins
debomatic-webui
Commits
27afaa51
Commit
27afaa51
authored
Jul 13, 2014
by
Leo Iannacone
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
parse log files in post_build hooks
parent
70395d9a
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
72 additions
and
1 deletion
+72
-1
debomatic-modules/JSONLogger.py
debomatic-modules/JSONLogger.py
+72
-1
No files found.
debomatic-modules/JSONLogger.py
View file @
27afaa51
...
...
@@ -28,6 +28,7 @@ import os
from
time
import
time
from
json
import
dumps
as
toJSON
from
json
import
load
as
fileToJSON
from
collections
import
defaultdict
class
DebomaticModule_JSONLogger
:
...
...
@@ -113,10 +114,80 @@ class DebomaticModule_JSONLogger:
status
=
self
.
_get_package_status
(
args
)
status
[
'status'
]
=
'build'
status
[
'success'
]
=
False
status
[
'tags'
]
=
{}
resultdir
=
os
.
path
.
join
(
args
[
'directory'
],
'pool'
,
args
[
'package'
])
for
filename
in
os
.
listdir
(
resultdir
):
if
filename
.
endswith
(
'.dsc'
):
status
[
'success'
]
=
True
break
else
:
full_path
=
os
.
path
.
join
(
resultdir
,
filename
)
tag
=
LogParser
(
full_path
).
parse
()
if
tag
:
status
[
'tags'
][
filename
]
=
tag
self
.
_write_package_json
(
args
,
status
)
self
.
_write_json_logfile
(
args
,
status
)
class
LogParser
():
def
__init__
(
self
,
file_path
):
self
.
file
=
file_path
self
.
basename
=
os
.
path
.
basename
(
file_path
)
self
.
extension
=
self
.
basename
.
split
(
'.'
).
pop
()
def
parse
(
self
):
if
not
os
.
path
.
isfile
(
self
.
file
):
return
None
result
=
None
if
self
.
extension
==
'lintian'
:
result
=
self
.
parse_lintian
()
elif
self
.
extension
==
'autopkgtest'
:
result
=
self
.
parse_autopkgtest
()
elif
self
.
extension
==
'piuparts'
:
result
=
self
.
parse_piuparts
()
return
result
def
parse_lintian
(
self
):
tags
=
defaultdict
(
int
)
with
open
(
self
.
file
,
'r'
)
as
fd
:
for
line
in
fd
:
if
len
(
line
)
>=
2
and
line
[
0
]
!=
'N'
and
line
[
1
]
==
':'
:
tags
[
line
[
0
]]
+=
1
return
_from_tags_to_result
(
tags
)
def
parse_autopkgtest
(
self
):
tags
=
defaultdict
(
int
)
with
open
(
self
.
file
,
'r'
)
as
fd
:
found
=
False
pass_next
=
False
for
line
in
fd
:
if
pass_next
:
pass_next
=
False
continue
if
not
found
and
line
.
find
(
'Tests summary'
)
>=
0
:
found
=
True
pass_next
=
True
elif
found
and
len
(
line
.
split
())
>=
2
:
info
=
line
.
split
()[
1
]
if
info
==
'PASS'
:
continue
tags
[
info
[
0
]]
+=
1
elif
found
and
line
==
'
\
n
'
:
break
return
_from_tags_to_result
(
tags
)
def
parse_piuparts
(
self
):
with
open
(
self
.
file
,
'r'
)
as
fd
:
last_line
=
fd
.
readlines
()[
-
1
]
if
last_line
.
find
(
'ERROR:'
)
>=
0
:
return
'E'
return
None
def
_from_tags_to_result
(
tags
):
keys
=
sorted
(
list
(
tags
.
keys
()))
result
=
[]
for
k
in
keys
:
result
.
append
(
"%s%s"
%
(
k
,
tags
[
k
]))
if
len
(
result
)
>
0
:
return
' '
.
join
(
result
)
return
None
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