Skip to content

Check for 'options' in update_repos command #4373

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 23, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 33 additions & 25 deletions readthedocs/core/management/commands/update_repos.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
# -*- coding: utf-8 -*-

"""
Custom management command to rebuild documentation for all projects.

Invoked via ``./manage.py update_repos``.
"""

from __future__ import absolute_import
from __future__ import (
absolute_import, division, print_function, unicode_literals)

import logging
from optparse import make_option

from django.core.management.base import BaseCommand

Expand All @@ -17,13 +18,12 @@
from readthedocs.projects import tasks
from readthedocs.projects.models import Project


log = logging.getLogger(__name__)


class Command(BaseCommand):

"""Management command for rebuilding documentation on projects"""
"""Management command for rebuilding documentation on projects."""

help = __doc__

Expand All @@ -35,39 +35,45 @@ def add_arguments(self, parser):
action='store_true',
dest='record',
default=False,
help='Make a Build'
help='Make a Build',
)

parser.add_argument(
'-f',
action='store_true',
dest='force',
default=False,
help='Force a build in sphinx'
help='Force a build in sphinx',
)

parser.add_argument(
'-V',
dest='version',
default=None,
help='Build a version, or all versions'
help='Build a version, or all versions',
)

def handle(self, *args, **options):
record = options['record']
force = options['force']
version = options['version']
if args:

if options.get('slug', []):
for slug in options['slugs']:
if version and version != "all":
log.info("Updating version %s for %s", version, slug)
for version in Version.objects.filter(project__slug=slug, slug=version):
if version and version != 'all':
log.info('Updating version %s for %s', version, slug)
for version in Version.objects.filter(
project__slug=slug,
slug=version,
):
trigger_build(project=version.project, version=version)
elif version == "all":
log.info("Updating all versions for %s", slug)
for version in Version.objects.filter(project__slug=slug,
active=True,
uploaded=False):
elif version == 'all':
log.info('Updating all versions for %s', slug)
for version in Version.objects.filter(
project__slug=slug,
active=True,
uploaded=False,
):

build_pk = None
if record:
Expand All @@ -83,28 +89,30 @@ def handle(self, *args, **options):
pk=version.project_id,
build_pk=build_pk,
record=record,
version_pk=version.pk
version_pk=version.pk,
)
else:
p = Project.all_objects.get(slug=slug)
log.info("Building %s", p)
log.info('Building %s', p)
trigger_build(project=p, force=force, record=record)
else:
if version == "all":
log.info("Updating all versions")
for version in Version.objects.filter(active=True,
uploaded=False):
if version == 'all':
log.info('Updating all versions')
for version in Version.objects.filter(
active=True,
uploaded=False,
):
tasks.UpdateDocsTask().run(
pk=version.project_id,
record=record,
force=force,
version_pk=version.pk
version_pk=version.pk,
)
else:
log.info("Updating all docs")
log.info('Updating all docs')
for project in Project.objects.all():
tasks.UpdateDocsTask().run(
pk=project.pk,
record=record,
force=force
force=force,
)