From c6fd24d608dcce10f7a4b7a990f40037d08c6fa7 Mon Sep 17 00:00:00 2001 From: Santos Gallegos Date: Mon, 2 Jul 2018 18:02:07 -0500 Subject: [PATCH] Fix deprecations in management commands --- .../core/management/commands/clean_builds.py | 26 +++++++----- .../commands/reindex_elasticsearch.py | 14 ++++--- .../core/management/commands/update_repos.py | 40 +++++++++++-------- 3 files changed, 47 insertions(+), 33 deletions(-) diff --git a/readthedocs/core/management/commands/clean_builds.py b/readthedocs/core/management/commands/clean_builds.py index da365b1a157..93a3fada683 100644 --- a/readthedocs/core/management/commands/clean_builds.py +++ b/readthedocs/core/management/commands/clean_builds.py @@ -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""" diff --git a/readthedocs/core/management/commands/reindex_elasticsearch.py b/readthedocs/core/management/commands/reindex_elasticsearch.py index 452010cfbef..7a5f25a065a 100644 --- a/readthedocs/core/management/commands/reindex_elasticsearch.py +++ b/readthedocs/core/management/commands/reindex_elasticsearch.py @@ -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""" diff --git a/readthedocs/core/management/commands/update_repos.py b/readthedocs/core/management/commands/update_repos.py index e7ea34c8848..3a624b11680 100644 --- a/readthedocs/core/management/commands/update_repos.py +++ b/readthedocs/core/management/commands/update_repos.py @@ -26,22 +26,30 @@ class Command(BaseCommand): """Management command for rebuilding documentation on projects""" help = __doc__ - option_list = BaseCommand.option_list + ( - 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']