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
2281919d
Commit
2281919d
authored
Jul 10, 2014
by
Leo Iannacone
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
renamed variables and function names - update doc according with
parent
d4429f40
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
31 deletions
+32
-31
debomatic-modules/JSONLogger.py
debomatic-modules/JSONLogger.py
+32
-31
No files found.
debomatic-modules/JSONLogger.py
View file @
2281919d
...
...
@@ -35,25 +35,26 @@ class DebomaticModule_JSONLogger:
def
__init__
(
self
):
self
.
jsonfile
=
'/var/log/debomatic-json.log'
def
_set_json
fil
e
(
self
,
args
):
def
_set_json
_logfile_nam
e
(
self
,
args
):
"""If debomatic config file has section [jsonlogger] try to get
'jsonfile' option and override the default value."""
if
'opts'
in
args
and
args
[
'opts'
].
has_section
(
'jsonlogger'
):
self
.
jsonfile
=
args
[
'opts'
].
get
(
'jsonlogger'
,
'jsonfile'
).
strip
()
def
_
append_info_to_logfile
(
self
,
args
,
info
):
"""Write
info to jsonfile converted
in JSON format."""
self
.
_set_json
fil
e
(
args
)
info
[
'time'
]
=
int
(
time
())
def
_
write_json_logfile
(
self
,
args
,
status
):
"""Write
status to jsonfile
in JSON format."""
self
.
_set_json
_logfile_nam
e
(
args
)
status
[
'time'
]
=
int
(
time
())
with
open
(
self
.
jsonfile
,
'a'
)
as
logfd
:
json
=
toJSON
(
info
)
json
=
toJSON
(
status
)
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
):
"""Write package status
in
to a JSON file."""
"""Write package status to a JSON file."""
package_json
=
self
.
_get_package_json
(
args
)
if
os
.
path
.
isfile
(
package_json
):
with
open
(
package_json
,
'r'
)
as
infofd
:
...
...
@@ -73,49 +74,49 @@ class DebomaticModule_JSONLogger:
json
=
toJSON
(
info
,
indent
=
4
)
infofd
.
write
(
json
+
'
\
n
'
)
def
_get_distribution_
info
(
self
,
args
):
"""From args to distribution
info.
"""
info
=
{}
info
[
'status'
]
=
args
[
'cmd'
]
info
[
'distribution'
]
=
args
[
'distribution'
]
def
_get_distribution_
status
(
self
,
args
):
"""From args to distribution
status
"""
status
=
{}
status
[
'status'
]
=
args
[
'cmd'
]
status
[
'distribution'
]
=
args
[
'distribution'
]
if
'success'
in
args
:
info
[
'success'
]
=
args
[
'success'
]
return
info
status
[
'success'
]
=
args
[
'success'
]
return
status
def
_get_package_
info
(
self
,
args
):
"""From args to package
info.
"""
def
_get_package_
status
(
self
,
args
):
"""From args to package
status
"""
keys
=
[
'package'
,
'distribution'
,
'uploader'
]
info
=
{}
status
=
{}
for
k
in
keys
:
if
k
in
args
:
info
[
k
]
=
args
[
k
]
return
info
status
[
k
]
=
args
[
k
]
return
status
def
pre_chroot
(
self
,
args
):
distribution
=
self
.
_get_distribution_
info
(
args
)
self
.
_
append_info_to
_logfile
(
args
,
distribution
)
distribution
=
self
.
_get_distribution_
status
(
args
)
self
.
_
write_json
_logfile
(
args
,
distribution
)
def
post_chroot
(
self
,
args
):
distribution
=
self
.
_get_distribution_
info
(
args
)
self
.
_
append_info_to
_logfile
(
args
,
distribution
)
distribution
=
self
.
_get_distribution_
status
(
args
)
self
.
_
write_json
_logfile
(
args
,
distribution
)
def
pre_build
(
self
,
args
):
package
=
self
.
_get_package_
info
(
args
)
package
=
self
.
_get_package_
status
(
args
)
package
[
'status'
]
=
'build'
package_json
=
self
.
_get_package_json
(
args
)
if
os
.
path
.
isfile
(
package_json
):
os
.
remove
(
package_json
)
self
.
_write_package_json
(
args
,
package
)
self
.
_
append_info_to
_logfile
(
args
,
package
)
self
.
_
write_json
_logfile
(
args
,
package
)
def
post_build
(
self
,
args
):
package
=
self
.
_get_package_info
(
args
)
package
[
'status'
]
=
'build'
package
[
'success'
]
=
False
status
=
self
.
_get_package_status
(
args
)
status
[
'status'
]
=
'build'
status
[
'success'
]
=
False
resultdir
=
os
.
path
.
join
(
args
[
'directory'
],
'pool'
,
args
[
'package'
])
for
filename
in
os
.
listdir
(
resultdir
):
if
filename
.
endswith
(
'.dsc'
):
package
[
'success'
]
=
True
status
[
'success'
]
=
True
break
self
.
_write_package_json
(
args
,
package
)
self
.
_
append_info_to_logfile
(
args
,
package
)
self
.
_write_package_json
(
args
,
status
)
self
.
_
write_json_logfile
(
args
,
status
)
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