Control: -1 +patch > One thing I'm missing right now is a warning about autoremovals from > testing.
Hi, The following patch should display the autoremoval notifications in the action needed panel. Cheers, Christophe
>From 678f25417b15ee2e765446676f9d11e81429a502 Mon Sep 17 00:00:00 2001 From: Christophe Siraut <d...@tobald.eu.org> Date: Mon, 11 Aug 2014 10:50:07 +0200 Subject: [PATCH 1/3] Add an actionitem for auto-removals. --- .../templates/debian/autoremoval-action-item.html | 7 ++ distro_tracker/vendor/debian/tracker_tasks.py | 78 ++++++++++++++++++++++ 2 files changed, 85 insertions(+) create mode 100644 distro_tracker/vendor/debian/templates/debian/autoremoval-action-item.html diff --git a/distro_tracker/vendor/debian/templates/debian/autoremoval-action-item.html b/distro_tracker/vendor/debian/templates/debian/autoremoval-action-item.html new file mode 100644 index 0000000..52291a1 --- /dev/null +++ b/distro_tracker/vendor/debian/templates/debian/autoremoval-action-item.html @@ -0,0 +1,7 @@ +{% spaceless %} +{% with version=item.extra_data.version %} +<div> + <span>Version {{ version }} is marked for autoremoval from testing. You should try to prevent the removal from testing by fixing RC bugs.</span> +</div> +{% endwith %} +{% endspaceless %} diff --git a/distro_tracker/vendor/debian/tracker_tasks.py b/distro_tracker/vendor/debian/tracker_tasks.py index 920ac62..d03dfb9 100644 --- a/distro_tracker/vendor/debian/tracker_tasks.py +++ b/distro_tracker/vendor/debian/tracker_tasks.py @@ -1686,6 +1686,84 @@ class UpdateUbuntuStatsTask(BaseTask): patch_diff=diff) +class UpdateAutoremovalStatsTask(BaseTask): + """ + A task for updating autoremovals information on all packages. + """ + ACTION_ITEM_TYPE_NAME = 'debian-autoremoval' + ACTION_ITEM_TEMPLATE = 'debian/autoremoval-action-item.html' + ITEM_DESCRIPTION = 'Marked for autoremoval on {removal_date}: {bugs}' + + def __init__(self, force_update=False, *args, **kwargs): + super(UpdateAutoremovalStatsTask, self).__init__(*args, **kwargs) + self.force_update = force_update + self.action_item_type = ActionItemType.objects.create_or_update( + type_name=self.ACTION_ITEM_TYPE_NAME, + full_description_template=self.ACTION_ITEM_TEMPLATE) + + def set_parameters(self, parameters): + if 'force_update' in parameters: + self.force_update = parameters['force_update'] + + def _get_autoremoval_content(self): + url = 'http://udd.debian.org/cgi-bin/autoremovals.yaml.cgi' + cache = HttpCache(settings.DISTRO_TRACKER_CACHE_DIRECTORY) + if not cache.is_expired(url): + return + response, updated = cache.update(url, force=self.force_update) + if not updated: + return + return yaml.safe_load(six.BytesIO(response.content)) + + def get_autoremovals_stats(self): + """ + Retrieves and parses the autoremoval stats for all packages. + Autoremoval stats include the BTS bugs id. + + :returns: A dict mapping package names to autoremoval stats. + """ + return self._get_autoremoval_content() + + def update_action_item(self, package, stats): + """ + Creates an :class:`ActionItem <distro_tracker.core.models.ActionItem>` + instance for the given type indicating that the package has an + autoremoval issue. + """ + action_item = package.get_action_item_for_type(self.action_item_type) + if not action_item: + action_item = ActionItem( + package=package, + item_type=self.action_item_type) + + action_item.short_description = self.ITEM_DESCRIPTION.format( + removal_date=stats['removal_date'].strftime('%d %B'), + bugs=', '.join('<a href="http://bugs.debian.org/{}">{}</a>' + .format(bug, bug) for bug in stats['bugs'])) + + action_item.extra_data = { + 'version': stats['version'], + 'removal_date': stats['removal_date'] + } + action_item.save() + + def execute(self): + autoremovals_stats = self.get_autoremovals_stats() + if autoremovals_stats is None: + # Nothing to do: cached content up to date + return + + ActionItem.objects.delete_obsolete_items( + item_types=[self.action_item_type], + non_obsolete_packages=autoremovals_stats.keys()) + + packages = SourcePackageName.objects.filter(name__in=autoremovals_stats.keys()) + packages = packages.prefetch_related('action_items') + + for package in packages: + self.update_action_item(package, autoremovals_stats[package.name]) + + class UpdateWnppStatsTask(BaseTask): """ The task updates the WNPP bugs for all packages. -- 2.0.1