Skip to content

Commit

Permalink
Merge pull request #4373 from rtfd/humitos/command/update_repos
Browse files Browse the repository at this point in the history
Check for 'options' in update_repos command
  • Loading branch information
humitos authored Jul 23, 2018
2 parents 45a5944 + 1fd676e commit 8a34164
Showing 1 changed file with 33 additions and 25 deletions.
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,
)

0 comments on commit 8a34164

Please sign in to comment.