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
37be48b0
Commit
37be48b0
authored
Jul 14, 2014
by
Leo Iannacone
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
better code style
parent
1745a989
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
36 deletions
+33
-36
debomatic-modules/JSONLogger.py
debomatic-modules/JSONLogger.py
+33
-36
No files found.
debomatic-modules/JSONLogger.py
View file @
37be48b0
...
@@ -81,10 +81,33 @@ class JSONLogger:
...
@@ -81,10 +81,33 @@ class JSONLogger:
def
_set_json_logfile_name
(
self
,
args
):
def
_set_json_logfile_name
(
self
,
args
):
"""If debomatic config file has section [jsonlogger] try to get
"""If debomatic config file has section [jsonlogger] try to get
'jsonfile' option and override the default value."""
'jsonfile' option and override the default value."""
if
'opts'
in
args
and
args
[
'opts'
].
has_section
(
'jsonlogger'
):
if
'opts'
in
args
and
\
args
[
'opts'
].
has_section
(
'jsonlogger'
)
and
\
args
[
'opts'
].
has_option
(
'jsonlogger'
,
'jsonfile'
):
self
.
jsonfile
=
args
[
'opts'
].
get
(
'jsonlogger'
,
'jsonfile'
).
strip
()
self
.
jsonfile
=
args
[
'opts'
].
get
(
'jsonlogger'
,
'jsonfile'
).
strip
()
def
_write_json_logfile
(
self
,
args
,
status
):
def
_get_package_json_filename
(
self
,
args
):
"""Get the path of package JSON file"""
return
'%(directory)s/pool/%(package)s/%(package)s.json'
%
args
def
_get_distribution_status
(
self
,
args
):
"""From args to distribution status"""
status
=
{}
status
[
'status'
]
=
args
[
'cmd'
]
status
[
'distribution'
]
=
args
[
'distribution'
]
if
'success'
in
args
:
status
[
'success'
]
=
args
[
'success'
]
return
status
def
_get_package_status
(
self
,
args
):
"""From args to package status"""
status
=
{}
for
k
in
[
'package'
,
'distribution'
,
'uploader'
]:
if
k
in
args
:
status
[
k
]
=
args
[
k
]
return
status
def
_append_json_logfile
(
self
,
args
,
status
):
"""Write status to jsonfile in JSON format."""
"""Write status to jsonfile in JSON format."""
self
.
_set_json_logfile_name
(
args
)
self
.
_set_json_logfile_name
(
args
)
status
[
'time'
]
=
int
(
time
())
status
[
'time'
]
=
int
(
time
())
...
@@ -92,13 +115,9 @@ class JSONLogger:
...
@@ -92,13 +115,9 @@ class JSONLogger:
json
=
toJSON
(
status
)
json
=
toJSON
(
status
)
logfd
.
write
(
json
+
'
\
n
'
)
logfd
.
write
(
json
+
'
\
n
'
)
def
_get_package_json
(
self
,
args
):
"""Get the path of package JSON file"""
return
'%(directory)s/pool/%(package)s/%(package)s.json'
%
args
def
_write_package_json
(
self
,
args
,
status
):
def
_write_package_json
(
self
,
args
,
status
):
"""Write package status to a JSON file."""
"""Write package status to a JSON file."""
package_json
=
self
.
_get_package_json
(
args
)
package_json
=
self
.
_get_package_json
_filename
(
args
)
if
os
.
path
.
isfile
(
package_json
):
if
os
.
path
.
isfile
(
package_json
):
with
open
(
package_json
,
'r'
)
as
infofd
:
with
open
(
package_json
,
'r'
)
as
infofd
:
try
:
try
:
...
@@ -117,40 +136,22 @@ class JSONLogger:
...
@@ -117,40 +136,22 @@ class JSONLogger:
json
=
toJSON
(
info
,
indent
=
4
)
json
=
toJSON
(
info
,
indent
=
4
)
infofd
.
write
(
json
+
'
\
n
'
)
infofd
.
write
(
json
+
'
\
n
'
)
def
_get_distribution_status
(
self
,
args
):
"""From args to distribution status"""
status
=
{}
status
[
'status'
]
=
args
[
'cmd'
]
status
[
'distribution'
]
=
args
[
'distribution'
]
if
'success'
in
args
:
status
[
'success'
]
=
args
[
'success'
]
return
status
def
_get_package_status
(
self
,
args
):
"""From args to package status"""
keys
=
[
'package'
,
'distribution'
,
'uploader'
]
status
=
{}
for
k
in
keys
:
if
k
in
args
:
status
[
k
]
=
args
[
k
]
return
status
def
pre_chroot
(
self
,
args
):
def
pre_chroot
(
self
,
args
):
distribution
=
self
.
_get_distribution_status
(
args
)
distribution
=
self
.
_get_distribution_status
(
args
)
self
.
_
write
_json_logfile
(
args
,
distribution
)
self
.
_
append
_json_logfile
(
args
,
distribution
)
def
post_chroot
(
self
,
args
):
def
post_chroot
(
self
,
args
):
distribution
=
self
.
_get_distribution_status
(
args
)
distribution
=
self
.
_get_distribution_status
(
args
)
self
.
_
write
_json_logfile
(
args
,
distribution
)
self
.
_
append
_json_logfile
(
args
,
distribution
)
def
pre_build
(
self
,
args
):
def
pre_build
(
self
,
args
):
package
=
self
.
_get_package_status
(
args
)
package
=
self
.
_get_package_status
(
args
)
package
[
'status'
]
=
'build'
package
[
'status'
]
=
'build'
package_json
=
self
.
_get_package_json
(
args
)
package_json
=
self
.
_get_package_json
_filename
(
args
)
if
os
.
path
.
isfile
(
package_json
):
if
os
.
path
.
isfile
(
package_json
):
os
.
remove
(
package_json
)
os
.
remove
(
package_json
)
self
.
_write_package_json
(
args
,
package
)
self
.
_write_package_json
(
args
,
package
)
self
.
_
write
_json_logfile
(
args
,
package
)
self
.
_
append
_json_logfile
(
args
,
package
)
def
post_build
(
self
,
args
):
def
post_build
(
self
,
args
):
status
=
self
.
_get_package_status
(
args
)
status
=
self
.
_get_package_status
(
args
)
...
@@ -167,7 +168,7 @@ class JSONLogger:
...
@@ -167,7 +168,7 @@ class JSONLogger:
if
tag
:
if
tag
:
status
[
'tags'
][
filename
]
=
tag
status
[
'tags'
][
filename
]
=
tag
self
.
_write_package_json
(
args
,
status
)
self
.
_write_package_json
(
args
,
status
)
self
.
_
write
_json_logfile
(
args
,
status
)
self
.
_
append
_json_logfile
(
args
,
status
)
# Parser for log files
# Parser for log files
...
@@ -227,9 +228,5 @@ class LogParser():
...
@@ -227,9 +228,5 @@ class LogParser():
def
_from_tags_to_result
(
self
,
tags
):
def
_from_tags_to_result
(
self
,
tags
):
keys
=
sorted
(
list
(
tags
.
keys
()))
keys
=
sorted
(
list
(
tags
.
keys
()))
result
=
[]
result
=
[
"%s%s"
%
(
k
,
tags
[
k
])
for
k
in
keys
]
for
k
in
keys
:
return
' '
.
join
(
result
)
if
result
else
None
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