Exemplo n.º 1
0
    def __deploy(self, deployer, stack_name, template_str,
                 parameters, capabilities, execute_changeset, role_arn,
                 notification_arns, s3_uploader, tags, fail_on_empty_changeset=True):
        try:
            result = deployer.create_and_wait_for_changeset(
                stack_name=stack_name,
                cfn_template=template_str,
                parameter_values=parameters,
                capabilities=capabilities,
                role_arn=role_arn,
                notification_arns=notification_arns,
                s3_uploader=s3_uploader,
                tags=tags
            )
        except exceptions.ChangeEmptyError as ex:
            if fail_on_empty_changeset:
                raise
            write_exception(ex, outfile=get_stdout_text_writer())
            return 0

        if execute_changeset:
            deployer.execute_changeset(result.changeset_id, stack_name)
            deployer.wait_for_execute(stack_name, result.changeset_type)
            sys.stdout.write(self._MSG_EXECUTE_SUCCESS.format(stack_name=stack_name))
        else:
            sys.stdout.write(self.MSG_NO_EXECUTE_SUCCESS.format(changeset_id=result.changeset_id))

        sys.stdout.flush()
        return 0
Exemplo n.º 2
0
    def deploy(self, deployer, stack_name, template_str,
               parameters, capabilities, execute_changeset, role_arn,
               notification_arns, s3_uploader, tags,
               fail_on_empty_changeset=True):
        try:
            result = deployer.create_and_wait_for_changeset(
                stack_name=stack_name,
                cfn_template=template_str,
                parameter_values=parameters,
                capabilities=capabilities,
                role_arn=role_arn,
                notification_arns=notification_arns,
                s3_uploader=s3_uploader,
                tags=tags
            )
        except exceptions.ChangeEmptyError as ex:
            if fail_on_empty_changeset:
                raise
            write_exception(ex, outfile=get_stdout_text_writer())
            return 0

        if execute_changeset:
            deployer.execute_changeset(result.changeset_id, stack_name)
            deployer.wait_for_execute(stack_name, result.changeset_type)
            sys.stdout.write(self.MSG_EXECUTE_SUCCESS.format(
                    stack_name=stack_name))
        else:
            sys.stdout.write(self.MSG_NO_EXECUTE_CHANGESET.format(
                    changeset_id=result.changeset_id))

        sys.stdout.flush()
        return 0
Exemplo n.º 3
0
 def _get_default_stream(self):
     if getattr(sys.stdout, 'encoding', None) is None:
         # In python3, sys.stdout.encoding is always set.
         # In python2, if you redirect to stdout, then
         # encoding is not None.  In this case we'll default
         # to utf-8.
         return compat.get_stdout_text_writer()
     else:
         return sys.stdout
Exemplo n.º 4
0
 def _get_default_stream(self):
     if getattr(sys.stdout, 'encoding', None) is None:
         # In python3, sys.stdout.encoding is always set.
         # In python2, if you redirect to stdout, then
         # encoding is not None.  In this case we'll default
         # to utf-8.
         return compat.get_stdout_text_writer()
     else:
         return sys.stdout
Exemplo n.º 5
0
 def test_json_prints_unicode_chars(self):
     self.parsed_response['Users'][1]['UserId'] = u'\u2713'
     output = self.run_cmd('iam list-users', expected_rc=0)[0]
     with mock.patch('sys.stdout', six.StringIO()) as f:
         out = get_stdout_text_writer()
         out.write(u'\u2713')
         expected = f.getvalue()
     # We should not see the '\u<hex>' for of the unicode character.
     # It should be encoded into the default encoding.
     self.assertNotIn('\\u2713', output)
     self.assertIn(expected, output)
Exemplo n.º 6
0
 def test_json_prints_unicode_chars(self):
     self.parsed_response['Users'][1]['UserId'] = u'\u2713'
     output = self.run_cmd('iam list-users', expected_rc=0)[0]
     with mock.patch('sys.stdout', six.StringIO()) as f:
         out = get_stdout_text_writer()
         out.write(u'\u2713')
         expected = f.getvalue()
     # We should not see the '\u<hex>' for of the unicode character.
     # It should be encoded into the default encoding.
     self.assertNotIn('\\u2713', output)
     self.assertIn(expected, output)
Exemplo n.º 7
0
 def _get_default_stream(self):
     return compat.get_stdout_text_writer()
Exemplo n.º 8
0
 def _get_default_stream(self):
     return compat.get_stdout_text_writer()
Exemplo n.º 9
0
 def _output_log_events(self, parsed_args, parsed_globals, log_events):
     output = get_stdout_text_writer()
     logs_formatter = self._FORMAT_TO_FORMATTER_CLS[parsed_args.format](
         output, colorize=self._should_use_color(parsed_globals))
     for event in log_events:
         logs_formatter.display_log_event(event)
Exemplo n.º 10
0
 def get_stdout_stream(self):
     yield get_stdout_text_writer()