Skip to content

Commit 31f2135

Browse files
committed
ci_build/: Re-design build-logs webpage
The newly created webpage combines the previous two webpages- info.txt and log/index.html. This web-page combines the results of both the pages and shows them in a better UI/UX with additional features of filtering and searching within the existing logs. The logs are fetched from a JSON file which is created from the logs stored in the log file _site/community.log Closes #256
1 parent 27d2f7d commit 31f2135

File tree

11 files changed

+364
-51
lines changed

11 files changed

+364
-51
lines changed

.moban.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ packages:
99
- gci
1010
- gsoc
1111
- gamification
12-
- log
12+
- ci_build
1313
- meta_review
1414
- model
1515
- twitter

.nocover.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ nocover_file_globs:
88
- community/git.py
99
- gci/*.py
1010
- gsoc/*.py
11-
- log/*.py
11+
- ci_build/*.py
1212
- meta_review/handler.py
1313
- model/*.py
1414
- openhub/*.py

ci_build/view_log.py

+91
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
import re
2+
import json
3+
import os
4+
import sys
5+
6+
from django.views.generic import TemplateView
7+
8+
from community.views import get_header_and_footer
9+
from community.git import (get_org_name,
10+
get_owner,
11+
get_deploy_url,
12+
get_upstream_deploy_url)
13+
14+
15+
class BuildLogsView(TemplateView):
16+
template_name = 'build_logs.html'
17+
18+
def get_build_info(self):
19+
data = {
20+
'Org name': get_org_name(),
21+
'Owner': get_owner(),
22+
'Deploy URL': get_deploy_url(),
23+
}
24+
try:
25+
upstream_deploy_url = get_upstream_deploy_url()
26+
data['Upstream deploy URL'] = upstream_deploy_url
27+
except RuntimeError:
28+
data['Upstream deploy URL'] = 'Not found'
29+
return dict(data)
30+
31+
def get_build_logs(self):
32+
log_lines = []
33+
log_level_specific_lines = {
34+
'INFO': [],
35+
'DEBUG': [],
36+
'WARNING': [],
37+
'ERROR': [],
38+
'CRITICAL': []
39+
}
40+
log_file_path = './_site/community.log'
41+
log_file_exists = os.path.isfile(log_file_path)
42+
if log_file_exists:
43+
with open(log_file_path) as log_file:
44+
previous_found_level = None
45+
for line in log_file:
46+
log_lines.append(line)
47+
levels = re.findall(r'\[[A-Z]+]', line)
48+
if levels:
49+
level = levels[0]
50+
level = previous_found_level = level[1:-1]
51+
log_level_specific_lines[level].append(line)
52+
elif previous_found_level:
53+
log_level_specific_lines[previous_found_level].append(
54+
line)
55+
ci_build_jsons = {
56+
'site_path': './_site/ci-build-detailed-logs.json',
57+
'public_path': './public/static/ci-build-detailed-logs.json',
58+
'static_path': './static/ci-build-detailed-logs.json'
59+
}
60+
with open(ci_build_jsons['site_path'], 'w+') as build_logs_file:
61+
data = {
62+
'logs': log_lines,
63+
'logs_level_Specific': log_level_specific_lines
64+
}
65+
json.dump(data, build_logs_file, indent=4)
66+
if os.path.isfile(ci_build_jsons['public_path']):
67+
if sys.platform == 'linux':
68+
os.popen('cp {} {}'.format(
69+
ci_build_jsons['site_path'],
70+
ci_build_jsons['public_path']))
71+
os.popen('cp {} {}'.format(
72+
ci_build_jsons['site_path'],
73+
ci_build_jsons['static_path']))
74+
else:
75+
os.popen('copy {} {}'.format(
76+
ci_build_jsons['site_path'],
77+
ci_build_jsons['public_path']))
78+
os.popen('copy {} {}'.format(
79+
ci_build_jsons['site_path'],
80+
ci_build_jsons['static_path']))
81+
82+
return True
83+
else:
84+
return False
85+
86+
def get_context_data(self, **kwargs):
87+
context = super().get_context_data(**kwargs)
88+
context = get_header_and_footer(context)
89+
context['build_info'] = self.get_build_info()
90+
context['build_logs_stored'] = self.get_build_logs()
91+
return context

community/urls.py

+5-11
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
from django.conf.urls.static import static
77
from django.conf import settings
88

9-
from community.views import HomePageView, info
9+
from community.views import HomePageView
1010
from gci.views import index as gci_index
1111
from gci.feeds import LatestTasksFeed as gci_tasks_rss
1212
from twitter.view_twitter import index as twitter_index
13-
from log.view_log import index as log_index
13+
from ci_build.view_log import BuildLogsView
1414
from data.views import index as contributors_index
1515
from gamification.views import index as gamification_index
1616
from meta_review.views import index as meta_review_index
@@ -79,12 +79,6 @@ def get_organization():
7979
distill_func=get_index,
8080
distill_file='index.html',
8181
),
82-
distill_url(
83-
'info.txt', info,
84-
name='index',
85-
distill_func=get_index,
86-
distill_file='info.txt',
87-
),
8882
distill_url(
8983
r'gci/tasks/rss.xml', gci_tasks_rss(),
9084
name='gci-tasks-rss',
@@ -104,10 +98,10 @@ def get_organization():
10498
distill_file='twitter/index.html',
10599
),
106100
distill_url(
107-
r'log/', log_index,
108-
name='log',
101+
r'CI/Build/', BuildLogsView.as_view(),
102+
name='ci_build',
109103
distill_func=get_index,
110-
distill_file='log/index.html',
104+
distill_file='CI/Build/index.html',
111105
),
112106
distill_url(
113107
r'contributors/$', contributors_index,

community/views.py

-21
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
1-
from django.http import HttpResponse
21
from django.views.generic.base import TemplateView
32
import requests
43
from trav import Travis
54

65
from .git import (
7-
get_deploy_url,
86
get_org_name,
9-
get_owner,
10-
get_upstream_deploy_url,
117
get_remote_url
128
)
139
from data.models import Team
@@ -105,20 +101,3 @@ def get_context_data(self, **kwargs):
105101
context['top_gamification_users'] = self.get_top_gamification_users(
106102
count=5)
107103
return context
108-
109-
110-
def info(request):
111-
data = {
112-
'Org name': get_org_name(),
113-
'Owner': get_owner(),
114-
'Deploy URL': get_deploy_url(),
115-
}
116-
try:
117-
upstream_deploy_url = get_upstream_deploy_url()
118-
data['Upstream deploy URL'] = upstream_deploy_url
119-
except RuntimeError:
120-
data['Upstream deploy URL'] = 'Not found'
121-
122-
s = '\n'.join(name + ': ' + value
123-
for name, value in data.items())
124-
return HttpResponse(s)

log/view_log.py

-12
This file was deleted.

setup.cfg

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ testpaths =
1414
gci
1515
gsoc
1616
gamification
17-
log
17+
ci_build
1818
meta_review
1919
model
2020
twitter
@@ -70,7 +70,7 @@ source =
7070
gci
7171
gsoc
7272
gamification
73-
log
73+
ci_build
7474
meta_review
7575
model
7676
twitter
@@ -82,7 +82,7 @@ omit =
8282
community/git.py
8383
gci/*.py
8484
gsoc/*.py
85-
log/*.py
85+
ci_build/*.py
8686
meta_review/handler.py
8787
model/*.py
8888
openhub/*.py

static/css/build_logs.css

+86
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
.build-info-section section,
2+
.build-logs-section section {
3+
min-width: 300px;
4+
width: 80%;
5+
}
6+
7+
.build-information,
8+
.build-logs {
9+
background-color: black;
10+
padding-left: 10px;
11+
font-weight: bold;
12+
color: white;
13+
}
14+
15+
.build-information p {
16+
font-size: 1.5em;
17+
margin: 0;
18+
}
19+
20+
.build-logs {
21+
max-height: 900px;
22+
overflow: scroll;
23+
overflow-x: hidden;
24+
overflow-y: auto;
25+
}
26+
27+
.build-logs p {
28+
margin: 0;
29+
}
30+
31+
.build-logs-section .log-chooser {
32+
width: 25%;
33+
min-width: 150px;
34+
border-radius: 100px;
35+
box-shadow: 0px 0px 25px 2px black;
36+
color: #454343;
37+
background-color: #c7da99;
38+
padding-left: 10px;
39+
margin: auto;
40+
margin-right: 0;
41+
}
42+
43+
.build-logs-section .log-chooser input,
44+
.build-logs-section .log-chooser input:focus:not(.browser-default) {
45+
border-bottom: none;
46+
margin-bottom: 0;
47+
}
48+
49+
.build-logs-section .small-screen,
50+
.build-logs-section .fa-close {
51+
display: none;
52+
}
53+
54+
.form-fields {
55+
margin: auto;
56+
margin-right: 0;
57+
width: 60%;
58+
padding-top: 10px;
59+
}
60+
61+
.search-field {
62+
width: 60%;
63+
min-width: 180px;
64+
}
65+
66+
.section-header {
67+
display: flex;
68+
align-items: center;
69+
}
70+
71+
.section-header form {
72+
display: flex;
73+
}
74+
75+
@media only screen and (max-width: 660px) {
76+
.build-logs-section .search-field {
77+
display: none;
78+
}
79+
.build-logs-section .small-screen {
80+
display: flex;
81+
align-items: center;
82+
margin: auto;
83+
margin-right: 3px;
84+
font-size: 2em;
85+
}
86+
}

0 commit comments

Comments
 (0)