euscan-ng/euscanwww/djeuscan/management/commands/scan_upstream.py
volpino 9bfd728d4f euscanwww: Moved business logic to djeuscan.processing
Moved stuff from management commands to djeuscan.processing

Signed-off-by: volpino <fox91@anche.no>
2012-06-22 09:32:39 +02:00

47 lines
1.2 KiB
Python

import sys
from optparse import make_option
from django.core.management.base import BaseCommand
from djeuscan.processing.scan_upstream import scan_upstream
class Command(BaseCommand):
_overlays = {}
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'),
)
args = '<package package ...>'
help = 'Scans metadata and fills database'
def handle(self, *args, **options):
if options['all']:
packages = None
elif len(args):
packages = [pkg for pkg in args]
else:
packages = [pkg[:-1] for pkg in sys.stdin.readlines()]
scan_upstream(
packages=packages,
purge_versions=options["purge-versions"],
quiet=options["quiet"],
stdout=self.stdout,
)