From c81aa8955dd5992f7039e1640243325c82d011cc Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Fri, 16 Mar 2012 09:12:44 -0500 Subject: reporead: rename Pkg to RepoPackage The bytes saved on the shorter name aren't worth it. Also ensure 'desc' is always initialized to None in case packages do not provide one. Signed-off-by: Dan McGee --- devel/management/commands/reporead.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'devel') diff --git a/devel/management/commands/reporead.py b/devel/management/commands/reporead.py index 3ed95a9d..8369b6ec 100644 --- a/devel/management/commands/reporead.py +++ b/devel/management/commands/reporead.py @@ -70,7 +70,7 @@ def handle(self, arch=None, filename=None, **options): return read_repo(arch, filename, options) -class Pkg(object): +class RepoPackage(object): """An interim 'container' object for holding Arch package data.""" bare = ( 'name', 'base', 'arch', 'filename', 'md5sum', 'sha256sum', 'url', 'packager' ) @@ -85,6 +85,7 @@ def __init__(self, repo): self.ver = None self.rel = None self.epoch = 0 + self.desc = None self.pgpsig = None for k in self.bare + self.number: setattr(self, k, None) @@ -458,7 +459,7 @@ def parse_info(iofile): def parse_repo(repopath): """ - Parses an Arch repo db file, and returns a list of Pkg objects. + Parses an Arch repo db file, and returns a list of RepoPackage objects. Arguments: repopath -- The path of a repository db file. @@ -480,7 +481,7 @@ def parse_repo(repopath): repodb = tarfile.open(repopath, "r") logger.debug("Starting package parsing") dbfiles = ('desc', 'depends', 'files') - newpkg = lambda: Pkg(reponame) + newpkg = lambda: RepoPackage(reponame) pkgs = defaultdict(newpkg) for tarinfo in repodb.getmembers(): if tarinfo.isreg(): -- cgit v1.2.3-54-g00ecf From 7d8580b4b151f1357632a26739287b9e4e99fc06 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Wed, 21 Mar 2012 15:52:40 -0500 Subject: Add number of keys signed to master keys page This really just makes me look bad, but an interesting fact none the less for people to look at. Signed-off-by: Dan McGee --- devel/models.py | 6 ++---- public/views.py | 15 ++++++++++++--- templates/public/keys.html | 4 +++- 3 files changed, 17 insertions(+), 8 deletions(-) (limited to 'devel') diff --git a/devel/models.py b/devel/models.py index a9a2efc5..2fc61060 100644 --- a/devel/models.py +++ b/devel/models.py @@ -24,10 +24,8 @@ def __unicode__(self): class PGPSignature(models.Model): - signer = PGPKeyField(max_length=40, verbose_name="Signer key fingerprint", - help_text="consists of 40 hex digits; use `gpg --fingerprint`") - signee = PGPKeyField(max_length=40, verbose_name="Signee key fingerprint", - help_text="consists of 40 hex digits; use `gpg --fingerprint`") + signer = PGPKeyField(max_length=40, verbose_name="Signer key fingerprint") + signee = PGPKeyField(max_length=40, verbose_name="Signee key fingerprint") created = models.DateField() expires = models.DateField(null=True, blank=True) valid = models.BooleanField(default=True) diff --git a/public/views.py b/public/views.py index 1f7006a6..1e1ffc6c 100644 --- a/public/views.py +++ b/public/views.py @@ -1,11 +1,12 @@ from django.conf import settings from django.contrib.auth.models import User +from django.db.models import Count from django.http import Http404 from django.views.decorators.cache import cache_control from django.views.generic import list_detail from django.views.generic.simple import direct_to_template -from devel.models import MasterKey +from devel.models import MasterKey, PGPSignature from main.models import Arch, Repo, Donor from mirrors.models import MirrorUrl from news.models import News @@ -87,9 +88,17 @@ def feeds(request): @cache_control(max_age=300) def keys(request): + master_keys = MasterKey.objects.select_related('owner', 'revoker', + 'owner__userprofile', 'revoker__userprofile').filter( + revoked__isnull=True) + sig_counts = PGPSignature.objects.filter(valid=True, + expires__isnull=True).values_list('signer').annotate( + Count('signer')) + sig_counts = dict((key_id[-16:], ct) for key_id, ct in sig_counts) + for key in master_keys: + key.signature_count = sig_counts.get(key.pgp_key[-16:], 0) context = { - 'keys': MasterKey.objects.select_related('owner', 'revoker', - 'owner__userprofile', 'revoker__userprofile').all(), + 'keys': master_keys, } return direct_to_template(request, 'public/keys.html', context) diff --git a/templates/public/keys.html b/templates/public/keys.html index 2e7fcebe..6b06cc32 100644 --- a/templates/public/keys.html +++ b/templates/public/keys.html @@ -34,13 +34,14 @@

Master Signing Keys

Owner's Signing Key Revoker Revoker's Signing Key + Developer/TU Keys Signed {% for key in keys %} {% pgp_key_link key.pgp_key %} - {{ key.pgp_key|pgp_fingerprint }} + {{ key.pgp_key|pgp_fingerprint }} {% with key.owner.userprofile as owner_profile %} {{ key.owner.get_full_name }} {% pgp_key_link owner_profile.pgp_key %} @@ -49,6 +50,7 @@

Master Signing Keys

{{ key.revoker.get_full_name }} {% pgp_key_link revoker_profile.pgp_key %} {% endwith %} + {{ key.signature_count }} {% endfor %} -- cgit v1.2.3-54-g00ecf From 99da2f78b8fbc2577f82895074ae868683e0ed5e Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Wed, 21 Mar 2012 15:58:15 -0500 Subject: Ensure clocks Expires header works in 59th minute of hour This was a rather careless oversight on my part. Signed-off-by: Dan McGee --- devel/views.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'devel') diff --git a/devel/views.py b/devel/views.py index d836bd78..328d52e4 100644 --- a/devel/views.py +++ b/devel/views.py @@ -101,8 +101,8 @@ def clock(request): response = direct_to_template(request, 'devel/clock.html', page_dict) if not response.has_header('Expires'): # why this works only with the non-UTC date I have no idea... - expire_time = now.replace(minute=utc_now.minute + 1, - second=0, microsecond=0) + expire_time = now.replace(second=0, microsecond=0) + expire_time += timedelta(minutes=1) expire_time = time.mktime(expire_time.timetuple()) response['Expires'] = http_date(expire_time) return response -- cgit v1.2.3-54-g00ecf From a7dc2a99b6d3343256aef2acc61452c93c4d81fc Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Fri, 23 Mar 2012 19:35:54 -0500 Subject: reporead: blow up when package found with wrong architecture Signed-off-by: Dan McGee --- devel/management/commands/reporead.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'devel') diff --git a/devel/management/commands/reporead.py b/devel/management/commands/reporead.py index 8369b6ec..7373c56d 100644 --- a/devel/management/commands/reporead.py +++ b/devel/management/commands/reporead.py @@ -537,8 +537,9 @@ def read_repo(primary_arch, repo_file, options): if package.arch in packages_arches: packages_arches[package.arch].append(package) else: - # we don't include mis-arched packages - logger.warning("Package %s arch = %s", package.name, package.arch) + raise Exception( + "Package %s in database %s had wrong architecture %s" % ( + package.name, repo_file, package.arch)) del packages logger.info('Starting database updates for %s.', repo_file) -- cgit v1.2.3-54-g00ecf