8000 Display daily build task · python-doc-tw/pydoc_autobuild@14ac9aa · GitHub
[go: up one dir, main page]

Skip to content

Commit 14ac9aa

Browse files
committed
Display daily build task
1 parent 6e73bc3 commit 14ac9aa

File tree

3 files changed

+55
-1
lines changed

3 files changed

+55
-1
lines changed

doc_tasks/views.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from collections import namedtuple
1+
from collections import namedtuple, OrderedDict
22

33
from django.core.urlresolvers import reverse
44
from django.shortcuts import render, get_object_or_404
@@ -57,6 +57,15 @@ def view_task(request, id):
5757
'sphinx_intl_build': sphinx_intl_build,
5858
'sphinx_build_html': sphinx_build_html,
5959
})
60+
if task.func == 'doc_tasks.tasks.full_update_and_commit':
61+
decoded_result = OrderedDict([
62+
(cmd_name, decode_cmd_out(cmd))
63+
for cmd_name, cmd in task.result.items()
64+
])
65+
return rendered(request, 'daily_update_task.html', {
66+
'task': task,
67+
'decoded_result': decoded_result
68+
})
6069
return Http404(
6170
'Given task of type %s does not have the result template '
6271
'to be rendered yet.'
@@ -72,8 +81,12 @@ def home(request):
7281
one_page_tasks = Task.objects.all().filter(
7382
func__exact='doc_tasks.tasks.update_one_page'
7483
).order_by('-started')
84+
daily_update_tasks = Task.objects.all().filter(
85+
func__exact='doc_tasks.tasks.full_update_and_commit'
86+
).order_by('-started')
7587
return render(request, 'index.html', {
7688
'one_page_tasks': one_page_tasks,
89+
'daily_update_tasks': daily_update_tasks,
7790
'queued_tasks': queued_tasks,
7891
'tz': tz,
7992
})

templates/daily_update_task.html

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{% extends 'base.html' %}
2+
3+
{% block title %}Task Result{% endblock %}
4+
5+
{% block content %}
6+
<h1>Task {{ task.id }} <small>{{ task.name }}</small></h1>
7+
{% for cmd_name, cmd_result in decoded_result.items %}
8+
<h2>{{ cmd_name }} (return code: {{ cmd_result.returncode }}</h2>
9+
<p><code>{{ cmd_result.args|join:" " }}</code></p>
10+
<pre>{{ cmd_result.stdout }}</pre>
11+
<pre>{{ cmd_result.stderr }}</pre>
12+
{% endfor %}
13+
{% endblock content %}

templates/index.html

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,34 @@ <h2>Doc Page Built History</h2>
5252
{% endfor %}
5353
</tbody>
5454
</table>
55+
56+
<h2>Daily Built History</h2>
57+
<table class="table table-striped">
58+
<thead>
59+
<tr>
60+
<th>Task ID</th>
61+
<th>Status</th>
62+
<th>Started</th>
63+
<th>Ended</th>
64+
</tr>
65+
</thead>
66+
<tbody>
67+
{% for task in daily_update_tasks %}
68+
<tr>
69+
<td>
70+
{% if task.success %}
71+
<a href="{% url 'view_task' id=task.id %}">{{ task.id }}</a>
72+
{% else %}
73+
{{ task.id }}
74+
{% endif %}
75+
</td>
76+
<td>{% if task.success %}OK{% else %}FAILED{% endif %}</td>
77+
<td>{{ task.started|date:"Y-m-d H:i:s" }}</td>
78+
<td>{{ task.stopped|date:"Y-m-d H:i:s" }}</td>
79+
{% endfor %}
80+
</tbody>
81+
</table>
82+
5583
<p>Timezone: {{ tz }}</p>
5684
<p>Only the latest 10 tasks are kept.</p>
5785
{% endblock %}

0 commit comments

Comments
 (0)
0