コード例 #1
0
 def test_indent_and_truncate(self):
     self.assertIsNone(format_utils.indent_and_truncate(None))
     self.assertIsNone(format_utils.indent_and_truncate(None,
                                                        truncate=True))
     self.assertEqual(
         '',
         format_utils.indent_and_truncate(''))
     self.assertEqual(
         'one',
         format_utils.indent_and_truncate('one'))
     self.assertIsNone(format_utils.indent_and_truncate(None, spaces=2))
     self.assertEqual(
         '',
         format_utils.indent_and_truncate('', spaces=2))
     self.assertEqual(
         '  one',
         format_utils.indent_and_truncate('one', spaces=2))
     self.assertEqual(
         'one\ntwo\nthree\nfour\nfive',
         format_utils.indent_and_truncate('one\ntwo\nthree\nfour\nfive'))
     self.assertEqual(
         'three\nfour\nfive',
         format_utils.indent_and_truncate(
             'one\ntwo\nthree\nfour\nfive',
             truncate=True,
             truncate_limit=3))
     self.assertEqual(
         '  and so on\n  three\n  four\n  five\n  truncated',
         format_utils.indent_and_truncate(
             'one\ntwo\nthree\nfour\nfive',
             spaces=2,
             truncate=True,
             truncate_limit=3,
             truncate_prefix='and so on',
             truncate_postfix='truncated'))
コード例 #2
0
 def test_indent_and_truncate(self):
     self.assertIsNone(format_utils.indent_and_truncate(None))
     self.assertIsNone(format_utils.indent_and_truncate(None,
                                                        truncate=True))
     self.assertEqual(
         '',
         format_utils.indent_and_truncate(''))
     self.assertEqual(
         'one',
         format_utils.indent_and_truncate('one'))
     self.assertIsNone(format_utils.indent_and_truncate(None, spaces=2))
     self.assertEqual(
         '',
         format_utils.indent_and_truncate('', spaces=2))
     self.assertEqual(
         '  one',
         format_utils.indent_and_truncate('one', spaces=2))
     self.assertEqual(
         'one\ntwo\nthree\nfour\nfive',
         format_utils.indent_and_truncate('one\ntwo\nthree\nfour\nfive'))
     self.assertEqual(
         'three\nfour\nfive',
         format_utils.indent_and_truncate(
             'one\ntwo\nthree\nfour\nfive',
             truncate=True,
             truncate_limit=3))
     self.assertEqual(
         '  and so on\n  three\n  four\n  five\n  truncated',
         format_utils.indent_and_truncate(
             'one\ntwo\nthree\nfour\nfive',
             spaces=2,
             truncate=True,
             truncate_limit=3,
             truncate_prefix='and so on',
             truncate_postfix='truncated'))
コード例 #3
0
    def _print_failures(self, failures, deployment_failures, long=False):
        """Print failed resources.

        If the resource is a deployment resource, look up the deployment and
        print deploy_stdout and deploy_stderr.
        """
        out = self.app.stdout

        if not failures:
            return
        for k, f in failures.items():
            out.write('%s:\n' % k)
            out.write('  resource_type: %s\n' % f.resource_type)
            out.write('  physical_resource_id: %s\n' %
                      f.physical_resource_id)
            out.write('  status: %s\n' % f.resource_status)
            reason = format_utils.indent_and_truncate(
                f.resource_status_reason,
                spaces=4,
                truncate=not long,
                truncate_prefix='...\n')
            out.write('  status_reason: |\n%s\n' % reason)
            df = deployment_failures.get(f.physical_resource_id)
            if df:
                for output in ('deploy_stdout', 'deploy_stderr'):
                    format_utils.print_software_deployment_output(
                        data=df.output_values, name=output, long=long, out=out)
コード例 #4
0
ファイル: stack_failures.py プロジェクト: numvc/LuxoftBot
    def _print_failures(self, failures, deployment_failures, long=False):
        """Print failed resources.

        If the resource is a deployment resource, look up the deployment and
        print deploy_stdout and deploy_stderr.
        """
        out = self.app.stdout

        if not failures:
            return
        for k, f in failures.items():
            out.write('%s:\n' % k)
            out.write('  resource_type: %s\n' % f.resource_type)
            out.write('  physical_resource_id: %s\n' % f.physical_resource_id)
            out.write('  status: %s\n' % f.resource_status)
            reason = format_utils.indent_and_truncate(f.resource_status_reason,
                                                      spaces=4,
                                                      truncate=not long,
                                                      truncate_prefix='...\n')
            out.write('  status_reason: |\n%s\n' % reason)
            df = deployment_failures.get(f.physical_resource_id)
            if df:
                for output in ('deploy_stdout', 'deploy_stderr'):
                    format_utils.print_software_deployment_output(
                        data=df.output_values, name=output, long=long, out=out)