當前位置: 首頁>>代碼示例>>Python>>正文


Python constants.COLOR_ERROR屬性代碼示例

本文整理匯總了Python中ansible.constants.COLOR_ERROR屬性的典型用法代碼示例。如果您正苦於以下問題:Python constants.COLOR_ERROR屬性的具體用法?Python constants.COLOR_ERROR怎麽用?Python constants.COLOR_ERROR使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在ansible.constants的用法示例。


在下文中一共展示了constants.COLOR_ERROR屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: v2_runner_on_failed

# 需要導入模塊: from ansible import constants [as 別名]
# 或者: from ansible.constants import COLOR_ERROR [as 別名]
def v2_runner_on_failed(self, result, ignore_errors=False):
        duration = self._get_duration()
        host_string = self._host_string(result)

        if 'exception' in result._result:
            exception_message = "An exception occurred during task execution."
            if self._display.verbosity < 3:
                # extract just the actual error message from the exception text
                error = result._result['exception'].strip().split('\n')[-1]
                msg = exception_message + \
                    "To see the full traceback, use -vvv. The error was: %s" % error
            else:
                msg = exception_message + \
                    "The full traceback is:\n" + \
                    result._result['exception'].replace('\n', '')

                self._emit_line(msg, color=C.COLOR_ERROR)

        self._emit_line("%s | FAILED | %s" %
                        (host_string,
                         duration), color=C.COLOR_ERROR)
        self._emit_line(deep_serialize(result._result), color=C.COLOR_ERROR) 
開發者ID:octplane,項目名稱:ansible_stdout_compact_logger,代碼行數:24,代碼來源:anstomlog.py

示例2: v2_runner_item_on_failed

# 需要導入模塊: from ansible import constants [as 別名]
# 或者: from ansible.constants import COLOR_ERROR [as 別名]
def v2_runner_item_on_failed(self, result):
        delegated_vars = result._result.get('_ansible_delegated_vars', None)
        if 'exception' in result._result:
            if self._display.verbosity < 3:
                # extract just the actual error message from the exception text
                error = result._result['exception'].strip().split('\n')[-1]
                msg = ("An exception occurred during task execution. To see the full traceback,"
                       " use -vvv. The error was: %s" % error)
            else:
                msg = ("An exception occurred during task execution."
                       " The full traceback is:\n" + result._result['exception'])

            self._display.display(msg, color="red")

        msg = "failed: "
        if delegated_vars:
            msg += "[%s -> %s]" % (result._host.get_name(), delegated_vars['ansible_host'])
        else:
            msg += "[%s]" % (result._host.get_name())

        self._display.display(msg + " (item=%s) => %s" % (self._get_item(result._result),
                                                          self._dump_results(result._result)),
                              color=C.COLOR_ERROR)
        self._handle_warnings(result._result) 
開發者ID:grycap,項目名稱:im,代碼行數:26,代碼來源:ansible_executor_v2.py

示例3: v2_playbook_on_stats

# 需要導入模塊: from ansible import constants [as 別名]
# 或者: from ansible.constants import COLOR_ERROR [as 別名]
def v2_playbook_on_stats(self, stats):
        if os.path.isfile(FAIL_LOGFILE):
            count = -1
            with open(FAIL_LOGFILE, 'r') as f:
                for count, line in enumerate(f):
                    pass
                count += 1

            if count > 0:
                self._display.banner("ERROR MESSAGE SUMMARY")
                with io.open(FAIL_LOGFILE, 'r', encoding="utf-8") as f:
                    for _, line in enumerate(f):
                        self._display.display(line.strip('\n'), color=C.COLOR_ERROR)
                    self.print_help_message()
            else:
                self._display.display("Congrats! All goes well. :-)", color=C.COLOR_OK) 
開發者ID:pingcap,項目名稱:tidb-ansible,代碼行數:18,代碼來源:help.py

示例4: v2_runner_on_failed

# 需要導入模塊: from ansible import constants [as 別名]
# 或者: from ansible.constants import COLOR_ERROR [as 別名]
def v2_runner_on_failed(self, result, ignore_errors=False):

        delegated_vars = result._result.get('_ansible_delegated_vars', None)
        self._clean_results(result._result, result._task.action)

        if self._last_task_banner != result._task._uuid:
            self._print_task_banner(result._task)

        self._handle_exception(result._result, use_stderr=self.display_failed_stderr)
        self._handle_warnings(result._result)

        if result._task.loop and 'results' in result._result:
            self._process_items(result)

        else:
            if delegated_vars:
                self._display.display("fatal: [%s -> %s]: FAILED! => %s" % (result._host.get_name(), delegated_vars['ansible_host'],
                                                                            self._dump_results(result._result)),
                                      color=C.COLOR_ERROR, stderr=self.display_failed_stderr)
            else:
                self._display.display("fatal: [%s]: FAILED! => %s" % (result._host.get_name(), self._dump_results(result._result)),
                                      color=C.COLOR_ERROR, stderr=self.display_failed_stderr)

        if ignore_errors:
            self._display.display("...ignoring", color=C.COLOR_SKIP) 
開發者ID:litmuschaos,項目名稱:litmus,代碼行數:27,代碼來源:default.py

示例5: v2_runner_item_on_failed

# 需要導入模塊: from ansible import constants [as 別名]
# 或者: from ansible.constants import COLOR_ERROR [as 別名]
def v2_runner_item_on_failed(self, result):
        if self._last_task_banner != result._task._uuid:
            self._print_task_banner(result._task)

        delegated_vars = result._result.get('_ansible_delegated_vars', None)
        self._clean_results(result._result, result._task.action)
        self._handle_exception(result._result)

        msg = "failed: "
        if delegated_vars:
            msg += "[%s -> %s]" % (result._host.get_name(), delegated_vars['ansible_host'])
        else:
            msg += "[%s]" % (result._host.get_name())

        self._handle_warnings(result._result)
        self._display.display(msg + " (item=%s) => %s" % (self._get_item_label(result._result), self._dump_results(result._result)), color=C.COLOR_ERROR) 
開發者ID:litmuschaos,項目名稱:litmus,代碼行數:18,代碼來源:default.py

示例6: phase_color

# 需要導入模塊: from ansible import constants [as 別名]
# 或者: from ansible.constants import COLOR_ERROR [as 別名]
def phase_color(self, status):
        """ Return color code for installer phase"""
        valid_status = [
            'In Progress',
            'Complete',
        ]

        if status not in valid_status:
            self._display.warning('Invalid phase status defined: {}'.format(status))

        if status == 'Complete':
            phase_color = C.COLOR_OK
        elif status == 'In Progress':
            phase_color = C.COLOR_ERROR
        else:
            phase_color = C.COLOR_WARN

        return phase_color 
開發者ID:ceph,項目名稱:ceph-ansible,代碼行數:20,代碼來源:installer_checkpoint.py

示例7: v2_playbook_on_stats

# 需要導入模塊: from ansible import constants [as 別名]
# 或者: from ansible.constants import COLOR_ERROR [as 別名]
def v2_playbook_on_stats(self, stats):
        self._open_section("system")
        self._emit_line("-- Play recap --")

        hosts = sorted(stats.processed.keys())
        for h in hosts:
            t = stats.summarize(h)

            self._emit_line(u"%s : %s %s %s %s" % (
                hostcolor(h, t),
                colorize(u'ok', t['ok'], C.COLOR_OK),
                colorize(u'changed', t['changed'], C.COLOR_CHANGED),
                colorize(u'unreachable', t['unreachable'], C.COLOR_UNREACHABLE),
                colorize(u'failed', t['failures'], C.COLOR_ERROR))) 
開發者ID:octplane,項目名稱:ansible_stdout_compact_logger,代碼行數:16,代碼來源:anstomlog.py

示例8: v2_playbook_on_stats

# 需要導入模塊: from ansible import constants [as 別名]
# 或者: from ansible.constants import COLOR_ERROR [as 別名]
def v2_playbook_on_stats(self, stats):
        """Print the final playbook run stats"""
        self._display.display("", screen_only=True)
        self.banner("PLAY RECAP")

        hosts = sorted(stats.processed.keys())
        for h in hosts:
            t = stats.summarize(h)

            self._display.display(
                u"%s : %s %s %s %s" % (
                    hostcolor(h, t),
                    colorize(u'ok', t['ok'], C.COLOR_OK),
                    colorize(u'changed', t['changed'], C.COLOR_CHANGED),
                    colorize(u'unreachable', t['unreachable'], C.COLOR_UNREACHABLE),
                    colorize(u'failed', t['failures'], C.COLOR_ERROR)),
                screen_only=True
            )

            self._display.display(
                u"%s : %s %s %s %s" % (
                    hostcolor(h, t, False),
                    colorize(u'ok', t['ok'], None),
                    colorize(u'changed', t['changed'], None),
                    colorize(u'unreachable', t['unreachable'], None),
                    colorize(u'failed', t['failures'], None)),
                log_only=True
            )

        self._display.display("", screen_only=True)
        self._display.display("", screen_only=True)

        # Some plays are conditional and won't run (such as load
        # balancers) if they aren't required. Let the user know about
        # this to avoid potential confusion.
        if self.plays_total_ran != self.plays_count:
            print("Installation Complete: Note: Play count is an estimate and some were skipped because your install does not require them")
            self._display.display("", screen_only=True) 
開發者ID:openshift,項目名稱:origin-ci-tool,代碼行數:40,代碼來源:openshift_quick_installer.py

示例9: v2_playbook_on_stats

# 需要導入模塊: from ansible import constants [as 別名]
# 或者: from ansible.constants import COLOR_ERROR [as 別名]
def v2_playbook_on_stats(self, stats):
        def failed(host):
            _failures = stats.summarize(host).get('failures', 0) > 0
            _unreachable = stats.summarize(host).get('unreachable', 0) > 0
            return (_failures or _unreachable)

        hosts = sorted(stats.processed.keys())
        failed_hosts = [host for host in hosts if failed(host)]

        if hosts:
            if failed_hosts:
                if len(failed_hosts) == len(hosts):
                    print("Failure! The validation failed for all hosts:")
                    for failed_host in failed_hosts:
                        self._display.display("* %s" % failed_host,
                                              color=C.COLOR_ERROR)
                else:
                    print("Failure! The validation failed for hosts:")
                    for failed_host in failed_hosts:
                        self._display.display("* %s" % failed_host,
                                              color=C.COLOR_ERROR)
                    print("and passed for hosts:")
                    for host in [h for h in hosts if h not in failed_hosts]:
                        self._display.display("* %s" % host,
                                              color=C.COLOR_OK)
            else:
                print("Success! The validation passed for all hosts:")
                for host in hosts:
                    self._display.display("* %s" % host,
                                          color=C.COLOR_OK)
        else:
            print("Warning! The validation did not run on any host.") 
開發者ID:openstack,項目名稱:tripleo-validations,代碼行數:34,代碼來源:validation_output.py

示例10: error

# 需要導入模塊: from ansible import constants [as 別名]
# 或者: from ansible.constants import COLOR_ERROR [as 別名]
def error(self, msg, wrap_text=True):
        if wrap_text:
            new_msg = u"\n[ERROR]: %s" % msg
            wrapped = textwrap.wrap(new_msg, self.columns)
            new_msg = u"\n".join(wrapped) + u"\n"
        else:
            new_msg = u"ERROR! %s" % msg
        if new_msg not in self._errors:
            self.display(new_msg, color=C.COLOR_ERROR, stderr=True)
            self._errors[new_msg] = 1 
開發者ID:litmuschaos,項目名稱:litmus,代碼行數:12,代碼來源:display.py

示例11: v2_runner_on_failed

# 需要導入模塊: from ansible import constants [as 別名]
# 或者: from ansible.constants import COLOR_ERROR [as 別名]
def v2_runner_on_failed(self, result, ignore_errors=False):
        self._clean_results(result._result, result._task.action)
        # TODO(mwhahaha): implement this one
        self._handle_exception(result._result)
        self._handle_warnings(result._result)
        if result._task.loop and 'results' in result._result:
            self._process_items(result)
        else:
            if ignore_errors:
                status = 'IGNORED'
                color = C.COLOR_SKIP
            else:
                status = 'FATAL'
                color = C.COLOR_ERROR

            line = [
                self._get_uuid(result),
                self._get_state(status),
                self._get_task_name(result),
                self._get_host(result=result)
            ]
            item_result = self._get_item_label(result._result)
            # don't display if None
            if item_result:
                line.append('item=%s' % item_result)
            line.append('error=%s' % self._dump_results(result._result))
            self._output(line, color) 
開發者ID:openstack,項目名稱:tripleo-ansible,代碼行數:29,代碼來源:tripleo_dense.py

示例12: v2_runner_item_on_failed

# 需要導入模塊: from ansible import constants [as 別名]
# 或者: from ansible.constants import COLOR_ERROR [as 別名]
def v2_runner_item_on_failed(self, result):
        line = [
            self._get_uuid(result),
            self._get_state('FATAL'),
            self._get_task_name(result),
            self._get_host(result=result)
        ]
        color = C.COLOR_ERROR
        item_result = self._get_item_label(result._result)
        # don't display if None
        if item_result:
            line.append('item=%s' % item_result)
        line.append('error=%s' % self._dump_results(result._result))
        self._output(line, color) 
開發者ID:openstack,項目名稱:tripleo-ansible,代碼行數:16,代碼來源:tripleo_dense.py

示例13: v2_runner_on_failed

# 需要導入模塊: from ansible import constants [as 別名]
# 或者: from ansible.constants import COLOR_ERROR [as 別名]
def v2_runner_on_failed(self, result, ignore_errors=False):
        delegated_vars = result._result.get('_ansible_delegated_vars')
        self._clean_results(result._result, result._task.action)

        if self._play.strategy == 'free' and self._last_task_banner != result._task._uuid:
            self._print_task_banner(result._task)

        self._handle_exception(result._result)
        self._handle_warnings(result._result)

        if result._task.loop and 'results' in result._result:
            return

        if delegated_vars:
            msg = "[%s -> %s]: FAILED! => %s" % (
                result._host.get_name(),
                delegated_vars['ansible_host'],
                self._dump_results(result._result),
            )
        else:
            msg = "[%s]: FAILED! => %s" % (
                result._host.get_name(),
                self._dump_results(result._result),
            )

        s = "fatal: %s: %s" % (
            result._task.get_path() or '(dynamic task)',
            msg,
        )
        self._display.display(s, color=C.COLOR_ERROR) 
開發者ID:dw,項目名稱:mitogen,代碼行數:32,代碼來源:nice_stdout.py

示例14: v2_runner_on_failed

# 需要導入模塊: from ansible import constants [as 別名]
# 或者: from ansible.constants import COLOR_ERROR [as 別名]
def v2_runner_on_failed(self, result, ignore_errors=False):
        if 'exception' in result._result:
            if self._display.verbosity < 3:
                # extract just the actual error message from the exception text
                error = result._result['exception'].strip().split('\n')[-1]
                msg = "An exception occurred during task execution. "
                "To see the full traceback, use -vvv. The error was: %s" % error
            else:
                msg = "An exception occurred during task execution. "
                "The full traceback is:\n" + result._result['exception']
            self._display.display(msg, color=C.COLOR_ERROR)

        self._process_results(result, 'FAILED', C.COLOR_ERROR) 
開發者ID:gluster,項目名稱:gdeploy,代碼行數:15,代碼來源:gdeploy.py

示例15: print_failure_message

# 需要導入模塊: from ansible import constants [as 別名]
# 或者: from ansible.constants import COLOR_ERROR [as 別名]
def print_failure_message(self, host_name, task_name, results,
                              abridged_result):
        '''Print a human-readable error info from Ansible result dictionary.'''

        def is_script(results):
            return ('rc' in results and 'invocation' in results
                    and 'script' in results._task_fields['action']
                    and '_raw_params' in results._task_fields['args'])

        display_full_results = False
        if 'rc' in results and 'cmd' in results:
            command = results['cmd']
            # The command can be either a list or a string.
            # Concat if it's a list:
            if type(command) == list:
                command = " ".join(results['cmd'])
            message = "Command `{}` exited with code: {}".format(
                command, results['rc'])
            # There may be an optional message attached to the command.
            # Display it:
            if 'msg' in results:
                message = message + ": " + results['msg']
        elif is_script(results):
            script_name = results['invocation']['module_args']['_raw_params']
            message = "Script `{}` exited with code: {}".format(
                script_name, results['rc'])
        elif 'msg' in results:
            message = results['msg']
        else:
            message = "Unknown error"
            display_full_results = True

        self._display.display(
            FAILURE_TEMPLATE.format(task_name, host_name, message),
            color=C.COLOR_ERROR)

        stdout = results.get('module_stdout', results.get('stdout', ''))
        if stdout:
            print('stdout:')
            self._display.display(indent(stdout), color=C.COLOR_ERROR)
        stderr = results.get('module_stderr', results.get('stderr', ''))
        if stderr:
            print('stderr:')
            self._display.display(indent(stderr), color=C.COLOR_ERROR)
        if display_full_results:
            print(
                "Could not get an error message. Here is the Ansible output:")
            pprint.pprint(abridged_result, indent=4)
        warnings = results.get('warnings', [])
        if warnings:
            print("Warnings:")
            for warning in warnings:
                self._display.display("* %s " % warning, color=C.COLOR_WARN)
            print("") 
開發者ID:openstack,項目名稱:tripleo-validations,代碼行數:56,代碼來源:validation_output.py


注:本文中的ansible.constants.COLOR_ERROR屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。