Bug 1312809 - Switch ingest_push command to add_arguments

.args and .option_list are deprecated as of Django 1.8. We're
currently using Django 1.10. So switch to the modern API.

As part of the change, "args" is no longer used: everything
is in "options." So, we can remove some error handling code
because argparse takes care of it for us.
This commit is contained in:
Gregory Szorc 2016-10-24 17:09:53 -07:00 коммит произвёл Gregory Szorc
Родитель 248e172321
Коммит d2d5404100
1 изменённых файлов: 11 добавлений и 19 удалений

Просмотреть файл

@ -1,5 +1,4 @@
from cProfile import Profile
from optparse import make_option
from django.conf import settings
from django.core.management.base import (BaseCommand,
@ -17,28 +16,21 @@ class Command(BaseCommand):
"""Management command to ingest data from a single push."""
help = "Ingests a single push into treeherder"
args = '<project> <changeset>'
option_list = BaseCommand.option_list + (
make_option('--profile-file',
action='store',
dest='profile_file',
default=None,
help='Profile command and write result to profile file'),
def add_arguments(self, parser):
parser.add_argument('--profile-file',
help='Profile command and write result to profile '
'file')
parser.add_argument('--filter-job-group',
help="Only process jobs in specified group symbol "
"(e.g. 'T')")
make_option('--filter-job-group',
action='store',
dest='filter_job_group',
default=None,
help="Only process jobs in specified group symbol "
"(e.g. 'T')")
)
parser.add_argument('project', help='repository to query')
parser.add_argument('changeset', help='changeset to import')
def _handle(self, *args, **options):
if len(args) != 2:
raise CommandError("Need to specify (only) branch and changeset")
(project, changeset) = args
project = options['project']
changeset = options['changeset']
# get reference to repo
repo = Repository.objects.get(name=project, active_status='active')