How to use the awscli.compat.six.text_type function in awscli

To help you get started, we’ve selected a few awscli examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github aws / aws-cli / tests / unit / customizations / s3 / View on Github external
    This sets up the test by making a directory named some_directory.  It
    has the file text1.txt and the directory another_directory inside.  Inside
    of another_directory it creates the file text2.txt.
    if size:
        body = "*" * size
        body = 'This is a test.'

    filename1 = file_creator.create_file(
        os.path.join('some_directory', 'text1.txt'), body)

    filename2 = file_creator.create_file(
        os.path.join('some_directory', 'another_directory', 'text2.txt'), body)
    filename1 = six.text_type(filename1)
    filename2 = six.text_type(filename2)
    return [filename1, filename2, os.path.dirname(filename2),
github aws / aws-cli / awscli / View on Github external
:type input_file: a file handle
    :param input_file: This is a file handle that will act as the
        the stdin of the process immediately on creation.  Essentially
        any data written to the file will be read from stdin of the
        process. This is needed if you plan to stream data into stdin while
        collecting memory.
    if platform.system() == 'Windows':
        command = _escape_quotes(command)
    if 'AWS_TEST_COMMAND' in os.environ:
        aws_command = os.environ['AWS_TEST_COMMAND']
        aws_command = 'python %s' % get_aws_cmd()
    full_command = '%s %s' % (aws_command, command)
    stdout_encoding = get_stdout_encoding()
    if isinstance(full_command, six.text_type) and not six.PY3:
        full_command = full_command.encode(stdout_encoding)
    INTEG_LOG.debug("Running command: %s", full_command)
    env = os.environ.copy()
    if 'AWS_DEFAULT_REGION' not in env:
        env['AWS_DEFAULT_REGION'] = "us-east-1"
    if env_vars is not None:
        env = env_vars
    if input_file is None:
        input_file = PIPE
    process = Popen(full_command, stdout=PIPE, stderr=PIPE, stdin=input_file,
                    shell=True, env=env)
    if not wait_for_finish:
        return process
    memory = None
    if not collect_memory:
        kwargs = {}
github aws / aws-cli / tests / unit / customizations / s3 / View on Github external
def test_no_follow_symlink(self):
        abs_root = six.text_type(os.path.abspath(self.root) + os.sep)
        input_local_dir = {'src': {'path': abs_root,
                                   'type': 'local'},
                           'dest': {'path': self.bucket,
                                    'type': 's3'},
                           'dir_op': True, 'use_src_name': True}
        file_stats = FileGenerator(self.client, '', False).call(input_local_dir)
        result_list = []
        for file_stat in file_stats:
            result_list.append(getattr(file_stat, 'src'))
        self.assertEqual(len(result_list), len(self.filenames))
        # Just check to make sure the right local files are generated.
        for i in range(len(result_list)):
            filename = six.text_type(os.path.abspath(self.filenames[i]))
            self.assertEqual(result_list[i], filename)
github aws / aws-cli / awscli / View on Github external
# Given a dictionary, partition it into two list based on the
    # values associated with the keys.
    # {'foo': 'scalar', 'bar': 'scalar', 'baz': ['not, 'scalar']}
    # scalar = [('foo', 'scalar'), ('bar', 'scalar')]
    # non_scalar = [('baz', ['not', 'scalar'])]
    scalar = []
    non_scalar = []
    if scalar_keys is None:
        # scalar_keys can have more than just the keys in the item_dict,
        # but if user does not provide scalar_keys, we'll grab the keys
        # from the current item_dict
        for key, value in sorted(item_dict.items()):
            if isinstance(value, (dict, list)):
                non_scalar.append((key, value))
        for key in scalar_keys:
            scalar.append(six.text_type(item_dict.get(key, '')))
        remaining_keys = sorted(set(item_dict.keys()) - set(scalar_keys))
        for remaining_key in remaining_keys:
            non_scalar.append((remaining_key, item_dict[remaining_key]))
    return scalar, non_scalar
github aws / aws-cli / awscli / View on Github external
def _format_text(item, stream, identifier=None, scalar_keys=None):
    if isinstance(item, dict):
        _format_dict(scalar_keys, item, identifier, stream)
    elif isinstance(item, list):
        _format_list(item, identifier, stream)
        # If it's not a list or a dict, we just write the scalar
        # value out directly.
github aws / aws-cli / awscli / View on Github external
def get_text_length(text):
    # `len(unichar)` measures the number of characters, so we use
    # `unicodedata.east_asian_width` to measure the length of characters.
    # Following responses are considered to be full-width length.
    # * A(Ambiguous)
    # * F(Fullwidth)
    # * W(Wide)
    text = six.text_type(text)
    return sum(2 if unicodedata.east_asian_width(char) in 'WFA' else 1
               for char in text)
github aws / aws-cli / awscli / View on Github external
def _unpack_cli_arg(argument_model, value, cli_name):
    if is_json_value_header(argument_model):
        return _unpack_json_cli_arg(argument_model, value, cli_name)
    elif argument_model.type_name in SCALAR_TYPES:
        return unpack_scalar_cli_arg(
            argument_model, value, cli_name)
    elif argument_model.type_name in COMPLEX_TYPES:
        return _unpack_complex_cli_arg(
            argument_model, value, cli_name)
        return six.text_type(value)