当前位置: 首页>>代码示例>>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;未经允许,请勿转载。