Conflicts:
	euscanwww/djeuscan/models.py

Signed-off-by: volpino <fox91@anche.no>
This commit is contained in:
volpino 2012-06-08 14:46:37 +02:00
commit 9cddc82808
5 changed files with 27 additions and 15 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]
maintainer = self.store_maintainer( try:
maintainer.name, maintainer.email maintainer = self.store_maintainer(
) 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

@ -205,10 +205,10 @@ class ScanPortage(object):
overlay=overlay, overlay=overlay,
defaults={"alive": True, "packaged": True} defaults={"alive": True, "packaged": True}
) )
if not created: if not created: # Created objects have defaults values
obj.alive = True obj.alive = True
obj.packaged = True obj.packaged = True
obj.save() obj.save()
if created: if created:
self.cache_store_version(obj) self.cache_store_version(obj)
@ -240,7 +240,6 @@ class ScanPortage(object):
overlay=obj.overlay overlay=obj.overlay
) )
@commit_on_success @commit_on_success
def purge_versions(quiet=False, nolog=False): def purge_versions(quiet=False, nolog=False):
# For each dead versions # For each dead versions

View File

@ -68,7 +68,7 @@ class ScanUpstream(object):
def store_version(self, package, ver, url): def store_version(self, package, ver, url):
obj, created = Version.objects.get_or_create( obj, created = Version.objects.get_or_create(
package=package, slot='', revision='r0', version=ver, overlay='', package=package, slot='', revision='r0', version=ver, overlay='',
defaults={"alive": True, "urls": url, "packaged": True} defaults={"alive": True, "urls": url, "packaged": False}
) )
if not created: if not created:
obj.alive = True obj.alive = True
@ -99,6 +99,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>.*?)\]$'
) )

View File

@ -115,7 +115,7 @@ class Version(models.Model):
""" """
package = models.ForeignKey(Package) package = models.ForeignKey(Package)
slot = models.CharField(max_length=128, blank=True) 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()
@ -148,7 +148,7 @@ 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, blank=True) 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()

View File

@ -10,7 +10,6 @@ from portage.dbapi import porttree
import gentoolkit.pprinter as pp import gentoolkit.pprinter as pp
from gentoolkit.query import Query from gentoolkit.query import Query
from gentoolkit.package import Package from gentoolkit.package import Package
from gentoolkit.eclean.search import (port_settings)
from euscan import CONFIG, BLACKLIST_PACKAGES from euscan import CONFIG, BLACKLIST_PACKAGES
from euscan import handlers, helpers, output from euscan import handlers, helpers, output
@ -95,10 +94,15 @@ def scan_upstream_urls(cpv, urls, on_progress):
# gentoolkit stores PORTDB, so even if we modify it to add an overlay # gentoolkit stores PORTDB, so even if we modify it to add an overlay
# it will still use the old dbapi # it will still use the old dbapi
def reload_gentoolkit(): def reload_gentoolkit():
from gentoolkit import dbapi
import gentoolkit.package import gentoolkit.package
import gentoolkit.query import gentoolkit.query
PORTDB = portage.db[portage.root]["porttree"].dbapi PORTDB = portage.db[portage.root]["porttree"].dbapi
dbapi.PORTDB = PORTDB
if hasattr(dbapi, 'PORTDB'):
dbapi.PORTDB = PORTDB
if hasattr(gentoolkit.package, 'PORTDB'): if hasattr(gentoolkit.package, 'PORTDB'):
gentoolkit.package.PORTDB = PORTDB gentoolkit.package.PORTDB = PORTDB
if hasattr(gentoolkit.query, 'PORTDB'): if hasattr(gentoolkit.query, 'PORTDB'):
@ -182,10 +186,10 @@ def scan_upstream(query, on_progress=None):
cpv = pkg.cpv cpv = pkg.cpv
metadata = { metadata = {
"EAPI": port_settings["EAPI"], "EAPI": portage.settings["EAPI"],
"SRC_URI": pkg.environment("SRC_URI", False), "SRC_URI": pkg.environment("SRC_URI", False),
} }
use = frozenset(port_settings["PORTAGE_USE"].split()) use = frozenset(portage.settings["PORTAGE_USE"].split())
try: try:
alist = porttree._parse_uri_map(cpv, metadata, use=use) alist = porttree._parse_uri_map(cpv, metadata, use=use)
aalist = porttree._parse_uri_map(cpv, metadata) aalist = porttree._parse_uri_map(cpv, metadata)