Example #1
0
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)
Example #2
0
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)
Example #3
0
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)
Example #4
0
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)
Example #5
0
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)
Example #6
0
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)
Example #7
0
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)
Example #8
0
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)
Example #9
0
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)
Example #10
0
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)
Example #11
0
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)
Example #12
0
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)
Example #13
0
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)
Example #14
0
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)
Example #15
0
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)
Example #16
0
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)
Example #17
0
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)
Example #18
0
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)
Example #19
0
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)
Example #20
0
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)
Example #21
0
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))
Example #22
0
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))
Example #23
0
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)
Example #24
0
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)
Example #25
0
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)
Example #26
0
def test_adls_item(account_name, path):
    return cf_dls_filesystem(account_name).exists(path)
Example #27
0
def get_adls_item(account_name,
                  path):
    return cf_dls_filesystem(account_name).info(path)
Example #28
0
def list_adls_items(account_name,
                    path):
    return cf_dls_filesystem(account_name).ls(path, detail=True)
Example #29
0
def set_adls_item_owner(account_name,
                        path,
                        owner=None,
                        group=None):
    cf_dls_filesystem(account_name).chown(path, owner, group)
Example #30
0
def set_adls_item_permissions(cmd, account_name, path, permission):
    cf_dls_filesystem(cmd.cli_ctx, account_name).chmod(path, permission)
Example #31
0
def list_adls_items(account_name, path):
    return cf_dls_filesystem(account_name).ls(path, detail=True)
Example #32
0
def get_adls_item(account_name, path):
    return cf_dls_filesystem(account_name).info(path)
Example #33
0
def remove_adls_item(cmd, account_name, path, recurse=False):
    cf_dls_filesystem(cmd.cli_ctx, account_name).rm(path, recurse)
Example #34
0
def list_adls_items(cmd, account_name, path):
    return cf_dls_filesystem(cmd.cli_ctx, account_name).ls(path, detail=True)
Example #35
0
def list_adls_items(cmd, account_name, path):
    return cf_dls_filesystem(cmd.cli_ctx, account_name).ls(path, detail=True)
Example #36
0
def remove_adls_item(cmd, account_name, path, recurse=False):
    cf_dls_filesystem(cmd.cli_ctx, account_name).rm(path, recurse)
Example #37
0
def get_adls_item(cmd, account_name, path):
    return cf_dls_filesystem(cmd.cli_ctx, account_name).info(path)
Example #38
0
def set_adls_item_permissions(cmd, account_name, path, permission):
    cf_dls_filesystem(cmd.cli_ctx, account_name).chmod(path, permission)
Example #39
0
def test_adls_item(cmd, account_name, path):
    return cf_dls_filesystem(cmd.cli_ctx, account_name).exists(path)
Example #40
0
def remove_adls_item(account_name,
                     path,
                     recurse=False):
    cf_dls_filesystem(account_name).rm(path, recurse)
Example #41
0
def test_adls_item(cmd, account_name, path):
    return cf_dls_filesystem(cmd.cli_ctx, account_name).exists(path)
Example #42
0
def remove_adls_item(account_name, path, recurse=False):
    cf_dls_filesystem(account_name).rm(path, recurse)
Example #43
0
def get_adls_item(cmd, account_name, path):
    return cf_dls_filesystem(cmd.cli_ctx, account_name).info(path)
Example #44
0
def test_adls_item(account_name,
                   path):
    return cf_dls_filesystem(account_name).exists(path)
Example #45
0
def set_adls_item_permissions(account_name, path, permission):
    cf_dls_filesystem(account_name).chmod(path, permission)
Example #46
0
def get_adls_item_acl(cmd, account_name, path):
    client = cf_dls_filesystem(cmd.cli_ctx, account_name)
    return client.get_acl_status(path)
Example #47
0
def set_adls_item_acl(account_name,
                      path,
                      acl_spec):
    client = cf_dls_filesystem(account_name)
    client.set_acl(path, acl_spec)
Example #48
0
def get_adls_item_acl(account_name,
                      path):
    client = cf_dls_filesystem(account_name)
    return client.get_acl_status(path)
Example #49
0
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)
Example #50
0
def remove_adls_item_acl_entry(account_name,
                               path,
                               acl_spec):
    client = cf_dls_filesystem(account_name)
    client.remove_acl_entries(path, acl_spec)
Example #51
0
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)
Example #52
0
def set_adls_item_acl_entry(account_name,
                            path,
                            acl_spec):
    client = cf_dls_filesystem(account_name)
    client.modify_acl_entries(path, acl_spec)
Example #53
0
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)
Example #54
0
def set_adls_item_permissions(account_name,
                              path,
                              permission):
    cf_dls_filesystem(account_name).chmod(path, permission)
Example #55
0
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)