summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'python/tbc_www')
-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
5 files changed, 89 insertions, 32 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)