diff mbox

[Branch,~linaro-validation/lava-scheduler/trunk] Rev 205: hack to get missing log files to mean that job files can still display

Message ID 20120827143110.6060.80127.launchpad@ackee.canonical.com
State Accepted
Headers show

Commit Message

Michael-Doyle Hudson Aug. 27, 2012, 2:31 p.m. UTC
------------------------------------------------------------
revno: 205
committer: Michael Hudson-Doyle <michael.hudson@linaro.org>
branch nick: missing-log-file-bug-1035307
timestamp: Mon 2012-08-27 11:52:54 +1200
message:
  hack to get missing log files to mean that job files can still display
modified:
  lava_scheduler_app/views.py


--
lp:lava-scheduler
https://code.launchpad.net/~linaro-validation/lava-scheduler/trunk

You are subscribed to branch lp:lava-scheduler.
To unsubscribe from this branch go to https://code.launchpad.net/~linaro-validation/lava-scheduler/trunk/+edit-subscription
diff mbox

Patch

=== modified file 'lava_scheduler_app/views.py'
--- lava_scheduler_app/views.py	2012-08-03 16:12:09 +0000
+++ lava_scheduler_app/views.py	2012-08-26 23:52:54 +0000
@@ -489,9 +489,15 @@ 
         'show_reload_page' : job.status <= TestJob.RUNNING,
     }
 
-    if job.log_file:
-        job_errors = getDispatcherErrors(job.log_file)
-        job_log_messages = getDispatcherLogMessages(job.log_file)
+    log_file = job.log_file
+    try:
+        log_file.open()
+    except IOError:
+        log_file = None
+
+    if log_file:
+        job_errors = getDispatcherErrors(log_file)
+        job_log_messages = getDispatcherLogMessages(log_file)
 
         levels = defaultdict(int)
         for kl in ['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL']:
@@ -505,7 +511,7 @@ 
             'job_has_error' : len(job_errors) > 0,
             'job_log_messages' : job_log_messages,
             'levels': levels,
-            'job_file_size' : job.log_file.size,
+            'job_file_size' : log_file.size,
             })
     else:
         data.update({
@@ -518,11 +524,16 @@ 
 
 def job_definition(request, pk):
     job = get_restricted_job(request.user, pk)
+    log_file = job.log_file
+    try:
+        log_file.open()
+    except IOError:
+        log_file = None
     return render_to_response(
         "lava_scheduler_app/job_definition.html",
         {
             'job': job,
-            'job_file_present': bool(job.log_file),
+            'job_file_present': bool(log_file),
         },
         RequestContext(request))