=== modified file 'lava_scheduler_app/logfile_helper.py'
@@ -1,9 +1,6 @@
-import os
import re
def getDispatcherErrors(logfile):
- if not logfile:
- return "Log file is missing"
errors = ""
for line in logfile:
if line.find("CriticalError:") != -1 or \
@@ -12,18 +9,7 @@
return errors
-def getDispatcherLogSize(logfile):
- if not logfile:
- return 0
- else:
- logfile.seek(0, os.SEEK_END)
- size = logfile.tell()
- return size
-
def getDispatcherLogMessages(logfile):
- if not logfile:
- return ('', "Log file is missing")
-
logs = []
log_prefix = '<LAVA_DISPATCHER>'
level_pattern = re.compile('....-..-.. ..:..:.. .. ([A-Z]+):')
=== modified file 'lava_scheduler_app/templates/lava_scheduler_app/job.html'
@@ -8,6 +8,10 @@
{% block content %}
<h2>Dispatcher Log Summary</h2>
+{% if job.status < job.RUNNING %}
+No log file yet.
+{% else %}
+{% if job_file_present %}
{% if job_has_error %}
<div id="dispatcher-error">
<h3>Dispatcher error or test failure</h3>
@@ -32,8 +36,14 @@
<img src="{{ STATIC_URL }}lava_scheduler_app/images/ajax-progress.gif"/>
{% endif %}
</div>
+{% else %}
+<p>
+Job file missing.
+</p>
+{% endif %}
+{% endif %}
-<script type="text/javascript">
+</p><script type="text/javascript">
$('.logbuttons input').button()
function showHideLogClick () {
var rule = rules[$(this).attr('id')];
@@ -51,7 +61,7 @@
'': undefined
}
-{% if job.status == job.RUNNING %}
+{% if job.status == job.RUNNING and job_file_present %}
var pollTimer = null, logLenth = '{{ job_file_size }}';
function poll (start) {
=== modified file 'lava_scheduler_app/templates/lava_scheduler_app/job_sidebar.html'
@@ -61,9 +61,11 @@
<li>
<a href="{% url lava.scheduler.job.detail job.pk %}">Summary</a>
</li>
+{% if job_file_present %}
<li>
<a href="{% url lava.scheduler.job.log_file job.pk %}">Complete log</a>
</li>
+{% endif %}
<li>
<a href="{% url lava.scheduler.job.definition job.pk %}">Defintion</a>
</li>
=== modified file 'lava_scheduler_app/views.py'
@@ -1,11 +1,9 @@
from collections import defaultdict
-import simplejson
import logging
import os
+import simplejson
import StringIO
-from logfile_helper import formatLogFile, getDispatcherErrors
-from logfile_helper import getDispatcherLogMessages, getDispatcherLogSize
from django.http import (
HttpResponse,
@@ -19,13 +17,19 @@
render_to_response,
)
-from lava_scheduler_app.models import Device, TestJob
from lava_server.views import index as lava_index
from lava_server.bread_crumbs import (
BreadCrumb,
BreadCrumbTrail,
)
+from lava_scheduler_app.logfile_helper import (
+ formatLogFile,
+ getDispatcherErrors,
+ getDispatcherLogMessages
+ )
+from lava_scheduler_app.models import Device, TestJob
+
def post_only(func):
def decorated(request, *args, **kwargs):
@@ -66,30 +70,39 @@
@BreadCrumb("Job #{pk}", parent=index, needs=['pk'])
def job_detail(request, pk):
job = get_object_or_404(TestJob, pk=pk)
- job_errors = getDispatcherErrors(job.log_file)
- job_log_messages = getDispatcherLogMessages(job.log_file)
-
- levels = defaultdict(int)
- for kl in ['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL']:
- levels[kl] = 0
- for level, msg in job_log_messages:
- levels[level] += 1
- levels = sorted(levels.items(), key=lambda (k,v):logging._levelNames.get(k))
-
- return render_to_response(
- "lava_scheduler_app/job.html",
- {
- 'job': TestJob.objects.get(pk=pk),
- 'show_cancel': job.status <= TestJob.RUNNING and job.can_cancel(request.user),
- 'bread_crumb_trail': BreadCrumbTrail.leading_to(job_detail, pk=pk),
+
+ data = {
+ 'job': job,
+ 'show_cancel': job.status <= TestJob.RUNNING and job.can_cancel(request.user),
+ 'bread_crumb_trail': BreadCrumbTrail.leading_to(job_detail, pk=pk),
+ 'show_reload_page' : job.status <= TestJob.RUNNING,
+ }
+
+ if job.log_file:
+ job_errors = getDispatcherErrors(job.log_file)
+ job_log_messages = getDispatcherLogMessages(job.log_file)
+
+ levels = defaultdict(int)
+ for kl in ['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL']:
+ levels[kl] = 0
+ for level, msg in job_log_messages:
+ levels[level] += 1
+ levels = sorted(levels.items(), key=lambda (k,v):logging._levelNames.get(k))
+ data.update({
+ 'job_file_present': True,
'job_errors' : job_errors,
'job_has_error' : len(job_errors) > 0,
'job_log_messages' : job_log_messages,
'levels': levels,
- 'show_reload_page' : job.status <= TestJob.RUNNING,
- 'job_file_size' : getDispatcherLogSize(job.log_file),
- },
- RequestContext(request))
+ 'job_file_size' : job.log_file.size,
+ })
+ else:
+ data.update({
+ 'job_file_present': False,
+ })
+
+ return render_to_response(
+ "lava_scheduler_app/job.html", data, RequestContext(request))
def job_definition(request, pk):
@@ -98,6 +111,7 @@
"lava_scheduler_app/job_definition.html",
{
'job': job,
+ 'job_file_present': bool(job.log_file),
},
RequestContext(request))
@@ -117,8 +131,9 @@
"lava_scheduler_app/job_log_file.html",
{
'job': TestJob.objects.get(pk=pk),
+ 'job_file_present': bool(job.log_file),
'sections' : content,
- 'job_file_size' : getDispatcherLogSize(job.log_file),
+ 'job_file_size' : job.log_file.size,
},
RequestContext(request))