Commits

Steve Losh  committed a261838

Handle in-process builds properly.

  • Participants
  • Parent commits 1cf0baa

Comments (0)

Files changed (3)

File integration/views.py

 
 def build_detail(request, slug, id):
     run = get_object_or_404(BuildRun, id=id)
-    length = run.end_time - run.start_time
+    length = run.end_time - run.start_time if run.end_time else None
     
-    hours, remainder = divmod(length.seconds, 3600)
-    minutes, seconds = divmod(remainder, 60)
+    hours, remainder = divmod(length.seconds, 3600) if length else (None, None)
+    minutes, seconds = divmod(remainder, 60) if length else (None, None)
     
     return render_to_response('integration/build.html',
         { 'run': run, 'hours': hours, 'minutes': minutes, 'seconds': seconds },

File templates/integration/build.html

 
 {% block content %}
     <p>
-        Started at {{ run.start_time|date:"f A" }} on {{ run.start_time|date:"l, F jS Y" }} ({{ run.start_time|timesince }} ago).<br/>
-        Finished at {{ run.end_time|date:"f A" }} on {{ run.end_time|date:"l, F jS Y" }} ({{ run.end_time|timesince }} ago).
-    </p>
+        This build started at {{ run.start_time|date:"f A" }} on {{ run.start_time|date:"l, F jS Y" }} ({{ run.start_time|timesince }} ago).<br/>
+        {% if run.end_time %}
+            This build finished at {{ run.end_time|date:"f A" }} on {{ run.end_time|date:"l, F jS Y" }} ({{ run.end_time|timesince }} ago).
+    {% else %}
+        This build is still running (it started {{ run.start_time|timesince }} ago).
+    {% endif %}
     
-    <p>
-        This build took
-        {% if hours %}{{ hours }} hour{{ hours|pluralize }},{% endif %}
-        {% if hours or minutes %}{{ minutes }} minute{{ minutes|pluralize }},{% endif %}
-        {{ seconds }} second{{ seconds|pluralize }}
-        to finish.
-    </p>
+    {% if run.end_time %}
+        <p>
+            It took
+            {% if hours %}{{ hours }} hour{{ hours|pluralize }},{% endif %}
+            {% if hours or minutes %}{{ minutes }} minute{{ minutes|pluralize }},{% endif %}
+            {{ seconds }} second{{ seconds|pluralize }}
+            to finish.
+        </p>
+    {% endif %}
+
     
     <p>The command used to build was: <code>{{ run.command }}</code></p>
     
-    {% if not run.success %}
+    {% if not run.success and run.end_time %}
         <p>The output was:</p>
         
         <pre>{{ run.output }}</pre>

File templates/integration/project.html

         <li><span class="info-label">Test Command:</span><code>{{ project.command }}</code></li>
     </ul>
     
-    <form method="post" action="{% url run_build slug=project.slug %}">
-        <p><input type="submit" value="Start a build" /></p>
-        <input type="hidden" name="run" value="run" />
-    </form>
+    {% if not project.last_build or project.last_build.end_time %}
+        <form method="post" action="{% url run_build slug=project.slug %}">
+            <p><input type="submit" value="Start a build" /></p>
+            <input type="hidden" name="run" value="run" />
+        </form>
+    {% else %}
+        {% if project.last_build %}
+            <p><a href="{{ project.last_build.get_absolute_url }}">A build</a> is currently running (it started {{ project.last_build.start_time|timesince }} ago).  Wait for it to finish before you start another one!</p>
+        {% endif %}
+    {% endif %}
     
     <h2>All Builds</h2>
     {% for run in project.buildrun_set.all %}