MCPcopy Index your code
hub / github.com/aws/aws-cli / aws

Function aws

awscli/testutils.py:700–778  ·  view source on GitHub ↗

Run an aws command. This help function abstracts the differences of running the "aws" command on different platforms. If collect_memory is ``True`` the the Result object will have a list of memory usage taken at 2 second intervals. The memory usage will be in bytes. If en

(
    command,
    collect_memory=False,
    env_vars=None,
    wait_for_finish=True,
    input_data=None,
    input_file=None,
)

Source from the content-addressed store, hash-verified

698
699
700def aws(
701 command,
702 collect_memory=False,
703 env_vars=None,
704 wait_for_finish=True,
705 input_data=None,
706 input_file=None,
707):
708 """Run an aws command.
709
710 This help function abstracts the differences of running the "aws"
711 command on different platforms.
712
713 If collect_memory is ``True`` the the Result object will have a list
714 of memory usage taken at 2 second intervals. The memory usage
715 will be in bytes.
716
717 If env_vars is None, this will set the environment variables
718 to be used by the aws process.
719
720 If wait_for_finish is False, then the Process object is returned
721 to the caller. It is then the caller's responsibility to ensure
722 proper cleanup. This can be useful if you want to test timeout's
723 or how the CLI responds to various signals.
724
725 :type input_data: string
726 :param input_data: This string will be communicated to the process through
727 the stdin of the process. It essentially allows the user to
728 avoid having to use a file handle to pass information to the process.
729 Note that this string is not passed on creation of the process, but
730 rather communicated to the process.
731
732 :type input_file: a file handle
733 :param input_file: This is a file handle that will act as the
734 the stdin of the process immediately on creation. Essentially
735 any data written to the file will be read from stdin of the
736 process. This is needed if you plan to stream data into stdin while
737 collecting memory.
738 """
739 if platform.system() == 'Windows':
740 command = _escape_quotes(command)
741 if 'AWS_TEST_COMMAND' in os.environ:
742 aws_command = os.environ['AWS_TEST_COMMAND']
743 else:
744 aws_command = 'python %s' % get_aws_cmd()
745 full_command = '%s %s' % (aws_command, command)
746 stdout_encoding = get_stdout_encoding()
747 INTEG_LOG.debug("Running command: %s", full_command)
748 env = os.environ.copy()
749 if 'AWS_DEFAULT_REGION' not in env:
750 env['AWS_DEFAULT_REGION'] = "us-east-1"
751 if env_vars is not None:
752 env = env_vars
753 if input_file is None:
754 input_file = PIPE
755 process = Popen(
756 full_command,
757 stdout=PIPE,

Calls 8

_escape_quotesFunction · 0.85
get_aws_cmdFunction · 0.85
get_stdout_encodingFunction · 0.85
_wait_and_collect_memFunction · 0.85
ResultClass · 0.85
decodeMethod · 0.80
copyMethod · 0.45
communicateMethod · 0.45

Tested by

no test coverage detected