euscan: stuff
(yeah, sorry ..) Signed-off-by: Corentin Chary <corentin.chary@gmail.com>
This commit is contained in:
parent
6ec059bdc2
commit
6ce658fa0d
@ -143,15 +143,15 @@ class Version(models.Model):
|
||||
unique_together = ['package', 'slot', 'revision', 'version', 'overlay']
|
||||
|
||||
def cpv(self):
|
||||
return '%s/%s-%s-%s' % (
|
||||
return '%s/%s-%s%s' % (
|
||||
self.package.category, self.package.name, self.version,
|
||||
self.revision if self.revision != 'r0' else ''
|
||||
self.revision if self.revision != '-r0' else ''
|
||||
)
|
||||
|
||||
def __unicode__(self):
|
||||
return '%s/%s-%s-%s:%s [%s]' % (
|
||||
return '%s/%s-%s%s:%s [%s]' % (
|
||||
self.package.category, self.package.name, self.version,
|
||||
self.revision if self.revision != 'r0' else '',
|
||||
self.revision if self.revision != '-r0' else '',
|
||||
self.slot, self.overlay or "<upstream>"
|
||||
)
|
||||
|
||||
@ -219,7 +219,10 @@ class EuscanResult(models.Model):
|
||||
|
||||
@property
|
||||
def messages(self):
|
||||
try:
|
||||
result = json.loads(self.result)
|
||||
except ValueError:
|
||||
return self.result
|
||||
|
||||
if result and self.package.cp() in result:
|
||||
return result[self.package.cp()]['messages']
|
||||
|
@ -2,7 +2,7 @@ from django.db.transaction import commit_on_success
|
||||
from django.utils import timezone
|
||||
|
||||
from djeuscan.models import Package, Herd, Maintainer, Version, HerdLog, \
|
||||
MaintainerLog, CategoryLog, WorldLog, Category, Overlay
|
||||
MaintainerLog, CategoryLog, WorldLog
|
||||
from djeuscan import charts
|
||||
from djeuscan.processing import FakeLogger
|
||||
|
||||
@ -48,19 +48,6 @@ def update_counters(fast=False, nolog=False, logger=None):
|
||||
|
||||
wlog = None
|
||||
|
||||
# Populate Category and Overlay
|
||||
for cat in Package.objects.values('category').distinct():
|
||||
obj, created = Category.objects.get_or_create(name=cat["category"])
|
||||
if created:
|
||||
logger.info("+ [c] %s", cat["category"])
|
||||
|
||||
for overlay in Version.objects.values('overlay').distinct():
|
||||
if not overlay["overlay"]:
|
||||
continue
|
||||
obj, created = Overlay.objects.get_or_create(name=overlay["overlay"])
|
||||
if created:
|
||||
logger.info("+ [o] %s", overlay["overlay"])
|
||||
|
||||
if not nolog:
|
||||
wlog = WorldLog()
|
||||
wlog.datetime = now
|
||||
|
@ -11,8 +11,7 @@ from django.core.management.color import color_style
|
||||
from euscan.version import get_version_type
|
||||
|
||||
from djeuscan.processing import FakeLogger
|
||||
from djeuscan.models import Package, Version, VersionLog
|
||||
|
||||
from djeuscan.models import Package, Version, VersionLog, Category, Overlay
|
||||
|
||||
class ScanPortage(object):
|
||||
def __init__(self, logger=None, no_log=False, purge_packages=False,
|
||||
@ -359,4 +358,20 @@ def scan_portage(packages=None, category=None, no_log=False,
|
||||
else:
|
||||
scan_handler.scan(pkg)
|
||||
|
||||
# Populate Category and Overlay
|
||||
# TODO: - use portage.settings.categories()
|
||||
# - read metadata.xml to add description
|
||||
for cat in Package.objects.values('category').distinct():
|
||||
obj, created = Category.objects.get_or_create(name=cat["category"])
|
||||
if created:
|
||||
logger.info("+ [c] %s", cat["category"])
|
||||
|
||||
# TODO: - get informations from layman and portage (path, url)
|
||||
for overlay in Version.objects.values('overlay').distinct():
|
||||
if not overlay["overlay"]:
|
||||
continue
|
||||
obj, created = Overlay.objects.get_or_create(name=overlay["overlay"])
|
||||
if created:
|
||||
logger.info("+ [o] %s", overlay["overlay"])
|
||||
|
||||
logger.info('Done.')
|
||||
|
@ -173,7 +173,7 @@ def update_portage(packages=None):
|
||||
@task
|
||||
def update_upstream():
|
||||
if settings.TASKS_UPSTREAM_GROUPS >= 1:
|
||||
packages = Package.objects.all().order_by("pk")
|
||||
packages = Package.objects.all().order_by('pk') # .order_by('?') ?
|
||||
|
||||
scan_upstream_sub = group_chunks(scan_upstream, packages,
|
||||
settings.TASKS_UPSTREAM_GROUPS,
|
||||
|
@ -66,9 +66,11 @@ def category(request, category):
|
||||
|
||||
favourited = False
|
||||
if request.user.is_authenticated():
|
||||
if Category.objects.get(name=category) in \
|
||||
get_profile(request.user).categories.all():
|
||||
favourited = True
|
||||
try:
|
||||
category = Category.objects.get(name=category)
|
||||
favourited = category in get_profile(request.user).categories.all()
|
||||
except Category.DoesNotExist:
|
||||
pass
|
||||
|
||||
return {'category': category, 'packages': packages, 'last_scan': last_scan,
|
||||
'favourited': favourited}
|
||||
@ -162,9 +164,11 @@ def overlay(request, overlay):
|
||||
|
||||
favourited = False
|
||||
if request.user.is_authenticated():
|
||||
if Overlay.objects.get(name=overlay) in \
|
||||
get_profile(request.user).overlays.all():
|
||||
favourited = True
|
||||
try:
|
||||
overlay = Overlay.objects.get(name=overlay)
|
||||
favourited = overlay in get_profile(request.user).overlays.all()
|
||||
except Overlay.DoesNotExist:
|
||||
pass
|
||||
|
||||
return {'overlay': overlay, 'packages': packages, 'last_scan': last_scan,
|
||||
'favourited': favourited}
|
||||
|
Loading…
Reference in New Issue
Block a user