Skip to content
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

Fix deprecations in management commands #4321

Merged
Merged
Show file tree
Hide file tree
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
26 changes: 15 additions & 11 deletions readthedocs/core/management/commands/clean_builds.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,21 @@ class Command(BaseCommand):

help = __doc__

option_list = BaseCommand.option_list + (
make_option('--days',
dest='days',
type='int',
default=365,
help='Find builds older than DAYS days, default: 365'),
make_option('--dryrun',
action='store_true',
dest='dryrun',
help='Perform dry run on build cleanup'),
)
def add_arguments(self, parser):
parser.add_argument(
'--days',
dest='days',
type='int',
default=365,
help='Find builds older than DAYS days, default: 365'
)

parser.add_argument(
'--dryrun',
action='store_true',
dest='dryrun',
help='Perform dry run on build cleanup'
)

def handle(self, *args, **options):
"""Find stale builds and remove build paths"""
Expand Down
14 changes: 8 additions & 6 deletions readthedocs/core/management/commands/reindex_elasticsearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@
class Command(BaseCommand):

help = __doc__
option_list = BaseCommand.option_list + (
make_option('-p',
dest='project',
default='',
help='Project to index'),
)

def add_arguments(self, parser):
parser.add_argument(
'-p',
dest='project',
default='',
help='Project to index'
)

def handle(self, *args, **options):
"""Build/index all versions or a single project's version"""
Expand Down
40 changes: 24 additions & 16 deletions readthedocs/core/management/commands/update_repos.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,30 @@ class Command(BaseCommand):
"""Management command for rebuilding documentation on projects"""

help = __doc__
option_list = BaseCommand.option_list + (
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that we lose the positional arguments:

manage.py update_repos mkdocs

doesn't work anymore.

This command is used when import_from_live is called.

From the example at https://docs.djangoproject.com/en/1.9/howto/custom-management-commands/#custom-commands-options we need some extra lines to allow that.

I had to add this to make it work.

        parser.add_argument('slugs', nargs='+', type=str)

Probably similar work is needed in the rest of the commands.

cc @stsewd

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll see if I can fix this today

make_option('-r',
action='store_true',
dest='record',
default=False,
help='Make a Build'),
make_option('-f',
action='store_true',
dest='force',
default=False,
help='Force a build in sphinx'),
make_option('-V',
dest='version',
default=None,
help='Build a version, or all versions')
)

def add_arguments(self, parser):
parser.add_argument(
'-r',
action='store_true',
dest='record',
default=False,
help='Make a Build'
)

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

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

def handle(self, *args, **options):
record = options['record']
Expand Down