euscanwww: fix the scan process

Signed-off-by: Corentin Chary <corentin.chary@gmail.com>
This commit is contained in:
Corentin Chary 2012-05-29 15:29:03 +02:00
parent f0a3c34ac8
commit 83f5df4daf
4 changed files with 20 additions and 11 deletions

View File

@ -8,6 +8,7 @@ from gentoolkit.errors import GentoolkitFatalError
from django.db.transaction import commit_on_success from django.db.transaction import commit_on_success
from django.core.management.base import BaseCommand from django.core.management.base import BaseCommand
from django.core.management.color import color_style from django.core.management.color import color_style
from django.core.exceptions import ValidationError
from djeuscan.models import Package, Herd, Maintainer from djeuscan.models import Package, Herd, Maintainer
@ -89,10 +90,15 @@ class ScanMetadata(object):
for maintainer in new_maintainers: for maintainer in new_maintainers:
maintainer = maintainers[maintainer] maintainer = maintainers[maintainer]
try:
maintainer = self.store_maintainer( maintainer = self.store_maintainer(
maintainer.name, maintainer.email maintainer.name, maintainer.email
) )
obj.maintainers.add(maintainer) obj.maintainers.add(maintainer)
except ValidationError:
sys.stderr.write(
self.style.ERROR("Bad maintainer: '%s' '%s'\n" % (maintainer.name, maintainer.email))
)
obj.save() obj.save()

View File

@ -242,7 +242,6 @@ class ScanPortage(object):
overlay=obj.overlay overlay=obj.overlay
) )
@commit_on_success @commit_on_success
def purge_versions(options): def purge_versions(options):
# For each dead versions # For each dead versions

View File

@ -88,6 +88,9 @@ class ScanUpstream(object):
def parse_output(self, output): def parse_output(self, output):
from portage.versions import _cp from portage.versions import _cp
if type(_cp) == dict:
_cp = _cp["dots_allowed_in_PN"]
package_re = re.compile( package_re = re.compile(
r'^ \* (?P<cpv>' + _cp + ') \[(?P<overlay>.*?)\]$' r'^ \* (?P<cpv>' + _cp + ') \[(?P<overlay>.*?)\]$'
) )
@ -177,7 +180,7 @@ class Command(BaseCommand):
scan_upstream = ScanUpstream(options) scan_upstream = ScanUpstream(options)
if options['feed']: if options['feed']:
scan_upstream.parse_output(options, sys.stdin) scan_upstream.parse_output(sys.stdin)
if options['purge-versions']: if options['purge-versions']:
purge_versions(options) purge_versions(options)
return return

View File

@ -115,11 +115,12 @@ class Version(models.Model):
""" """
package = models.ForeignKey(Package) 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) revision = models.CharField(max_length=128)
version = models.CharField(max_length=128) version = models.CharField(max_length=128)
packaged = models.BooleanField() 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]) validators=[validate_name])
urls = models.TextField(blank=True) urls = models.TextField(blank=True)
alive = models.BooleanField(default=True, db_index=True) alive = models.BooleanField(default=True, db_index=True)
@ -148,12 +149,12 @@ class VersionLog(models.Model):
package = models.ForeignKey(Package) package = models.ForeignKey(Package)
datetime = models.DateTimeField(auto_now_add=True) 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) revision = models.CharField(max_length=128)
version = models.CharField(max_length=128) version = models.CharField(max_length=128)
packaged = models.BooleanField() packaged = models.BooleanField()
overlay = models.CharField(max_length=128, default='gentoo', overlay = models.CharField(max_length=128, blank=True,
validators=[validate_name]) default='gentoo', validators=[validate_name])
action = models.IntegerField(choices=VERSION_ACTIONS) action = models.IntegerField(choices=VERSION_ACTIONS)
objects = VersionLogManager() objects = VersionLogManager()