From 24a717d3cafbe356dcd06da8f58080b7f655728f Mon Sep 17 00:00:00 2001 From: Adam Nielsen Date: Mon, 4 Sep 2017 09:15:34 +1000 Subject: [PATCH] Resolve #519 by adding --hide-progress This hides transfer progress messages, but unlike --only-show-errors, the results of the transfer (list of filenames) is still displayed. This makes the output more suitable for logging. --- awscli/customizations/s3/results.py | 6 ++++++ awscli/customizations/s3/s3handler.py | 3 +++ awscli/customizations/s3/subcommands.py | 9 +++++++-- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/awscli/customizations/s3/results.py b/awscli/customizations/s3/results.py index b80fcf648295..c4f93fef5c77 100644 --- a/awscli/customizations/s3/results.py +++ b/awscli/customizations/s3/results.py @@ -563,6 +563,12 @@ def _print_success(self, result, **kwargs): pass +class HideProgressResultPrinter(ResultPrinter): + """A result printer that only lists files transferred upon completion""" + def _print_progress(self, **kwargs): + pass + + class ResultProcessor(threading.Thread): def __init__(self, result_queue, result_handlers=None): """Thread to process results from result queue diff --git a/awscli/customizations/s3/s3handler.py b/awscli/customizations/s3/s3handler.py index 89b1c657350e..47e24b8fdbd0 100644 --- a/awscli/customizations/s3/s3handler.py +++ b/awscli/customizations/s3/s3handler.py @@ -33,6 +33,7 @@ from awscli.customizations.s3.results import ResultRecorder from awscli.customizations.s3.results import ResultPrinter from awscli.customizations.s3.results import OnlyShowErrorsResultPrinter +from awscli.customizations.s3.results import HideProgressResultPrinter from awscli.customizations.s3.results import ResultProcessor from awscli.customizations.s3.results import CommandResultRecorder from awscli.customizations.s3.utils import RequestParamsMapper @@ -110,6 +111,8 @@ def _add_result_printer(self, result_recorder, result_processor_handlers): result_printer = OnlyShowErrorsResultPrinter(result_recorder) elif self._cli_params.get('is_stream'): result_printer = OnlyShowErrorsResultPrinter(result_recorder) + elif self._cli_params.get('hide_progress'): + result_printer = HideProgressResultPrinter(result_recorder) else: result_printer = ResultPrinter(result_recorder) result_processor_handlers.append(result_printer) diff --git a/awscli/customizations/s3/subcommands.py b/awscli/customizations/s3/subcommands.py index effcd4df533a..c9e6d4e7837e 100644 --- a/awscli/customizations/s3/subcommands.py +++ b/awscli/customizations/s3/subcommands.py @@ -368,6 +368,11 @@ 'Only errors and warnings are displayed. All other ' 'output is suppressed.')} +HIDE_PROGRESS = {'name': 'hide-progress', 'action': 'store_true', + 'help_text': ( + 'Suppress transfer progress messages, but still list ' + 'files transferred.')} + EXPECTED_SIZE = {'name': 'expected-size', 'help_text': ( @@ -424,7 +429,7 @@ SSE_C_COPY_SOURCE_KEY, STORAGE_CLASS, GRANTS, WEBSITE_REDIRECT, CONTENT_TYPE, CACHE_CONTROL, CONTENT_DISPOSITION, CONTENT_ENCODING, CONTENT_LANGUAGE, - EXPIRES, SOURCE_REGION, ONLY_SHOW_ERRORS, + EXPIRES, SOURCE_REGION, ONLY_SHOW_ERRORS, HIDE_PROGRESS, PAGE_SIZE, IGNORE_GLACIER_WARNINGS, FORCE_GLACIER_TRANSFER] @@ -735,7 +740,7 @@ class RmCommand(S3TransferCommand): USAGE = "" ARG_TABLE = [{'name': 'paths', 'nargs': 1, 'positional_arg': True, 'synopsis': USAGE}, DRYRUN, QUIET, RECURSIVE, INCLUDE, - EXCLUDE, ONLY_SHOW_ERRORS, PAGE_SIZE] + EXCLUDE, ONLY_SHOW_ERRORS, HIDE_PROGRESS, PAGE_SIZE] class SyncCommand(S3TransferCommand):