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
e8dff50b
Commit
e8dff50b
authored
Jul 14, 2014
by
Leo Iannacone
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'github/master' into portable
parents
8b46ae53
886c11aa
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
52 additions
and
57 deletions
+52
-57
debomatic-modules/JSONLogger.py
debomatic-modules/JSONLogger.py
+36
-56
debomatic-webui/lib/client.js
debomatic-webui/lib/client.js
+7
-1
debomatic-webui/public/javascripts/page_distribution.js
debomatic-webui/public/javascripts/page_distribution.js
+9
-0
No files found.
debomatic-modules/JSONLogger.py
View file @
e8dff50b
...
...
@@ -35,7 +35,7 @@ from collections import defaultdict
# as first and as last one for pre_* and post_* hooks
class
DebomaticModule_00_JSONLogger
:
def
__init__
(
self
):
self
.
logger
=
JSONLogger
.
Instance
()
self
.
logger
=
DebomaticModule_JSONLogger
()
def
pre_chroot
(
self
,
args
):
self
.
logger
.
pre_chroot
(
args
)
...
...
@@ -46,7 +46,7 @@ class DebomaticModule_00_JSONLogger:
class
DebomaticModule_ZZ_JSONLogger
:
def
__init__
(
self
):
self
.
logger
=
JSONLogger
.
Instance
()
self
.
logger
=
DebomaticModule_JSONLogger
()
def
post_chroot
(
self
,
args
):
self
.
logger
.
post_chroot
(
args
)
...
...
@@ -55,25 +55,8 @@ class DebomaticModule_ZZ_JSONLogger:
self
.
logger
.
post_build
(
args
)
# Singleton decorator
class
Singleton
:
def
__init__
(
self
,
decorated
):
self
.
_decorated
=
decorated
def
Instance
(
self
):
try
:
return
self
.
_instance
except
AttributeError
:
self
.
_instance
=
self
.
_decorated
()
return
self
.
_instance
def
__call__
(
self
):
raise
TypeError
(
'Singletons must be accessed through `Instance()`.'
)
# The real JSONLogger Class
@
Singleton
class
JSONLogger
:
class
DebomaticModule_JSONLogger
:
def
__init__
(
self
):
self
.
jsonfile
=
'/var/log/debomatic-json.log'
...
...
@@ -81,10 +64,33 @@ class JSONLogger:
def
_set_json_logfile_name
(
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'
):
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
()
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."""
self
.
_set_json_logfile_name
(
args
)
status
[
'time'
]
=
int
(
time
())
...
...
@@ -92,13 +98,9 @@ class JSONLogger:
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 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
):
with
open
(
package_json
,
'r'
)
as
infofd
:
try
:
...
...
@@ -117,40 +119,22 @@ class JSONLogger:
json
=
toJSON
(
info
,
indent
=
4
)
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
):
distribution
=
self
.
_get_distribution_status
(
args
)
self
.
_
write
_json_logfile
(
args
,
distribution
)
self
.
_
append
_json_logfile
(
args
,
distribution
)
def
post_chroot
(
self
,
args
):
distribution
=
self
.
_get_distribution_status
(
args
)
self
.
_
write
_json_logfile
(
args
,
distribution
)
self
.
_
append
_json_logfile
(
args
,
distribution
)
def
pre_build
(
self
,
args
):
package
=
self
.
_get_package_status
(
args
)
package
[
'status'
]
=
'build'
package_json
=
self
.
_get_package_json
(
args
)
package_json
=
self
.
_get_package_json
_filename
(
args
)
if
os
.
path
.
isfile
(
package_json
):
os
.
remove
(
package_json
)
self
.
_write_package_json
(
args
,
package
)
self
.
_
write
_json_logfile
(
args
,
package
)
self
.
_
append
_json_logfile
(
args
,
package
)
def
post_build
(
self
,
args
):
status
=
self
.
_get_package_status
(
args
)
...
...
@@ -167,7 +151,7 @@ class JSONLogger:
if
tag
:
status
[
'tags'
][
filename
]
=
tag
self
.
_write_package_json
(
args
,
status
)
self
.
_
write
_json_logfile
(
args
,
status
)
self
.
_
append
_json_logfile
(
args
,
status
)
# Parser for log files
...
...
@@ -227,9 +211,5 @@ class LogParser():
def
_from_tags_to_result
(
self
,
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
result
=
[
"%s%s"
%
(
k
,
tags
[
k
])
for
k
in
keys
]
return
' '
.
join
(
result
)
if
result
else
None
debomatic-webui/lib/client.js
View file @
e8dff50b
...
...
@@ -137,6 +137,7 @@ function Client(socket) {
return
;
var
distribution_path
=
path
.
join
(
config
.
debomatic
.
path
,
data
.
distribution
.
name
,
'
pool
'
);
utils
.
generic_handler_watcher
(
_e
.
distribution_packages
,
socket
,
data
,
distribution_path
,
__send_distribution_packages
);
data
=
null
;
});
socket
.
on
(
_e
.
package_files_list
,
function
(
data
)
{
...
...
@@ -144,18 +145,21 @@ function Client(socket) {
return
;
var
package_path
=
utils
.
get_package_path
(
data
);
utils
.
generic_handler_watcher
(
_e
.
package_files_list
,
socket
,
data
,
package_path
,
__send_package_files_list
);
data
=
null
;
});
socket
.
on
(
_e
.
file
,
function
(
data
)
{
if
(
!
utils
.
check_data_file
(
data
))
return
;
__handler_get_file
(
socket
,
data
);
data
=
null
;
});
socket
.
on
(
_e
.
package_info
,
function
(
data
)
{
if
(
!
utils
.
check_data_package
(
data
))
return
;
__send_package_info
(
socket
,
data
);
data
=
null
;
});
...
...
@@ -167,7 +171,9 @@ function Client(socket) {
for
(
var
key
in
socket_watchers
)
{
try
{
socket_watchers
[
key
].
close
();
}
catch
(
error_watch
)
{}
}
catch
(
error_watch
)
{
utils
.
errors_handler
(
'
client:disconnect
'
,
error_watch
);
}
}
});
};
...
...
debomatic-webui/public/javascripts/page_distribution.js
View file @
e8dff50b
...
...
@@ -725,12 +725,14 @@ function Page_Distrubion(socket) {
socket
.
on
(
_e
.
distribution_packages
,
function
(
socket_data
)
{
debug_socket
(
'
received
'
,
_e
.
distribution_packages
,
socket_data
);
packages
.
set
(
socket_data
);
socket_data
=
null
;
});
socket
.
on
(
_e
.
distribution_packages_status
,
function
(
socket_data
)
{
debug_socket
(
'
received
'
,
_e
.
distribution_packages_status
,
socket_data
);
packages
.
set_status
(
socket_data
);
sticky
.
set_status
(
socket_data
);
socket_data
=
null
;
});
socket
.
on
(
config
.
events
.
broadcast
.
status_update
,
function
(
socket_data
)
{
...
...
@@ -739,26 +741,31 @@ function Page_Distrubion(socket) {
if
(
socket_data
.
distribution
==
view
.
distribution
.
name
&&
socket_data
.
package
==
view
.
package
.
orig_name
)
{
package_info
.
get
();
}
socket_data
=
null
;
});
socket
.
on
(
_e
.
package_files_list
,
function
(
socket_data
)
{
debug_socket
(
'
received
'
,
_e
.
package_files_list
,
socket_data
);
files
.
set
(
socket_data
);
socket_data
=
null
;
});
socket
.
on
(
_e
.
file
,
function
(
socket_data
)
{
debug_socket
(
'
received
'
,
_e
.
file
,
socket_data
);
file
.
set
(
socket_data
);
socket_data
=
null
;
});
socket
.
on
(
_e
.
file_newcontent
,
function
(
socket_data
)
{
debug_socket
(
'
received
'
,
_e
.
file_newcontent
,
socket_data
);
new_lines
.
push
(
socket_data
.
file
.
new_content
);
socket_data
=
null
;
});
socket
.
on
(
_e
.
package_info
,
function
(
socket_data
)
{
debug_socket
(
'
received
'
,
_e
.
package_info
,
socket_data
);
package_info
.
set
(
socket_data
);
socket_data
=
null
;
});
$
(
window
).
on
(
'
hashchange
'
,
function
()
{
...
...
@@ -775,6 +782,8 @@ function Page_Distrubion(socket) {
update
.
page
(
old_view
);
page
.
go
.
up
();
debug
(
1
,
'
changing view
'
,
'
old:
'
,
old_view
,
'
new:
'
,
view
);
old_view
=
null
;
new_view
=
null
;
});
...
...
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