def METHOD_NAME(value, octal=False):
    """
    Escape a string to be used in a shell environment. Blank characters
    will be replaced with their hexadecimal (\x20) or octal (\040)
    representation.
    Example:
    - /srv/dev-disk-by-label-xx yy => /srv/dev-disk-by-label-xx\x20yy
    - /srv/dev-disk-by-label-xx yy => /srv/dev-disk-by-label-xx\040yy
    :param value: The value that will be escaped.
    :type value: str
    :param octal: If ``True``, convert to octal values, otherwise
        hexadecimal. Defaults to ``False``.
    :type octal: bool
    :return: The escaped string.
    :rtype: str
    """
    return value.replace(' ', '\\040' if octal else '\\x20')