ChangeLog dorrie/comps dorrie/urls.py
by Shreyank Gupta
ChangeLog | 17 +++++++++++
dorrie/comps/media/fedora.css | 6 ++--
dorrie/comps/models.py | 1
dorrie/comps/parse.py | 54 ++++++++++++++++++++++++++++++++++++++
dorrie/comps/templates/build.html | 31 ++++++++++++++++++++-
dorrie/comps/views.py | 21 ++++++++++++++
dorrie/urls.py | 2 +
7 files changed, 126 insertions(+), 6 deletions(-)
New commits:
commit 11559ddb4ca5bdffb4660f48bdc16d9a8a5bd031
Author: Shreyank Gupta <sgupta(a)redhat.com>
Date: Tue Feb 23 18:07:06 2010 +0530
Added functionality to build spin.
diff --git a/ChangeLog b/ChangeLog
index 2581970..8bacce2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,21 @@
+2010-02-23 Shreyank Gupta <sgupta(a)redhat.com>
+
+ * dorrie/comps/media/fedora.css (#packages, #package-list): Width, border.
+
+ * dorrie/comps/models.py (Spin): Added attribute pid.
+
+ * dorrie/comps/parse.py (livecd_comand, livecd_create, get_tail): New
+ functions.
+
+ * dorrie/comps/templates/build.html: Added JS Block, new div and build
+ spin link.
+
+ * dorrie/comps/views.py (process, tail): New views.
+
+ * dorrie/urls.py: URLs for new views.
+
2009-12-17 Hiemanshu Sharma <hiemanshu(a)fedoraproject.org>
+
* base.html - Moved to new Template
* dorrie.jpg - Updated with new logo send by Shreyank
* dorrie.fedora.css - Added new css file to leave fedora.css untouched
diff --git a/dorrie/comps/media/fedora.css b/dorrie/comps/media/fedora.css
index 5d8d458..b965c20 100644
--- a/dorrie/comps/media/fedora.css
+++ b/dorrie/comps/media/fedora.css
@@ -56,15 +56,15 @@ pre
#packages
{
- width: 40%;
+ width: 50%;
float: right;
}
#package-list
{
- width: 70%;
+ width: 100%;
height: 300px;
- border: 2px solid #bbb;
+ border: 1px solid #bbb;
overflow: auto;
}
diff --git a/dorrie/comps/models.py b/dorrie/comps/models.py
index 03d02d3..a784932 100644
--- a/dorrie/comps/models.py
+++ b/dorrie/comps/models.py
@@ -30,6 +30,7 @@ class Spin(models.Model):
gminus = models.ManyToManyField('Group', related_name='gminus_set')
pplus = models.ManyToManyField('Package', related_name='pplus_set')
pminus = models.ManyToManyField('Package', related_name='pminus_set')
+ pid = models.IntegerField(default=0)
class Group(models.Model):
diff --git a/dorrie/comps/parse.py b/dorrie/comps/parse.py
index 13594fe..09212e5 100644
--- a/dorrie/comps/parse.py
+++ b/dorrie/comps/parse.py
@@ -17,6 +17,8 @@
import os, pytz, urllib
+from subprocess import Popen
+
#FIXME: Import only what's needed or just 'from pykickstart import parser'
from pykickstart.parser import *
from pykickstart.version import makeVersion
@@ -209,3 +211,55 @@ def build_ks(id):
os.symlink(settings.CACHE, link)
return linkname
+
+
+def livecd_command(spin):
+ """
+ Build livecd-creator command
+ """
+ ks_path = "%s%s_%s/%s.ks" % (settings.CACHE, spin.id, spin.name, spin.name)
+ fs_label = spin.name
+ folder = "%s%s_%s" % (settings.CACHE, spin.id, spin.name)
+ cache_path = os.path.join(settings.CACHE, 'cache/')
+ tmp_path = os.path.join(settings.CACHE, 'tmp/')
+ cmd = "cd %s;sudo livecd-creator -c %s --cache='%s' -t '%s' -f %s" \
+ % (folder, ks_path, cache_path, tmp_path, fs_label)
+ return cmd
+
+
+def livecd_create(id):
+ """
+ Build livecd + give progress
+ """
+ spin = get_spin(id)
+ cmd = livecd_command(spin)
+ log_file = "%s%s_%s/%s.log" % \
+ (settings.CACHE, spin.id, spin.name, spin.name)
+ fd = open(log_file, 'w')
+ process = Popen(cmd, shell=True, stdout=fd, stderr=fd)
+ spin.pid = process.pid
+ spin.save()
+ return process.pid
+
+
+def get_tail(id):
+ """
+ return tail or log file
+ """
+ spin = get_spin(id)
+ spin_path = "%s%s_%s/%s.iso" % (settings.CACHE, spin.id, spin.name,
+ spin.name)
+ if os.path.exists(spin_path):
+ linkname = "/static/cache/%s_%s/%s.iso" % \
+ (spin.id, spin.name, spin.name)
+ lines = "<h3><a href='%s'>Download Spin</a></h3>" % linkname
+ else:
+ log_file = "%s%s_%s/%s.log" % \
+ (settings.CACHE, spin.id, spin.name, spin.name)
+ fd = open(log_file, 'r')
+ lines = fd.readlines()[-10:]
+ fd.close()
+ lines = "<br>".join(lines)
+ return lines
+
+
diff --git a/dorrie/comps/templates/build.html b/dorrie/comps/templates/build.html
index 5f3b082..8494735 100644
--- a/dorrie/comps/templates/build.html
+++ b/dorrie/comps/templates/build.html
@@ -20,9 +20,36 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
{% extends "base.html" %}
{% block content %}
+
+<script type="text/javascript">
+$(document).ready(function() {
+ $("#packages").hide();
+});
+
+function build(id) {
+ $.post("/process/", { spin_id: id });
+ $('#packages').slideDown("normal");
+ setInterval(show_log, 3000);
+}
+
+var show_log = function() {
+ $.post("/tail/", { spin_id: {{ spin.id }} },
+ function(data) {
+ $("#package-list").html(data);
+ }
+ );
+}
+
+</script>
+
<h1>Image : {{ spin.name }}</h1>
-<h3>Download Kickstart</h3>
+<h3><a href="{{ ks }}">Download Kickstart</a></h3>
+
+<h3><a href="javascript:build({{ spin.id }})">Build Spin</a></h3>
-<a href="{{ ks }}">{{ spin.name }}.ks</a>
+ <div id="packages">
+ <h3>Building spin {{ spin.name }}</h3>
+ <div id="package-list"></div>
+ </div>
{% endblock %}
diff --git a/dorrie/comps/views.py b/dorrie/comps/views.py
index be62124..23ba2e9 100644
--- a/dorrie/comps/views.py
+++ b/dorrie/comps/views.py
@@ -22,7 +22,7 @@ from django.shortcuts import render_to_response
from forms import NameForm , BasicForm
from helper import new_spin, add_lang_tz, select_helper, get_spin
from parse import (get_lang_tz, get_comps, default_selected,
- package_listing, build_ks)
+ package_listing, build_ks, livecd_create, get_tail)
def home(request):
@@ -84,3 +84,22 @@ def build(request):
spin = get_spin(spin_id)
return render_to_response('build.html', {'ks': new_ks, 'spin': spin})
+
+def process(request):
+ """
+ start livecd-creator as a separate process
+ """
+ spin_id = request.POST.get('spin_id')
+ pid = livecd_create(spin_id)
+ html = "Process %s started.." % pid
+ return HttpResponse(html)
+
+
+def tail(request):
+ """
+ Return tail of the log
+ """
+ spin_id = request.POST.get('spin_id')
+ html = get_tail(spin_id)
+ return HttpResponse(html)
+
diff --git a/dorrie/urls.py b/dorrie/urls.py
index 92a3e0e..5c0f06d 100644
--- a/dorrie/urls.py
+++ b/dorrie/urls.py
@@ -36,6 +36,8 @@ urlpatterns = patterns('',
(r'^packages/$', views.packages),
(r'^select/$', views.select),
(r'^build/$', views.build),
+ (r'^process/$', views.process),
+ (r'^tail/$', views.tail),
# Uncomment the next line to enable the admin:
# (r'^admin/(.*)', admin.site.root),
)
14 years, 2 months