diff options
author | 2013-02-23 18:43:43 +0100 | |
---|---|---|
committer | 2013-02-23 18:43:43 +0100 | |
commit | b5b05e95020925a72fef57716b3ff4d01a67b53c (patch) | |
tree | 83e93081e5de8280188afb028cf6b93dd3e64a67 | |
parent | Merge branch 'master' of github.com:volpino/euscan (diff) | |
download | euscan-b5b05e95020925a72fef57716b3ff4d01a67b53c.tar.gz euscan-b5b05e95020925a72fef57716b3ff4d01a67b53c.tar.bz2 euscan-b5b05e95020925a72fef57716b3ff4d01a67b53c.zip |
euscanwww: Added PoC of stabilization candidates feature
Signed-off-by: volpino <fox91@anche.no>
3 files changed, 75 insertions, 1 deletions
diff --git a/euscanwww/djeuscan/management/commands/stabilization_candidates.py b/euscanwww/djeuscan/management/commands/stabilization_candidates.py new file mode 100644 index 0000000..140bb61 --- /dev/null +++ b/euscanwww/djeuscan/management/commands/stabilization_candidates.py @@ -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)
\ No newline at end of file diff --git a/euscanwww/djeuscan/processing/misc/__init__.py b/euscanwww/djeuscan/processing/misc/__init__.py index b5664ad..dc2bd59 100644 --- a/euscanwww/djeuscan/processing/misc/__init__.py +++ b/euscanwww/djeuscan/processing/misc/__init__.py @@ -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 update_counters import update_counters from update_portage_trees import update_portage_trees +from stabilization_candidates import stabilization_candidates
\ No newline at end of file diff --git a/euscanwww/djeuscan/processing/misc/stabilization_candidates.py b/euscanwww/djeuscan/processing/misc/stabilization_candidates.py new file mode 100644 index 0000000..f85e1f4 --- /dev/null +++ b/euscanwww/djeuscan/processing/misc/stabilization_candidates.py @@ -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") |