Skip to content

Commit

Permalink
Fixed storage args, added "max-connections" arg to `blob download-bat…
Browse files Browse the repository at this point in the history
…ch` (#5384)

* fixed parameters to be type int, changes in tests

* history and style

* fixed metrics test for new service change as well
  • Loading branch information
williexu authored Jan 25, 2018
1 parent 00f4c90 commit 318bdd0
Show file tree
Hide file tree
Showing 11 changed files with 810 additions and 739 deletions.
2 changes: 2 additions & 0 deletions src/command_modules/azure-cli-storage/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ Release History
* Added progress reporting for all upload/download commands, including batch.
* `storage account check-name`: fixed bug preventing "-n" arg option.
* Added 'snapshot' column to table output for blob list/show.
* Fixed bugs with various parameters that needed to be parsed as ints, added test coverage.
* Small fix with test, `storage blob service-properties show`: "hourMetrics.enabled" defaults to false.

2.0.23
++++++
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,8 @@ def load_arguments(self, _): # pylint: disable=too-many-locals, too-many-statem
with self.argument_context('storage blob download') as c:
c.argument('file_path', options_list=('--file', '-f'), type=file_type, completer=FilesCompleter())
c.argument('max_connections', type=int)
c.argument('start_range', type=int)
c.argument('end_range', type=int)
c.argument('validate_content', action='store_true', min_api='2016-05-31')
c.extra('no_progress', progress_type)

Expand All @@ -269,6 +271,7 @@ def load_arguments(self, _): # pylint: disable=too-many-locals, too-many-statem
c.argument('destination', options_list=('--destination', '-d'))
c.argument('source', options_list=('--source', '-s'), validator=process_blob_download_batch_parameters)
c.extra('no_progress', progress_type)
c.argument('max_connections', type=int)

with self.argument_context('storage blob delete') as c:
from .sdkutil import get_delete_blob_snapshot_type_names
Expand Down Expand Up @@ -468,6 +471,9 @@ def load_arguments(self, _): # pylint: disable=too-many-locals, too-many-statem
validator=process_file_download_namespace, completer=FilesCompleter())
c.argument('path', validator=None) # validator called manually from process_file_download_namespace
c.extra('no_progress', progress_type)
c.argument('max_connections', type=int)
c.argument('start_range', type=int)
c.argument('end_range', type=int)

with self.argument_context('storage file exists') as c:
c.register_path_argument()
Expand Down Expand Up @@ -518,6 +524,7 @@ def load_arguments(self, _): # pylint: disable=too-many-locals, too-many-statem
c.register_content_settings_argument(t_file_content_settings, update=False, guess_from_file='local_file_path')
c.argument('local_file_path', options_list='--source', type=file_type, completer=FilesCompleter())
c.extra('no_progress', progress_type)
c.argument('max_connections', type=int)

with self.argument_context('storage file url') as c:
c.register_path_argument()
Expand All @@ -527,7 +534,7 @@ def load_arguments(self, _): # pylint: disable=too-many-locals, too-many-statem
from ._validators import process_file_upload_batch_parameters
c.argument('source', options_list=('--source', '-s'), validator=process_file_upload_batch_parameters)
c.argument('destination', options_list=('--destination', '-d'))
c.argument('max_connections', arg_group='Download Control')
c.argument('max_connections', arg_group='Download Control', type=int)
c.argument('validate_content', action='store_true', min_api='2016-05-31')
c.register_content_settings_argument(t_file_content_settings, update=False, arg_group='Content Settings')
c.extra('no_progress', progress_type)
Expand All @@ -536,7 +543,7 @@ def load_arguments(self, _): # pylint: disable=too-many-locals, too-many-statem
from ._validators import process_file_download_batch_parameters
c.argument('source', options_list=('--source', '-s'), validator=process_file_download_batch_parameters)
c.argument('destination', options_list=('--destination', '-d'))
c.argument('max_connections', arg_group='Download Control')
c.argument('max_connections', arg_group='Download Control', type=int)
c.argument('validate_content', action='store_true', min_api='2016-05-31')
c.extra('no_progress', progress_type)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def action_file_copy(file_info):

# pylint: disable=unused-argument
def storage_blob_download_batch(client, source, destination, source_container_name, pattern=None, dryrun=False,
progress_callback=None):
progress_callback=None, max_connections=2):
def _download_blob(blob_service, container, destination_folder, blob_name):
import os
# TODO: try catch IO exception
Expand All @@ -103,7 +103,7 @@ def _download_blob(blob_service, container, destination_folder, blob_name):
if not os.path.exists(destination_folder):
mkdir_p(destination_folder)

blob = blob_service.get_blob_to_path(container, blob_name, destination_path,
blob = blob_service.get_blob_to_path(container, blob_name, destination_path, max_connections=max_connections,
progress_callback=progress_callback)
return blob.name

Expand Down
Loading

0 comments on commit 318bdd0

Please sign in to comment.