summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMagnus Granberg <zorry@gentoo.org>2017-01-15 20:44:38 +0100
committerMagnus Granberg <zorry@gentoo.org>2017-01-15 20:44:38 +0100
commit5270ca757656869bc05f5de9ef7e772b0d0ab68a (patch)
tree6120993e7fa117a1d48d8280d0f092b409a7a79e
parentfix ame 'adict' is not defined line 273 (diff)
downloadtinderbox-cluster-www-5270ca757656869bc05f5de9ef7e772b0d0ab68a.tar.gz
tinderbox-cluster-www-5270ca757656869bc05f5de9ef7e772b0d0ab68a.tar.bz2
tinderbox-cluster-www-5270ca757656869bc05f5de9ef7e772b0d0ab68a.zip
update logs and add password changeHEADmaster
-rw-r--r--python/tbc_www/forms.py16
-rw-r--r--python/tbc_www/models.py37
-rw-r--r--python/tbc_www/urls.py5
-rw-r--r--python/tbc_www/utils/bugzillasubmit.py3
-rw-r--r--python/tbc_www/views.py60
-rw-r--r--python/templates/pages/cluster/index.html26
-rw-r--r--python/templates/pages/logs/build/index.html40
-rw-r--r--python/templates/pages/logs/index.html117
-rw-r--r--python/templates/registration/password_change_form.html13
9 files changed, 252 insertions, 65 deletions
diff --git a/python/tbc_www/forms.py b/python/tbc_www/forms.py
index 0a91b3b..40d1669 100644
--- a/python/tbc_www/forms.py
+++ b/python/tbc_www/forms.py
@@ -30,4 +30,18 @@ class BugForm(forms.Form):
class BugzillaUser(forms.Form):
BugzillaName = forms.CharField(label='Bugzilla Name', max_length=100)
- BugzillaPassword = forms.CharField(label='Bugzilla Password', max_length=100)
+ BugzillaPassword = forms.CharField(label='Bugzilla Password', max_length=100, widget=forms.PasswordInput)
+
+class LogsViews(forms.Form):
+ ChoicesComponent = (
+ ('All', 'All'),
+ ('Fail', 'Fail'),
+ ('Repoman', 'Repoman'),
+ ('Qa', 'Qa'),
+ ('Others', 'Others'),
+ ('Test', 'Test'),
+ ('Build', 'Build'),
+ )
+ LogView = forms.ChoiceField(widget=forms.Select, choices=ChoicesComponent, label='View')
+ def __str__(self):
+ return '%s' % (self.LogView)
diff --git a/python/tbc_www/models.py b/python/tbc_www/models.py
index b54c772..73b0413 100644
--- a/python/tbc_www/models.py
+++ b/python/tbc_www/models.py
@@ -144,13 +144,21 @@ class BuildLogsErrors(models.Model):
return '%s %s %s' % (self.Id, self.BuildLogId, self.ErrorId)
class EmergeInfo(models.Model):
- EInfoId = models.IntegerField(primary_key=True, db_column='einfo_id')
+ EInfoId = models.AutoField(primary_key=True, db_column='einfo_id')
EmergeInfoText = models.TextField(db_column='emerge_info_text')
class Meta:
db_table = 'emerge_info'
def __str__(self):
return '%s %s %s' % (self.EInfoId, self.Checksum, self.EmergeInfoText)
+class Keywords(models.Model):
+ KeywordId = models.AutoField(primary_key=True, db_column='keyword_id')
+ Keyword = models.CharField(max_length=40, db_column='keyword')
+ class Meta:
+ db_table = 'keywords'
+ def __str__(self):
+ return '%s %s' % (self.KeywordId, self.keyword)
+
class Setups(models.Model):
SetupId = models.AutoField(primary_key=True, db_column='setup_id')
Setup = models.CharField(max_length=100, db_column='setup')
@@ -170,6 +178,25 @@ class Configs(models.Model):
def __str__(self):
return '%s %s %s %s' % (self.ConfigId, self.HostName, self.SetupId, self.DefaultConfig)
+class ConfigsMetaData(models.Model):
+ Id = models.AutoField(primary_key=True, db_column='id')
+ ConfigId = models.ForeignKey(Configs, db_column='config_id')
+ KeywordId = models.ForeignKey(Keywords, db_column='keyword_id')
+ MakeConfText = models.TextField(db_column='make_conf_text')
+ Checksum = models.CharField(max_length=100, db_column='checksum')
+ ConfigSync = models.BooleanField(db_column='configsync')
+ Active = models.BooleanField(db_column='active')
+ ConfigErrorText = models.TextField(db_column='config_error_text')
+ Updateing = models.CharField(max_length=100, db_column='updateing')
+ Status = models.CharField(max_length=100, db_column='status')
+ Auto = models.BooleanField(db_column='auto')
+ RepoPath = models.CharField(max_length=200, db_column='repo_path')
+ TimeStamp = models.DateTimeField(db_column='time_stamp')
+ class Meta:
+ db_table = 'configs_metadata'
+ def __str__(self):
+ return '%s %s %s %s %s %s %s %s %s %s %s %s' % (self.ConfigId, self.KeywordId, self.MakeConfText, self.Checksum, self.ConfigSync, self.Active, self.ConfigErrorText, self.Updateing, self.Status, self.Auto, self.RepoPath, self.TimeStamp)
+
class BuildLogsConfig(models.Model):
LogId = models.IntegerField(primary_key=True, db_column='log_id')
BuildLogId = models.ForeignKey(BuildLogs, db_column='build_log_id')
@@ -242,14 +269,6 @@ class BuildJobsUse(models.Model):
def __str__(self):
return '%s %s %s %s' % (self.Id, self.BuildJobId, self.UseId, self.Status)
-class Keywords(models.Model):
- KeywordId = models.IntegerField(primary_key=True, db_column='keyword_id')
- Keyword = models.CharField(max_length=45, db_column='keyword')
- class Meta:
- db_table = 'keywords'
- def __str__(self):
- return '%s %s' % (self.KeywordId, self.Keyword)
-
class Restrictions(models.Model):
RestrictionId = models.IntegerField(primary_key=True, db_column='restriction_id')
Restriction = models.CharField(max_length=150, db_column='restriction')
diff --git a/python/tbc_www/urls.py b/python/tbc_www/urls.py
index dfea3a7..2f97143 100644
--- a/python/tbc_www/urls.py
+++ b/python/tbc_www/urls.py
@@ -9,7 +9,7 @@ urlpatterns = [
url(r'^categories/packages/versions/(?P<package_id>\d+)/$', views.versions),
url(r'^build_req/$', views.new_build_req),
url(r'^logs/build/(?P<buildlog_id>\d+)/$', views.new_logs_build, name='new_logs_build'),
- url(r'^logs/build/submitlog/(?P<buildlog_id>\d+)/$', views.buildinfo_bugzilla),
+ url(r'^logs/build/submitlog/(?P<buildlog_id>\d+)/$', views.buildinfo_bugzilla, name='buildinfo_bugzilla'),
url(r'^logs/$', views.new_logs),
url(r'^logs/all/build/$', views.new_build_logs_all),
url(r'^logs/all/repoman/$', views.new_repoman),
@@ -18,5 +18,6 @@ urlpatterns = [
url(r'^user/password_change/$', auth_views.password_change, name='password_change'),
url(r'^user/password_change/done/$', auth_views.password_change_done, name='password_change_done'),
url(r'^user/password_reset/$', auth_views.password_reset, name='password_reset'),
- url(r'^user/bugzillalogin/$', views.set_bugzilla_user),
+ url(r'^user/bugzillalogin/$', views.set_bugzilla_user, name='set_bugzilla_user'),
+ url(r'^cluster/$', views.cluster_configs)
]
diff --git a/python/tbc_www/utils/bugzillasubmit.py b/python/tbc_www/utils/bugzillasubmit.py
index d8160dc..935660d 100644
--- a/python/tbc_www/utils/bugzillasubmit.py
+++ b/python/tbc_www/utils/bugzillasubmit.py
@@ -5,8 +5,6 @@ import bugzilla
URL = "https://bugs.gentoo.org/xmlrpc.cgi"
def addnewbug(args):
bzapi = bugzilla.Bugzilla(URL)
- print(args['username'])
- print(args['password'])
bzapi.login(user=args['username'], password=args['password'])
createinfo = bzapi.build_createbug(
product=args['product'],
@@ -16,7 +14,6 @@ def addnewbug(args):
description=args['description'],
assigned_to=args['assigned_to'])
newbug = bzapi.createbug(createinfo)
- print("Created new bug id=%s url=%s" % (newbug.id, newbug.weburl))
update = bzapi.build_update(comment=args['comment'])
bzapi.update_bugs(newbug.id, update)
kwards = {
diff --git a/python/tbc_www/views.py b/python/tbc_www/views.py
index c272c50..df3a84a 100644
--- a/python/tbc_www/views.py
+++ b/python/tbc_www/views.py
@@ -11,7 +11,7 @@ from gentoo_www.models import SiteSettings, Layout, Pages, SubPages, Sponsors, P
from tbc_www.models import EbuildsMetadata, BuildLogs, BuildJobs, BuildLogsQa, \
BuildJobsUse, Categories, CategoriesMetadata, Packages, PackagesMetadata, Ebuilds, \
Repos, EbuildsKeywords, BuildLogsErrors, EbuildsRestrictions, EbuildsIuse, PackagesRepoman, \
- BuildLogsConfig, BuildLogsUse, BuildLogsRepoman, PackagesEmails, Jobs
+ BuildLogsConfig, BuildLogsUse, BuildLogsRepoman, PackagesEmails, Jobs, ConfigsMetaData
import re
import gzip
import os
@@ -258,23 +258,33 @@ def new_repoman(request):
def new_logs(request):
pagerequest = 'logs'
+ object_on_page = 100
TmpDict = default_TmpDict(pagerequest)
+ BL_tmp = BuildLogs.objects.order_by('-TimeStamp')
alist = []
- for BL in BuildLogs.objects.order_by('-TimeStamp').filter(New = True):
- adict2 = {}
- adict2['BuildLogId'] = BL.BuildLogId
- adict2['C'] = BL.EbuildId.PackageId.CategoryId.Category
- adict2['P'] = BL.EbuildId.PackageId.Package
- adict2['V'] = BL.EbuildId.Version
- adict2['R'] = BL.EbuildId.PackageId.RepoId.Repo
- adict2['Fail'] = BL.Fail
- adict2['SummeryText'] = BL.SummeryText
+ for BL in BL_tmp:
+ adict = {}
+ adict['BuildLogId'] = BL.BuildLogId
+ adict['C'] = BL.EbuildId.PackageId.CategoryId.Category
+ adict['P'] = BL.EbuildId.PackageId.Package
+ adict['V'] = BL.EbuildId.Version
+ adict['R'] = BL.EbuildId.PackageId.RepoId.Repo
+ adict['Fail'] = BL.Fail
+ adict['SummeryText'] = BL.SummeryText
if BL.Fail:
- adict2['FI'] = fail_status(BL.BuildLogId)
- alist.append(adict2)
- TmpDict['BL_tmp'] = alist
- TmpDict['QA_tmp'] = BuildLogsQa.objects.filter(BuildLogId__New = True)
- TmpDict['RM_tmp'] = BuildLogsRepoman.objects.filter(BuildLogId__New = True)
+ adict['FI'] = fail_status(BL.BuildLogId)
+ alist.append(adict)
+ paginator = Paginator(alist, object_on_page)
+ page = request.GET.get('page')
+ try:
+ BL_tmp = paginator.page(page)
+ except PageNotAnInteger:
+ # If page is not an integer, deliver first page.
+ BL_tmp = paginator.page(1)
+ except EmptyPage:
+ # If page is out of range (e.g. 9999), deliver last page of results.
+ BL_tmp = paginator.page(paginator.num_pages)
+ TmpDict['BL_tmp'] = BL_tmp
return render(request, 'pages/logs/index.html', TmpDict)
def new_build_logs_all(request):
@@ -311,7 +321,6 @@ def new_build_logs_all(request):
def new_logs_build(request, buildlog_id):
pagerequest = 'logs'
TmpDict = default_TmpDict(pagerequest)
- TmpDict['Bugzillalogin'] = False
B = BuildLogs.objects.get(BuildLogId = buildlog_id)
EM = EbuildsMetadata.objects.get(EbuildId = B.EbuildId.EbuildId)
PM = PackagesMetadata.objects.get(PackageId__PackageId = B.EbuildId.PackageId.PackageId)
@@ -389,6 +398,8 @@ def submit_to_bugzilla(request, form, buildlog_id):
Filesize = os.path.getsize(LogDir + LogFile)/1024
if Filesize > 900:
#FIXME UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
+ # python-bugzilla need a fix in attachment()
+ # f = open(attachment) -> f = open(attachment, 'rb')
with open(LogDir + LogFile, 'rb') as orig_file:
with gzip.open('/tmp' + BC.LogName + '.gz', 'wb') as zipped_file:
zipped_file.writelines(orig_file)
@@ -403,6 +414,11 @@ def submit_to_bugzilla(request, form, buildlog_id):
def buildinfo_bugzilla(request, buildlog_id):
pagerequest = 'logs'
+ if not 'bugzillapassword' in request.session:
+ request.session['bugzillabuildid'] = buildlog_id
+ return redirect('set_bugzilla_user')
+ if 'bugzillabuildid' in request.session:
+ del request.session['bugzillabuildid']
TmpDict = default_TmpDict(pagerequest)
B = get_object_or_404(BuildLogs, BuildLogId = buildlog_id)
C = B.EbuildId.PackageId.CategoryId.Category
@@ -439,10 +455,10 @@ def buildinfo_bugzilla(request, buildlog_id):
def set_bugzilla_user(request):
pagerequest = 'home'
TmpDict = default_TmpDict(pagerequest)
+ b = Bugzilla.objects.get(Username=request.user.username)
if request.method == 'POST':
form = BugzillaUser(request.POST)
if form.is_valid():
- b = Bugzilla.objects.get(Username=request.user.username)
if b == []:
b = Bugzilla(Bugzillaname = form.cleaned_data['BugzillaName'], Username = request.user.username)
b.save()
@@ -451,9 +467,19 @@ def set_bugzilla_user(request):
b.Bugzillaname = form.cleaned_data['BugzillaName']
b.save()
request.session['bugzillapassword'] = form.cleaned_data['BugzillaPassword']
+ if 'bugzillabuildid' in request.session:
+ return redirect('buildinfo_bugzilla', buildlog_id=request.session['bugzillabuildid'])
return HttpResponseRedirect('/home/')
else:
form = BugzillaUser()
+ if b != []:
+ form.fields['BugzillaName'].initial = b.Bugzillaname
TmpDict['form'] = form
return render(request, 'registration/bugzillauser.html', TmpDict)
+
+def cluster_configs(request):
+ pagerequest = 'cluster'
+ TmpDict = default_TmpDict(pagerequest)
+ TmpDict['CM_tmp'] = ConfigsMetaData.objects.all
+ return render(request, 'pages/cluster/index.html', TmpDict)
diff --git a/python/templates/pages/cluster/index.html b/python/templates/pages/cluster/index.html
new file mode 100644
index 0000000..307cae1
--- /dev/null
+++ b/python/templates/pages/cluster/index.html
@@ -0,0 +1,26 @@
+{% extends "layout/base.html" %}
+{% block content %}
+<div class="panel panel-default">
+ <div class="panel-heading">
+ <h3 class="panel-title">
+ <span class="fa fa-fw fa-history"></span>
+ <a href="/packages/added">Guests on the cluster</a>
+ </h3>
+ </div>
+ <div class="table-responsive">
+ <table class="table table-striped">
+ {% for CM in CM_tmp %}
+<tr>
+ <td>
+ <p>{{ CM.ConfigId.HostName }}</p>
+ </td>
+ <td>
+ <p>{{ CM.ConfigId.SetupId.Profile }}</p>
+ <span class="label label-info">{{ CM.Status }}</span>
+ </td>
+</tr>
+{% endfor %}
+ </table>
+ </div>
+</div>
+{% endblock %}
diff --git a/python/templates/pages/logs/build/index.html b/python/templates/pages/logs/build/index.html
index 0bbc96b..a6c13e4 100644
--- a/python/templates/pages/logs/build/index.html
+++ b/python/templates/pages/logs/build/index.html
@@ -64,6 +64,40 @@
</div>
{% endif %}
</div>
+ <div class="col-md-3">
+ <div class="panel panel-default">
+ <div class="panel-heading">
+ <h3 class="panel-title">Resources</h3>
+ </div>
+ <div class="list-group">
+ <a href="https://bugs.gentoo.org/buglist.cgi?quicksearch={{ BLI.C }}/{{ BLI.P }}" class="list-group-item" target="_blank">
+ <span class="fa fa-fw fa-bug"></span>
+ Related bugs
+ </a>
+ <a href="https://wiki.gentoo.org/index.php?title=Special%3ASearch&fulltext=Search&search={{ BLI.P }}" class="list-group-item" target="_blank">
+ <span class="fa fa-fw fa-book"></span>
+ Documentation
+ </a>
+ <a href="https://forums.gentoo.org/search.php?search_terms=all&show_results=topics&search_keywords={{ BLI.P }}&mode=results" class="list-group-item" target="_blank">
+ <span class="fa fa-fw fa-comments-o"></span>
+ Forums posts
+ </a>
+ <a href="https://gitweb.gentoo.org/repo/gentoo.git/tree/{{ BLI.C }}/{{ BLI.P }}" class="list-group-item" target="_blank">
+ <span class="fa fa-fw fa-code-fork"></span>
+ Git repository browser
+ </a>
+ <a href="https://gitweb.gentoo.org/repo/gentoo.git/log/{{ BLI.C }}/{{ BLI.P }}?showmsg=1" class="list-group-item" target="_blank">
+ <span class="fa fa-fw fa-history"></span>
+ Git log
+ </a>
+ <a href="https://gitweb.gentoo.org/repo/gentoo.git/atom/{{ BLI.C }}/{{ BLI.P }}?h=master" class="list-group-item" target="_blank">
+ <span class="fa fa-fw fa-rss"></span>
+ Changes feed
+ </a>
+ </div>
+</div>
+
+ </div>
<div class="row-fluid">
<div class=span12>
{% if BLI.Summery_text %}
@@ -99,13 +133,9 @@
{% if BLI.logname %}
<br />
Log file name:{{ BLI.logname }}<br />
- <a href="{{ STATIC_URL }}/logs/{{BLI.hostname}}/{{BLI.config}}/{{ BLI.logname }}">Raw log<a/><br />
+ <a href="/static/logs/{{BLI.hostname}}/{{BLI.config}}/{{ BLI.logname }}">Raw log<a/><br />
{% if user.is_authenticated %}
- {% if bugzillalogin %}
<a href="/logs/build/submitlog/{{BLI.BuildLogId}}/">
- {% else %}
- <a href="/user/bugzillalogin/">
- {% endif %}
Summit log to Gentoo's bugzilla</a>
{% endif %}
{% endif %}
diff --git a/python/templates/pages/logs/index.html b/python/templates/pages/logs/index.html
index ff5f354..f770f95 100644
--- a/python/templates/pages/logs/index.html
+++ b/python/templates/pages/logs/index.html
@@ -4,39 +4,100 @@
<div class="panel-heading">
<h3 class="panel-title">
<span class="fa fa-fw fa-history"></span>
- <a href="/packages/added">New Build Logs On Packages</a>
+ Logs On Packages
</h3>
+ {% if BL_tmp.has_other_pages %}
+ <ul class="pagination">
+ {% if BL_tmp.has_previous %}
+ <li><a href="?page={{ BL_tmp.previous_page_number }}">&laquo;</a></li>
+ {% else %}
+ <li class="disabled"><span>&laquo;</span></li>
+ {% endif %}
+ {% for i in BL_tmp.paginator.page_range %}
+ {% if BL_tmp.number == i %}
+ <li class="active"><span>{{ i }} <span class="sr-only">(current)</span></span></li>
+ {% else %}
+ <li><a href="?page={{ i }}">{{ i }}</a></li>
+ {% endif %}
+ {% endfor %}
+ {% if BL_tmp.has_next %}
+ <li><a href="?page={{ BL_tmp.next_page_number }}">&raquo;</a></li>
+ {% else %}
+ <li class="disabled"><span>&raquo;</span></li>
+ {% endif %}
+ </ul>
+{% endif %}
</div>
<div class="table-responsive">
<table class="table table-striped">
- {% include "includes/frontpage/new_logs" %}
- </table>
- </div>
-</div>
-<div class="panel panel-default">
- <div class="panel-heading">
- <h3 class="panel-title">
- <span class="fa fa-fw fa-history"></span>
- <a href="/packages/added">New Repoman Logs On Packages</a>
- </h3>
- </div>
- <div class="table-responsive">
- <table class="table table-striped">
- {% include "includes/frontpage/new_repoman" %}
- </table>
- </div>
-</div>
-<div class="panel panel-default">
- <div class="panel-heading">
- <h3 class="panel-title">
- <span class="fa fa-fw fa-history"></span>
- <a href="/packages/added">New Qa Logs On Packages</a>
- </h3>
- </div>
- <div class="table-responsive">
- <table class="table table-striped">
- {% include "includes/frontpage/new_qa" %}
+ {% for BL in BL_tmp %}
+<tr>
+ <td>
+ <a href="/logs/build/{{ BL.BuildLogId }}/">
+ <span class="text-muted">{{ BL.C }}/</span>/<strong>{{ BL.P }}-{{ BL.V }}::{{ BL.R }}</strong>
+ </a>
+ </td>
+ <td>
+ <p title="{{ BL.SummeryText }}">{{ BL.SummeryText|truncatewords:5 }}</p>
+ {% if BL.Fail %}
+ {% if BL.FI.others %}
+ <span class="label label-info">Others</span>
+ {% else %}
+ {% if BL.FI.qa %}
+ <span class="label label-warning">
+ {% else %}
+ <span class="label label-success">
+ {% endif %}
+ Qa</span>
+ {% if BL.FI.repoman %}
+ <span class="label label-warning">
+ {% else %}
+ <span class="label label-success">
+ {% endif %}
+ Repoman</span>
+ {% if BL.FI.TestRun %}
+ {% if BL.FI.test %}
+ <span class="label label-danger">
+ {% else %}
+ <span class="label label-success">
+ {% endif %}
+ Test</span>
+ {% endif %}
+ {% if BL.FI.build %}
+ <span class="label label-danger">{{ BL.FI.builderror }}
+ {% else %}
+ <span class="label label-success">Build
+ {% endif %}
+ </span>
+ {% endif %}
+ {% else %}
+ <span class="label label-success">Ok</span>
+ {% endif %}
+ </td>
+</tr>
+{% endfor %}
</table>
</div>
</div>
+{% if BL_tmp.has_other_pages %}
+ <ul class="pagination">
+ {% if BL_tmp.has_previous %}
+ <li><a href="?page={{ BL_tmp.previous_page_number }}">&laquo;</a></li>
+ {% else %}
+ <li class="disabled"><span>&laquo;</span></li>
+ {% endif %}
+ {% for i in BL_tmp.paginator.page_range %}
+ {% if BL_tmp.number == i %}
+ <li class="active"><span>{{ i }} <span class="sr-only">(current)</span></span></li>
+ {% else %}
+ <li><a href="?page={{ i }}">{{ i }}</a></li>
+ {% endif %}
+ {% endfor %}
+ {% if BL_tmp.has_next %}
+ <li><a href="?page={{ BL_tmp.next_page_number }}">&raquo;</a></li>
+ {% else %}
+ <li class="disabled"><span>&raquo;</span></li>
+ {% endif %}
+ </ul>
+{% endif %}
{% endblock %}
diff --git a/python/templates/registration/password_change_form.html b/python/templates/registration/password_change_form.html
new file mode 100644
index 0000000..7761fe4
--- /dev/null
+++ b/python/templates/registration/password_change_form.html
@@ -0,0 +1,13 @@
+{% extends 'layout/base.html' %}
+
+{% block title %}Change you password{% endblock %}
+
+{% block content %}
+ <h1>Change you password</h1>
+ <p>Use the form below to change your password.</p>
+ <form action="." method="post">
+ {{ form.as_p }}
+ <p><input type="submit" value="Change"></p>
+ {% csrf_token %}
+ </form>
+{% endblock %}