def storage_file_delete_batch(cmd, client, source, pattern=None, dryrun=False, timeout=None): """ Delete files from file share in batch """ def delete_action(file_pair): delete_file_args = { 'share_name': source, 'directory_name': file_pair[0], 'file_name': file_pair[1], 'timeout': timeout } return client.delete_file(**delete_file_args) from azure.cli.command_modules.storage.util import glob_files_remotely source_files = list(glob_files_remotely(cmd, client, source, pattern)) if dryrun: logger = get_logger(__name__) logger.warning('delete files from %s', source) logger.warning(' pattern %s', pattern) logger.warning(' share %s', source) logger.warning(' total %d', len(source_files)) logger.warning(' operations') for f in source_files: logger.warning(' - %s/%s', f[0], f[1]) return [] for f in source_files: delete_action(f)
def storage_file_download_batch(cmd, client, source, destination, pattern=None, dryrun=False, validate_content=False, max_connections=1, progress_callback=None, snapshot=None): """ Download files from file share to local directory in batch """ from azure.cli.command_modules.storage.util import glob_files_remotely, mkdir_p source_files = glob_files_remotely(cmd, client, source, pattern, snapshot=snapshot) if dryrun: source_files_list = list(source_files) logger = get_logger(__name__) logger.warning('download files from file share') logger.warning(' account %s', client.account_name) logger.warning(' share %s', source) logger.warning('destination %s', destination) logger.warning(' pattern %s', pattern) logger.warning(' total %d', len(source_files_list)) logger.warning(' operations') for f in source_files_list: logger.warning(' - %s/%s => %s', f[0], f[1], os.path.join(destination, *f)) return [] def _download_action(pair): destination_dir = os.path.join(destination, pair[0]) mkdir_p(destination_dir) get_file_args = { 'share_name': source, 'directory_name': pair[0], 'file_name': pair[1], 'file_path': os.path.join(destination, *pair), 'max_connections': max_connections, 'progress_callback': progress_callback, 'snapshot': snapshot } if cmd.supported_api_version(min_api='2016-05-31'): get_file_args['validate_content'] = validate_content client.get_file_to_path(**get_file_args) return client.make_file_url(source, *pair) return list(_download_action(f) for f in source_files)
def storage_file_delete_batch(cmd, client, source, pattern=None, dryrun=False, timeout=None): """ Delete files from file share in batch """ def delete_action(file_pair): delete_file_args = {'share_name': source, 'directory_name': file_pair[0], 'file_name': file_pair[1], 'timeout': timeout} return client.delete_file(**delete_file_args) from azure.cli.command_modules.storage.util import glob_files_remotely source_files = list(glob_files_remotely(cmd, client, source, pattern)) if dryrun: logger = get_logger(__name__) logger.warning('delete files from %s', source) logger.warning(' pattern %s', pattern) logger.warning(' share %s', source) logger.warning(' total %d', len(source_files)) logger.warning(' operations') for f in source_files: logger.warning(' - %s/%s', f[0], f[1]) return [] for f in source_files: delete_action(f)
def storage_file_download_batch(cmd, client, source, destination, pattern=None, dryrun=False, validate_content=False, max_connections=1, progress_callback=None): """ Download files from file share to local directory in batch """ from azure.cli.command_modules.storage.util import glob_files_remotely, mkdir_p source_files = glob_files_remotely(cmd, client, source, pattern) if dryrun: source_files_list = list(source_files) logger = get_logger(__name__) logger.warning('download files from file share') logger.warning(' account %s', client.account_name) logger.warning(' share %s', source) logger.warning('destination %s', destination) logger.warning(' pattern %s', pattern) logger.warning(' total %d', len(source_files_list)) logger.warning(' operations') for f in source_files_list: logger.warning(' - %s/%s => %s', f[0], f[1], os.path.join(destination, *f)) return [] def _download_action(pair): destination_dir = os.path.join(destination, pair[0]) mkdir_p(destination_dir) get_file_args = {'share_name': source, 'directory_name': pair[0], 'file_name': pair[1], 'file_path': os.path.join(destination, *pair), 'max_connections': max_connections, 'progress_callback': progress_callback} if cmd.supported_api_version(min_api='2016-05-31'): get_file_args['validate_content'] = validate_content client.get_file_to_path(**get_file_args) return client.make_file_url(source, *pair) return list(_download_action(f) for f in source_files)