Exemple #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)
Exemple #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)
Exemple #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)
Exemple #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)
Exemple #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)
Exemple #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)
Exemple #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)
Exemple #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)
Exemple #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)
Exemple #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)
Exemple #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)
Exemple #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)
Exemple #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)
Exemple #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)
Exemple #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)
Exemple #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)
Exemple #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)
Exemple #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)
Exemple #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)
Exemple #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)
Exemple #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))
Exemple #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))
Exemple #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)
Exemple #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)
Exemple #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)
Exemple #26
0
def test_adls_item(account_name, path):
    return cf_dls_filesystem(account_name).exists(path)
Exemple #27
0
def get_adls_item(account_name,
                  path):
    return cf_dls_filesystem(account_name).info(path)
Exemple #28
0
def list_adls_items(account_name,
                    path):
    return cf_dls_filesystem(account_name).ls(path, detail=True)
Exemple #29
0
def set_adls_item_owner(account_name,
                        path,
                        owner=None,
                        group=None):
    cf_dls_filesystem(account_name).chown(path, owner, group)
Exemple #30
0
def set_adls_item_permissions(cmd, account_name, path, permission):
    cf_dls_filesystem(cmd.cli_ctx, account_name).chmod(path, permission)
Exemple #31
0
def list_adls_items(account_name, path):
    return cf_dls_filesystem(account_name).ls(path, detail=True)
Exemple #32
0
def get_adls_item(account_name, path):
    return cf_dls_filesystem(account_name).info(path)
Exemple #33
0
def remove_adls_item(cmd, account_name, path, recurse=False):
    cf_dls_filesystem(cmd.cli_ctx, account_name).rm(path, recurse)
Exemple #34
0
def list_adls_items(cmd, account_name, path):
    return cf_dls_filesystem(cmd.cli_ctx, account_name).ls(path, detail=True)
Exemple #35
0
def list_adls_items(cmd, account_name, path):
    return cf_dls_filesystem(cmd.cli_ctx, account_name).ls(path, detail=True)
Exemple #36
0
def remove_adls_item(cmd, account_name, path, recurse=False):
    cf_dls_filesystem(cmd.cli_ctx, account_name).rm(path, recurse)
Exemple #37
0
def get_adls_item(cmd, account_name, path):
    return cf_dls_filesystem(cmd.cli_ctx, account_name).info(path)
Exemple #38
0
def set_adls_item_permissions(cmd, account_name, path, permission):
    cf_dls_filesystem(cmd.cli_ctx, account_name).chmod(path, permission)
Exemple #39
0
def test_adls_item(cmd, account_name, path):
    return cf_dls_filesystem(cmd.cli_ctx, account_name).exists(path)
Exemple #40
0
def remove_adls_item(account_name,
                     path,
                     recurse=False):
    cf_dls_filesystem(account_name).rm(path, recurse)
Exemple #41
0
def test_adls_item(cmd, account_name, path):
    return cf_dls_filesystem(cmd.cli_ctx, account_name).exists(path)
Exemple #42
0
def remove_adls_item(account_name, path, recurse=False):
    cf_dls_filesystem(account_name).rm(path, recurse)
Exemple #43
0
def get_adls_item(cmd, account_name, path):
    return cf_dls_filesystem(cmd.cli_ctx, account_name).info(path)
Exemple #44
0
def test_adls_item(account_name,
                   path):
    return cf_dls_filesystem(account_name).exists(path)
Exemple #45
0
def set_adls_item_permissions(account_name, path, permission):
    cf_dls_filesystem(account_name).chmod(path, permission)
Exemple #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)
Exemple #47
0
def set_adls_item_acl(account_name,
                      path,
                      acl_spec):
    client = cf_dls_filesystem(account_name)
    client.set_acl(path, acl_spec)
Exemple #48
0
def get_adls_item_acl(account_name,
                      path):
    client = cf_dls_filesystem(account_name)
    return client.get_acl_status(path)
Exemple #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)
Exemple #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)
Exemple #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)
Exemple #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)
Exemple #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)
Exemple #54
0
def set_adls_item_permissions(account_name,
                              path,
                              permission):
    cf_dls_filesystem(account_name).chmod(path, permission)
Exemple #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)