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:
...
@@ -35,25 +35,26 @@ class DebomaticModule_JSONLogger:
def
__init__
(
self
):
def
__init__
(
self
):
self
.
jsonfile
=
'/var/log/debomatic-json.log'
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
"""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'
):
self
.
jsonfile
=
args
[
'opts'
].
get
(
'jsonlogger'
,
'jsonfile'
).
strip
()
self
.
jsonfile
=
args
[
'opts'
].
get
(
'jsonlogger'
,
'jsonfile'
).
strip
()
def
_
append_info_to_logfile
(
self
,
args
,
info
):
def
_
write_json_logfile
(
self
,
args
,
status
):
"""Write
info to jsonfile converted
in JSON format."""
"""Write
status to jsonfile
in JSON format."""
self
.
_set_json
fil
e
(
args
)
self
.
_set_json
_logfile_nam
e
(
args
)
info
[
'time'
]
=
int
(
time
())
status
[
'time'
]
=
int
(
time
())
with
open
(
self
.
jsonfile
,
'a'
)
as
logfd
:
with
open
(
self
.
jsonfile
,
'a'
)
as
logfd
:
json
=
toJSON
(
info
)
json
=
toJSON
(
status
)
logfd
.
write
(
json
+
'
\
n
'
)
logfd
.
write
(
json
+
'
\
n
'
)
def
_get_package_json
(
self
,
args
):
def
_get_package_json
(
self
,
args
):
"""Get the path of package JSON file"""
return
'%(directory)s/pool/%(package)s/%(package)s.json'
%
args
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
in
to a JSON file."""
"""Write package status to a JSON file."""
package_json
=
self
.
_get_package_json
(
args
)
package_json
=
self
.
_get_package_json
(
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
:
...
@@ -73,49 +74,49 @@ class DebomaticModule_JSONLogger:
...
@@ -73,49 +74,49 @@ class DebomaticModule_JSONLogger:
json
=
toJSON
(
info
,
indent
=
4
)
json
=
toJSON
(
info
,
indent
=
4
)
infofd
.
write
(
json
+
'
\
n
'
)
infofd
.
write
(
json
+
'
\
n
'
)
def
_get_distribution_
info
(
self
,
args
):
def
_get_distribution_
status
(
self
,
args
):
"""From args to distribution
info.
"""
"""From args to distribution
status
"""
info
=
{}
status
=
{}
info
[
'status'
]
=
args
[
'cmd'
]
status
[
'status'
]
=
args
[
'cmd'
]
info
[
'distribution'
]
=
args
[
'distribution'
]
status
[
'distribution'
]
=
args
[
'distribution'
]
if
'success'
in
args
:
if
'success'
in
args
:
info
[
'success'
]
=
args
[
'success'
]
status
[
'success'
]
=
args
[
'success'
]
return
info
return
status
def
_get_package_
info
(
self
,
args
):
def
_get_package_
status
(
self
,
args
):
"""From args to package
info.
"""
"""From args to package
status
"""
keys
=
[
'package'
,
'distribution'
,
'uploader'
]
keys
=
[
'package'
,
'distribution'
,
'uploader'
]
info
=
{}
status
=
{}
for
k
in
keys
:
for
k
in
keys
:
if
k
in
args
:
if
k
in
args
:
info
[
k
]
=
args
[
k
]
status
[
k
]
=
args
[
k
]
return
info
return
status
def
pre_chroot
(
self
,
args
):
def
pre_chroot
(
self
,
args
):
distribution
=
self
.
_get_distribution_
info
(
args
)
distribution
=
self
.
_get_distribution_
status
(
args
)
self
.
_
append_info_to
_logfile
(
args
,
distribution
)
self
.
_
write_json
_logfile
(
args
,
distribution
)
def
post_chroot
(
self
,
args
):
def
post_chroot
(
self
,
args
):
distribution
=
self
.
_get_distribution_
info
(
args
)
distribution
=
self
.
_get_distribution_
status
(
args
)
self
.
_
append_info_to
_logfile
(
args
,
distribution
)
self
.
_
write_json
_logfile
(
args
,
distribution
)
def
pre_build
(
self
,
args
):
def
pre_build
(
self
,
args
):
package
=
self
.
_get_package_
info
(
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
(
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
.
_
append_info_to
_logfile
(
args
,
package
)
self
.
_
write_json
_logfile
(
args
,
package
)
def
post_build
(
self
,
args
):
def
post_build
(
self
,
args
):
package
=
self
.
_get_package_info
(
args
)
status
=
self
.
_get_package_status
(
args
)
package
[
'status'
]
=
'build'
status
[
'status'
]
=
'build'
package
[
'success'
]
=
False
status
[
'success'
]
=
False
resultdir
=
os
.
path
.
join
(
args
[
'directory'
],
'pool'
,
args
[
'package'
])
resultdir
=
os
.
path
.
join
(
args
[
'directory'
],
'pool'
,
args
[
'package'
])
for
filename
in
os
.
listdir
(
resultdir
):
for
filename
in
os
.
listdir
(
resultdir
):
if
filename
.
endswith
(
'.dsc'
):
if
filename
.
endswith
(
'.dsc'
):
package
[
'success'
]
=
True
status
[
'success'
]
=
True
break
break
self
.
_write_package_json
(
args
,
package
)
self
.
_write_package_json
(
args
,
status
)
self
.
_
append_info_to_logfile
(
args
,
package
)
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