euscanwww: Added PoC of stabilization candidates feature

Signed-off-by: volpino <fox91@anche.no>
This commit is contained in:
volpino 2013-02-23 18:43:43 +01:00
parent 9254040b38
commit b5b05e9502
3 changed files with 75 additions and 1 deletions

View File

@ -0,0 +1,16 @@
import logging
from django.core.management.base import BaseCommand
from djeuscan.processing import set_verbosity_level
from djeuscan.processing.misc import stabilization_candidates
logger = logging.getLogger(__name__)
class Command(BaseCommand):
_overlays = {}
help = 'Collect stabilization candidates'
def handle(self, *args, **options):
set_verbosity_level(logger, options.get("verbosity", 1))
stabilization_candidates(logger=logger)

View File

@ -1,5 +1,6 @@
__all__ = ["regen_rrds", "update_counters", "update_portage_trees"] __all__ = ["regen_rrds", "update_counters", "update_portage_trees", "stabilization_candidates"]
from regen_rrds import regen_rrds from regen_rrds import regen_rrds
from update_counters import update_counters from update_counters import update_counters
from update_portage_trees import update_portage_trees from update_portage_trees import update_portage_trees
from stabilization_candidates import stabilization_candidates

View File

@ -0,0 +1,57 @@
import os.path
import re
from datetime import datetime, timedelta
from gentoolkit.package import Package
from dateutil.parser import parse
from djeuscan.processing import FakeLogger
from djeuscan.models import Version
def get_version_date(version, date_limit):
"""
Returns the datetime when the version was added to Portage, if less than date_limit
"""
changelog_path = os.path.join(os.path.dirname(version.ebuild_path), "ChangeLog")
if not os.path.exists(changelog_path):
return
with open(changelog_path) as changelog:
for line in changelog:
match = re.match(r"^\*([^\(]+) \((\d\d \w\w\w \d\d\d\d)\)\s*$", line)
if match:
version_date = parse(match.group(2)).date()
if version_date < date_limit:
return version_date
def stabilization_candidates(date_limit=None, logger=None):
"""
Collect stabilization candidates
"""
if logger is None:
logger = FakeLogger()
if date_limit is None:
date_limit = (datetime.utcnow() - timedelta(days=30)).date()
logger.info("Starting collecting stabilization candidates - date_limit=%s", str(date_limit))
# Set all versions to not be stabilization_candidates
#Version.objects.update(stabilization_candidate=False)
# For every version check if it's unstable.
# If it is then check if can be a stabilization candidate
for version in Version.objects.filter(overlay='gentoo').exclude(version='9999').exclude(version='99999999'):
pkg = Package(version.cpv())
keywords = pkg.environment("KEYWORDS").split()
if all([x.startswith("~") for x in keywords]):
version_date = get_version_date(version, date_limit)
if version_date:
logger.info('+ [s] %s @ %s', version, version_date)
# XXX: What should we save? A flag and version_date? Just the date?
#version.stabilization_candidate = True
#version.save()
logger.info("Finished collecting stabilization candidates")