From f0a858aab6691438eeec9094c2d46d95b5ddb306 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Tue, 7 Feb 2012 00:46:21 -0600 Subject: Make rematch command do a bit more Now that we have a few objects that can potentially link back to developers, allow flag requests to also be rematched. Signed-off-by: Dan McGee --- devel/management/commands/rematch_packager.py | 64 --------------------------- 1 file changed, 64 deletions(-) delete mode 100644 devel/management/commands/rematch_packager.py (limited to 'devel/management/commands/rematch_packager.py') diff --git a/devel/management/commands/rematch_packager.py b/devel/management/commands/rematch_packager.py deleted file mode 100644 index 461d83ab..00000000 --- a/devel/management/commands/rematch_packager.py +++ /dev/null @@ -1,64 +0,0 @@ -# -*- coding: utf-8 -*- -""" -rematch_packager command - -Match all packages with a packager_str but NULL packager_id to a packager if we -can find one. - -Usage: ./manage.py rematch_packager -""" - -from django.core.management.base import NoArgsCommand - -import sys -import logging - -from devel.utils import UserFinder -from main.models import Package - -logging.basicConfig( - level=logging.INFO, - format='%(asctime)s -> %(levelname)s: %(message)s', - datefmt='%Y-%m-%d %H:%M:%S', - stream=sys.stderr) -logger = logging.getLogger() - -class Command(NoArgsCommand): - help = "Match all packages with a packager_str but NULL packager_id to a packager if we can find one." - - def handle_noargs(self, **options): - v = int(options.get('verbosity', None)) - if v == 0: - logger.level = logging.ERROR - elif v == 1: - logger.level = logging.INFO - elif v == 2: - logger.level = logging.DEBUG - - return match_packager() - -def match_packager(): - finder = UserFinder() - logger.info("getting all unmatched packages") - package_count = matched_count = 0 - unknown = set() - - for package in Package.objects.filter(packager__isnull=True): - logger.debug("package %s, packager string %s", - package.pkgname, package.packager_str) - package_count += 1 - user = finder.find(package.packager_str) - if user: - package.packager = user - logger.debug(" found user %s" % user.username) - package.save() - matched_count += 1 - else: - unknown.add(package.packager_str) - - logger.info("%d packages checked, %d newly matched", - package_count, matched_count) - logger.debug("unknown packagers:\n%s", - "\n".join(unknown)) - -# vim: set ts=4 sw=4 et: -- cgit v1.2.3-2-g168b