def remove_adls_item_expiry(cmd, account_name, path): client = cf_dls_filesystem(cmd.cli_ctx, account_name) if client.info(path)['type'] != 'FILE': # pylint: disable=line-too-long raise CLIError('The specified path does not exist or is not a file. Please ensure the path points to a file and it exists. Path supplied: {}'.format(path)) client.set_expiry(path, ExpiryOptionType.never_expire.value)
def create_adls_item(account_name, path, content=None, folder=False, force=False): client = cf_dls_filesystem(account_name) if client.exists(path): if force: # only recurse if the user wants this to be a folder # this prevents the user from unintentionally wiping out a folder # when trying to create a file. client.rm(path, recursive=folder) else: # pylint: disable=line-too-long raise CLIError('An item at path: \'{}\' already exists. To overwrite the existing item, specify --force'.format(path)) if folder: return client.mkdir(path) if content: if isinstance(content, str): # turn content into bytes with UTF-8 encoding if it is just a string content = str.encode(content) with client.open(path, mode='wb') as f: return f.write(content) else: return client.touch(path)
def remove_adls_item_expiry(cmd, account_name, path): client = cf_dls_filesystem(cmd.cli_ctx, account_name) if client.info(path)['type'] != 'FILE': # pylint: disable=line-too-long raise CLIError('The specified path does not exist or is not a file. Please ensure the path points to a file and it exists. Path supplied: {}'.format(path)) client.set_expiry(path, ExpiryOptionType.never_expire.value)
def create_adls_item(cmd, account_name, path, content=None, folder=False, force=False): client = cf_dls_filesystem(cmd.cli_ctx, account_name) if client.exists(path): if force: # only recurse if the user wants this to be a folder # this prevents the user from unintentionally wiping out a folder # when trying to create a file. client.rm(path, recursive=folder) else: # pylint: disable=line-too-long raise CLIError( 'An item at path: \'{}\' already exists. To overwrite the existing item, specify --force' .format(path)) if folder: return client.mkdir(path) if content: if isinstance(content, str): # turn content into bytes with UTF-8 encoding if it is just a string content = str.encode(content) with client.open(path, mode='wb') as f: return f.write(content) else: return client.touch(path)
def preview_adls_item(cmd, account_name, path, length=None, offset=0, force=False): client = cf_dls_filesystem(cmd.cli_ctx, account_name) if length: try: length = long(length) except NameError: length = int(length) if offset: try: offset = long(offset) except NameError: offset = int(offset) if not length or length <= 0: length = client.info(path)['length'] - offset if length > 1 * 1024 * 1024 and not force: # pylint: disable=line-too-long raise CLIError( 'The remaining data to preview is greater than {} bytes. Please specify a length or use the --force parameter to preview the entire file. The length of the file that would have been previewed: {}' .format(str(1 * 1024 * 1024), str(length))) return client.read_block(path, offset, length)
def preview_adls_item(account_name, path, length=None, offset=0, force=False): client = cf_dls_filesystem(account_name) if length: try: length = long(length) except NameError: length = int(length) if offset: try: offset = long(offset) except NameError: offset = int(offset) if not length or length <= 0: length = client.info(path)['length'] - offset if length > 1 * 1024 * 1024 and not force: # pylint: disable=line-too-long raise CLIError('The remaining data to preview is greater than {} bytes. Please specify a length or use the --force parameter to preview the entire file. The length of the file that would have been previewed: {}'.format(str(1 * 1024 * 1024), str(length))) return client.read_block(path, offset, length)
def upload_to_adls(account_name, source_path, destination_path, thread_count=None, overwrite=False): client = cf_dls_filesystem(account_name) ADLUploader(client, destination_path, source_path, thread_count, overwrite=overwrite)
def remove_adls_item_acl(account_name, path, default_acl=False): client = cf_dls_filesystem(account_name) if default_acl: client.remove_default_acl(path) else: client.remove_acl(path)
def move_adls_item(account_name, source_path, destination_path, force=False): client = cf_dls_filesystem(account_name) if force and client.exists(destination_path): client.rm(destination_path) client.mv(source_path, destination_path)
def move_adls_item(account_name, source_path, destination_path, force=False): client = cf_dls_filesystem(account_name) if force and client.exists(destination_path): client.rm(destination_path) client.mv(source_path, destination_path)
def remove_adls_item_acl(account_name, path, default_acl=False): client = cf_dls_filesystem(account_name) if default_acl: client.remove_default_acl(path) else: client.remove_acl(path)
def join_adls_items(account_name, source_paths, destination_path, force=False): client = cf_dls_filesystem(account_name) if force and client.exists(destination_path): client.rm(destination_path) client.concat(destination_path, source_paths)
def join_adls_items(account_name, source_paths, destination_path, force=False): client = cf_dls_filesystem(account_name) if force and client.exists(destination_path): client.rm(destination_path) client.concat(destination_path, source_paths)
def append_adls_item(cmd, account_name, path, content): client = cf_dls_filesystem(cmd.cli_ctx, account_name) if not client.exists(path): # pylint: disable=line-too-long raise CLIError('File at path: \'{}\' does not exist. Create the file before attempting to append to it.'.format(path)) with client.open(path, mode='ab') as f: if isinstance(content, str): content = str.encode(content) f.write(content)
def append_adls_item(cmd, account_name, path, content): client = cf_dls_filesystem(cmd.cli_ctx, account_name) if not client.exists(path): # pylint: disable=line-too-long raise CLIError('File at path: \'{}\' does not exist. Create the file before attempting to append to it.'.format(path)) with client.open(path, mode='ab') as f: if isinstance(content, str): content = str.encode(content) f.write(content)
def download_from_adls(account_name, source_path, destination_path, thread_count=None, overwrite=False): client = cf_dls_filesystem(account_name) ADLDownloader(client, source_path, destination_path, thread_count, overwrite=overwrite)
def upload_to_adls(account_name, source_path, destination_path, thread_count=None, overwrite=False): client = cf_dls_filesystem(account_name) ADLUploader(client, destination_path, source_path, thread_count, overwrite=overwrite)
def set_adls_item_expiry(cmd, account_name, path, expiration_time): client = cf_dls_filesystem(cmd.cli_ctx, account_name) if client.info(path)['type'] != 'FILE': # pylint: disable=line-too-long raise CLIError('The specified path does not exist or is not a file. Please ensure the path points to a file and it exists. Path supplied: {}'.format(path)) expiration_time = float(expiration_time) try: expiration_time = long(expiration_time) except NameError: expiration_time = int(expiration_time) client.set_expiry(path, ExpiryOptionType.absolute.value, expiration_time)
def set_adls_item_expiry(cmd, account_name, path, expiration_time): client = cf_dls_filesystem(cmd.cli_ctx, account_name) if client.info(path)['type'] != 'FILE': # pylint: disable=line-too-long raise CLIError('The specified path does not exist or is not a file. Please ensure the path points to a file and it exists. Path supplied: {}'.format(path)) expiration_time = float(expiration_time) try: expiration_time = long(expiration_time) except NameError: expiration_time = int(expiration_time) client.set_expiry(path, ExpiryOptionType.absolute.value, expiration_time)
def download_from_adls(account_name, source_path, destination_path, thread_count=None, overwrite=False): client = cf_dls_filesystem(account_name) ADLDownloader( client, source_path, destination_path, thread_count, overwrite=overwrite)
def download_from_adls(cmd, account_name, source_path, destination_path, chunk_size, buffer_size, block_size, thread_count=None, overwrite=False, progress_callback=None): client = cf_dls_filesystem(cmd.cli_ctx, account_name) ADLDownloader( client, source_path, destination_path, thread_count, chunksize=chunk_size, buffersize=buffer_size, blocksize=block_size, overwrite=overwrite, progress_callback=progress_callback or get_update_progress(cmd.cli_ctx))
def download_from_adls(cmd, account_name, source_path, destination_path, chunk_size, buffer_size, block_size, thread_count=None, overwrite=False, progress_callback=None): client = cf_dls_filesystem(cmd.cli_ctx, account_name) ADLDownloader( client, source_path, destination_path, thread_count, chunksize=chunk_size, buffersize=buffer_size, blocksize=block_size, overwrite=overwrite, progress_callback=progress_callback or get_update_progress(cmd.cli_ctx))
def download_from_adls(account_name, source_path, destination_path, chunk_size, buffer_size, block_size, thread_count=None, overwrite=False): client = cf_dls_filesystem(account_name) ADLDownloader( client, source_path, destination_path, thread_count, chunksize=chunk_size, buffersize=buffer_size, blocksize=block_size, overwrite=overwrite)
def upload_to_adls(account_name, source_path, destination_path, chunk_size, buffer_size, block_size, thread_count=None, overwrite=False, progress_callback=_update_progress): client = cf_dls_filesystem(account_name) ADLUploader(client, destination_path, source_path, thread_count, chunksize=chunk_size, buffersize=buffer_size, blocksize=block_size, overwrite=overwrite, progress_callback=progress_callback)
def upload_to_adls(account_name, source_path, destination_path, chunk_size, buffer_size, block_size, thread_count=None, overwrite=False, progress_callback=_update_progress): client = cf_dls_filesystem(account_name) ADLUploader( client, destination_path, source_path, thread_count, chunksize=chunk_size, buffersize=buffer_size, blocksize=block_size, overwrite=overwrite, progress_callback=progress_callback)
def test_adls_item(account_name, path): return cf_dls_filesystem(account_name).exists(path)
def get_adls_item(account_name, path): return cf_dls_filesystem(account_name).info(path)
def list_adls_items(account_name, path): return cf_dls_filesystem(account_name).ls(path, detail=True)
def set_adls_item_owner(account_name, path, owner=None, group=None): cf_dls_filesystem(account_name).chown(path, owner, group)
def set_adls_item_permissions(cmd, account_name, path, permission): cf_dls_filesystem(cmd.cli_ctx, account_name).chmod(path, permission)
def list_adls_items(account_name, path): return cf_dls_filesystem(account_name).ls(path, detail=True)
def get_adls_item(account_name, path): return cf_dls_filesystem(account_name).info(path)
def remove_adls_item(cmd, account_name, path, recurse=False): cf_dls_filesystem(cmd.cli_ctx, account_name).rm(path, recurse)
def list_adls_items(cmd, account_name, path): return cf_dls_filesystem(cmd.cli_ctx, account_name).ls(path, detail=True)
def list_adls_items(cmd, account_name, path): return cf_dls_filesystem(cmd.cli_ctx, account_name).ls(path, detail=True)
def remove_adls_item(cmd, account_name, path, recurse=False): cf_dls_filesystem(cmd.cli_ctx, account_name).rm(path, recurse)
def get_adls_item(cmd, account_name, path): return cf_dls_filesystem(cmd.cli_ctx, account_name).info(path)
def set_adls_item_permissions(cmd, account_name, path, permission): cf_dls_filesystem(cmd.cli_ctx, account_name).chmod(path, permission)
def test_adls_item(cmd, account_name, path): return cf_dls_filesystem(cmd.cli_ctx, account_name).exists(path)
def remove_adls_item(account_name, path, recurse=False): cf_dls_filesystem(account_name).rm(path, recurse)
def test_adls_item(cmd, account_name, path): return cf_dls_filesystem(cmd.cli_ctx, account_name).exists(path)
def remove_adls_item(account_name, path, recurse=False): cf_dls_filesystem(account_name).rm(path, recurse)
def get_adls_item(cmd, account_name, path): return cf_dls_filesystem(cmd.cli_ctx, account_name).info(path)
def test_adls_item(account_name, path): return cf_dls_filesystem(account_name).exists(path)
def set_adls_item_permissions(account_name, path, permission): cf_dls_filesystem(account_name).chmod(path, permission)
def get_adls_item_acl(cmd, account_name, path): client = cf_dls_filesystem(cmd.cli_ctx, account_name) return client.get_acl_status(path)
def set_adls_item_acl(account_name, path, acl_spec): client = cf_dls_filesystem(account_name) client.set_acl(path, acl_spec)
def get_adls_item_acl(account_name, path): client = cf_dls_filesystem(account_name) return client.get_acl_status(path)
def remove_adls_item_acl_entry(cmd, account_name, path, acl_spec): client = cf_dls_filesystem(cmd.cli_ctx, account_name) client.remove_acl_entries(path, acl_spec)
def remove_adls_item_acl_entry(account_name, path, acl_spec): client = cf_dls_filesystem(account_name) client.remove_acl_entries(path, acl_spec)
def set_adls_item_acl(cmd, account_name, path, acl_spec): client = cf_dls_filesystem(cmd.cli_ctx, account_name) client.set_acl(path, acl_spec)
def set_adls_item_acl_entry(account_name, path, acl_spec): client = cf_dls_filesystem(account_name) client.modify_acl_entries(path, acl_spec)
def set_adls_item_acl_entry(cmd, account_name, path, acl_spec): client = cf_dls_filesystem(cmd.cli_ctx, account_name) client.modify_acl_entries(path, acl_spec)
def set_adls_item_permissions(account_name, path, permission): cf_dls_filesystem(account_name).chmod(path, permission)
def set_adls_item_owner(cmd, account_name, path, owner=None, group=None): cf_dls_filesystem(cmd.cli_ctx, account_name).chown(path, owner, group)