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


Python constants.COLOR_WARN屬性代碼示例

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


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

示例1: _handle_warnings

# 需要導入模塊: from ansible import constants [as 別名]
# 或者: from ansible.constants import COLOR_WARN [as 別名]
def _handle_warnings(self, result):
        if not C.ACTION_WARNINGS:
            return
        if result.get('warnings', False):
            line = [
                self._get_uuid(result),
                self._get_state('WARNING')
            ]
            color = C.COLOR_WARN
            for warn in result['warnings']:
                msg = line + [warn]
                self._output(msg, color)
            del result['warnings']
        if result.get('deprecations', False):
            line = [
                self._get_uuid(result),
                self._get_state('DEPRECATED')
            ]
            color = C.COLOR_DEPRECATE
            # TODO(mwhahaha): handle deps correctly as they are a dict
            for dep in result['deprecations']:
                msg = line + [dep['msg']]
                self._output(msg, color)
            del result['deprecations'] 
開發者ID:openstack,項目名稱:tripleo-ansible,代碼行數:26,代碼來源:tripleo_dense.py

示例2: phase_color

# 需要導入模塊: from ansible import constants [as 別名]
# 或者: from ansible.constants import COLOR_WARN [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

示例3: print_help_message

# 需要導入模塊: from ansible import constants [as 別名]
# 或者: from ansible.constants import COLOR_WARN [as 別名]
def print_help_message(self):
        self._display.display("Ask TiDB User Group for help:", color=C.COLOR_WARN)
        self._display.display(
            "It seems that you have encountered some problem. Please describe your operation steps and provide error information as much as possible on https://asktug.com (in Chinese) or https://stackoverflow.com/questions/tagged/tidb (in English). We will do our best to help solve your problem. Thanks. :-)",
            color=C.COLOR_WARN) 
開發者ID:pingcap,項目名稱:tidb-ansible,代碼行數:7,代碼來源:help.py

示例4: v2_runner_on_ok

# 需要導入模塊: from ansible import constants [as 別名]
# 或者: from ansible.constants import COLOR_WARN [as 別名]
def v2_runner_on_ok(self, result, **kwargs):
        host_name = result._host
        task_name = result._task.get_name()
        task_fields = result._task_fields
        results = result._result  # A dict of the module name etc.
        self._dump_results(results)
        warnings = results.get('warnings', [])
        # Print only tasks that produced some warnings:
        if warnings:
            for warning in warnings:
                warn_msg = "{}\n".format(warning)
            self._display.display(WARNING_TEMPLATE.format(task_name,
                                                          host_name,
                                                          warn_msg),
                                  color=C.COLOR_WARN)

        if 'debug' in task_fields['action']:
            output = ""

            if 'var' in task_fields['args']:
                variable = task_fields['args']['var']
                value = results[variable]
                output = "{}: {}".format(variable, str(value))
            elif 'msg' in task_fields['args']:
                output = "Message: {}".format(
                    task_fields['args']['msg'])

            self._display.display(DEBUG_TEMPLATE.format(host_name, output),
                                  color=C.COLOR_OK) 
開發者ID:openstack,項目名稱:tripleo-validations,代碼行數:31,代碼來源:validation_output.py

示例5: warning

# 需要導入模塊: from ansible import constants [as 別名]
# 或者: from ansible.constants import COLOR_WARN [as 別名]
def warning(self, msg, formatted=False):

        if not formatted:
            new_msg = "\n[WARNING]: %s" % msg
            wrapped = textwrap.wrap(new_msg, self.columns)
            new_msg = "\n".join(wrapped) + "\n"
        else:
            new_msg = "\n[WARNING]: \n%s" % msg

        if new_msg not in self._warns:
            self.display(new_msg, color=C.COLOR_WARN, stderr=True)
            self._warns[new_msg] = 1 
開發者ID:litmuschaos,項目名稱:litmus,代碼行數:14,代碼來源:display.py

示例6: print_failure_message

# 需要導入模塊: from ansible import constants [as 別名]
# 或者: from ansible.constants import COLOR_WARN [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_WARN屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。