2011-04-14 08:52:26 +02:00
|
|
|
import sys
|
|
|
|
from optparse import make_option
|
|
|
|
|
2012-04-28 18:16:05 +02:00
|
|
|
from django.core.management.base import BaseCommand
|
2012-05-28 21:16:38 +02:00
|
|
|
|
2012-06-22 09:32:39 +02:00
|
|
|
from djeuscan.processing.scan_upstream import scan_upstream
|
2011-04-14 08:52:26 +02:00
|
|
|
|
|
|
|
|
2012-05-28 21:16:38 +02:00
|
|
|
class Command(BaseCommand):
|
|
|
|
_overlays = {}
|
2011-04-14 08:52:26 +02:00
|
|
|
|
2012-05-28 21:16:38 +02:00
|
|
|
option_list = BaseCommand.option_list + (
|
|
|
|
make_option('--all',
|
|
|
|
action='store_true',
|
|
|
|
dest='all',
|
|
|
|
default=False,
|
|
|
|
help='Scan all packages'),
|
|
|
|
make_option('--purge-versions',
|
|
|
|
action='store_true',
|
|
|
|
dest='purge-versions',
|
|
|
|
default=False,
|
|
|
|
help='Purge old versions'),
|
|
|
|
make_option('--quiet',
|
|
|
|
action='store_true',
|
|
|
|
dest='quiet',
|
|
|
|
default=False,
|
|
|
|
help='Be quiet'),
|
2012-04-28 18:16:05 +02:00
|
|
|
)
|
2012-05-28 21:16:38 +02:00
|
|
|
args = '<package package ...>'
|
|
|
|
help = 'Scans metadata and fills database'
|
2011-04-14 08:52:26 +02:00
|
|
|
|
2012-05-28 21:16:38 +02:00
|
|
|
def handle(self, *args, **options):
|
|
|
|
if options['all']:
|
2012-06-22 09:32:39 +02:00
|
|
|
packages = None
|
2012-05-28 21:16:38 +02:00
|
|
|
|
2012-06-22 09:32:39 +02:00
|
|
|
elif len(args):
|
|
|
|
packages = [pkg for pkg in args]
|
|
|
|
else:
|
|
|
|
packages = [pkg[:-1] for pkg in sys.stdin.readlines()]
|
2012-05-28 21:16:38 +02:00
|
|
|
|
2012-06-22 09:32:39 +02:00
|
|
|
scan_upstream(
|
|
|
|
packages=packages,
|
|
|
|
purge_versions=options["purge-versions"],
|
|
|
|
quiet=options["quiet"],
|
|
|
|
stdout=self.stdout,
|
|
|
|
)
|