From 83f5df4daf6fc6d074b9f0afb51bb3bbaad9a33c Mon Sep 17 00:00:00 2001 From: Corentin Chary Date: Tue, 29 May 2012 15:29:03 +0200 Subject: [PATCH] euscanwww: fix the scan process Signed-off-by: Corentin Chary --- .../djeuscan/management/commands/scan_metadata.py | 14 ++++++++++---- .../djeuscan/management/commands/scan_portage.py | 1 - .../djeuscan/management/commands/scan_upstream.py | 5 ++++- euscanwww/djeuscan/models.py | 11 ++++++----- 4 files changed, 20 insertions(+), 11 deletions(-) diff --git a/euscanwww/djeuscan/management/commands/scan_metadata.py b/euscanwww/djeuscan/management/commands/scan_metadata.py index 8590412..d9ec08c 100644 --- a/euscanwww/djeuscan/management/commands/scan_metadata.py +++ b/euscanwww/djeuscan/management/commands/scan_metadata.py @@ -8,6 +8,7 @@ from gentoolkit.errors import GentoolkitFatalError from django.db.transaction import commit_on_success from django.core.management.base import BaseCommand from django.core.management.color import color_style +from django.core.exceptions import ValidationError from djeuscan.models import Package, Herd, Maintainer @@ -89,10 +90,15 @@ class ScanMetadata(object): for maintainer in new_maintainers: maintainer = maintainers[maintainer] - maintainer = self.store_maintainer( - maintainer.name, maintainer.email - ) - obj.maintainers.add(maintainer) + try: + maintainer = self.store_maintainer( + maintainer.name, maintainer.email + ) + obj.maintainers.add(maintainer) + except ValidationError: + sys.stderr.write( + self.style.ERROR("Bad maintainer: '%s' '%s'\n" % (maintainer.name, maintainer.email)) + ) obj.save() diff --git a/euscanwww/djeuscan/management/commands/scan_portage.py b/euscanwww/djeuscan/management/commands/scan_portage.py index 4227501..86481e1 100644 --- a/euscanwww/djeuscan/management/commands/scan_portage.py +++ b/euscanwww/djeuscan/management/commands/scan_portage.py @@ -242,7 +242,6 @@ class ScanPortage(object): overlay=obj.overlay ) - @commit_on_success def purge_versions(options): # For each dead versions diff --git a/euscanwww/djeuscan/management/commands/scan_upstream.py b/euscanwww/djeuscan/management/commands/scan_upstream.py index f6e78c3..c5e95b0 100644 --- a/euscanwww/djeuscan/management/commands/scan_upstream.py +++ b/euscanwww/djeuscan/management/commands/scan_upstream.py @@ -88,6 +88,9 @@ class ScanUpstream(object): def parse_output(self, output): from portage.versions import _cp + if type(_cp) == dict: + _cp = _cp["dots_allowed_in_PN"] + package_re = re.compile( r'^ \* (?P' + _cp + ') \[(?P.*?)\]$' ) @@ -177,7 +180,7 @@ class Command(BaseCommand): scan_upstream = ScanUpstream(options) if options['feed']: - scan_upstream.parse_output(options, sys.stdin) + scan_upstream.parse_output(sys.stdin) if options['purge-versions']: purge_versions(options) return diff --git a/euscanwww/djeuscan/models.py b/euscanwww/djeuscan/models.py index 727deef..9445af4 100644 --- a/euscanwww/djeuscan/models.py +++ b/euscanwww/djeuscan/models.py @@ -115,11 +115,12 @@ class Version(models.Model): """ package = models.ForeignKey(Package) - slot = models.CharField(max_length=128) + slot = models.CharField(max_length=128, blank=True, default='') revision = models.CharField(max_length=128) version = models.CharField(max_length=128) packaged = models.BooleanField() - overlay = models.CharField(max_length=128, default='gentoo', db_index=True, + overlay = models.CharField(max_length=128, blank=True, + default='gentoo', db_index=True, validators=[validate_name]) urls = models.TextField(blank=True) alive = models.BooleanField(default=True, db_index=True) @@ -148,12 +149,12 @@ class VersionLog(models.Model): package = models.ForeignKey(Package) datetime = models.DateTimeField(auto_now_add=True) - slot = models.CharField(max_length=128) + slot = models.CharField(max_length=128, blank=True, default='') revision = models.CharField(max_length=128) version = models.CharField(max_length=128) packaged = models.BooleanField() - overlay = models.CharField(max_length=128, default='gentoo', - validators=[validate_name]) + overlay = models.CharField(max_length=128, blank=True, + default='gentoo', validators=[validate_name]) action = models.IntegerField(choices=VERSION_ACTIONS) objects = VersionLogManager()