2011-04-13 19:00:31 +02:00
|
|
|
import sys
|
2012-06-22 11:31:15 +02:00
|
|
|
import logging
|
2011-04-13 19:00:31 +02:00
|
|
|
from optparse import make_option
|
|
|
|
|
2012-05-28 21:16:38 +02:00
|
|
|
from django.core.management.base import BaseCommand
|
2012-03-14 14:07:06 +01:00
|
|
|
|
2012-06-22 11:31:15 +02:00
|
|
|
from djeuscan.processing import set_verbosity_level
|
2012-07-02 18:16:59 +02:00
|
|
|
from djeuscan.processing.scan import scan_metadata
|
2012-05-28 21:16:38 +02:00
|
|
|
|
2012-06-22 11:31:15 +02:00
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
2012-05-28 21:16:38 +02:00
|
|
|
|
|
|
|
class Command(BaseCommand):
|
|
|
|
_overlays = {}
|
|
|
|
|
|
|
|
option_list = BaseCommand.option_list + (
|
|
|
|
make_option('--all',
|
|
|
|
action='store_true',
|
|
|
|
dest='all',
|
|
|
|
default=False,
|
|
|
|
help='Scan all packages'),
|
2012-07-02 11:19:49 +02:00
|
|
|
make_option('--category',
|
|
|
|
action='store',
|
|
|
|
dest='category',
|
|
|
|
default=None,
|
|
|
|
help='Scan only this category'),
|
2012-07-20 13:25:03 +02:00
|
|
|
make_option('--populate',
|
|
|
|
action='store',
|
|
|
|
dest='populate',
|
|
|
|
default=None,
|
|
|
|
help='Populate herds and maintainers from herds.xml'),
|
2012-05-28 21:16:38 +02:00
|
|
|
)
|
|
|
|
args = '<package package ...>'
|
|
|
|
help = 'Scans metadata and fills database'
|
|
|
|
|
|
|
|
def handle(self, *args, **options):
|
2012-06-22 11:31:15 +02:00
|
|
|
set_verbosity_level(logger, options.get("verbosity", 1))
|
|
|
|
|
2012-07-02 11:19:49 +02:00
|
|
|
if options['all'] or options['category']:
|
2012-06-22 09:32:39 +02:00
|
|
|
packages = None
|
|
|
|
|
|
|
|
elif len(args):
|
|
|
|
packages = [pkg for pkg in args]
|
2012-05-28 21:16:38 +02:00
|
|
|
else:
|
2012-06-22 09:32:39 +02:00
|
|
|
packages = [pkg[:-1] for pkg in sys.stdin.readlines()]
|
|
|
|
|
2012-07-02 11:19:49 +02:00
|
|
|
scan_metadata(
|
|
|
|
packages=packages,
|
|
|
|
category=options['category'],
|
2012-07-20 13:25:03 +02:00
|
|
|
logger=logger,
|
|
|
|
populate=options['populate'],
|
2012-07-02 11:19:49 +02:00
|
|
|
)
|