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


Python Log.commands方法代碼示例

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


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

示例1: _parse_arg_commands

# 需要導入模塊: from haproxy.logfile import Log [as 別名]
# 或者: from haproxy.logfile.Log import commands [as 別名]
def _parse_arg_commands(commands):
    input_commands = commands.split(',')
    available_commands = Log.commands()
    for cmd in input_commands:
        if cmd not in available_commands:
            msg = 'command "{0}" is not available. Use --list-commands to ' \
                  'get a list of all available commands.'
            raise ValueError(msg.format(cmd))
    return input_commands
開發者ID:gforcada,項目名稱:haproxy_log_analysis,代碼行數:11,代碼來源:main.py

示例2: test_arg_parser_list_commands_output

# 需要導入模塊: from haproxy.logfile import Log [as 別名]
# 或者: from haproxy.logfile.Log import commands [as 別名]
    def test_arg_parser_list_commands_output(self):
        """Test that list commands argument outputs what's expected."""
        arguments = ['--list-commands', ]
        data = parse_arguments(self.parser.parse_args(arguments))
        test_output = NamedTemporaryFile(mode='w', delete=False)

        with RedirectStdout(stdout=test_output):
            main(data)

        with open(test_output.name, 'r') as output_file:
            output_text = output_file.read()

            for cmd in Log.commands():
                self.assertIn(cmd, output_text)
開發者ID:sayiho,項目名稱:haproxy_log_analysis,代碼行數:16,代碼來源:test_argparse.py

示例3: print_commands

# 需要導入模塊: from haproxy.logfile import Log [as 別名]
# 或者: from haproxy.logfile.Log import commands [as 別名]
def print_commands():
    """Prints all commands available from Log with their
    description.
    """
    dummy_log_file = Log()
    commands = Log.commands()
    commands.sort()

    for cmd in commands:
        cmd = getattr(dummy_log_file, 'cmd_{0}'.format(cmd))
        description = cmd.__doc__
        if description:
            description = re.sub(r'\n\s+', ' ', description)
            description = description.strip()

        print('{0}: {1}\n'.format(cmd.__name__, description))
開發者ID:gforcada,項目名稱:haproxy_log_analysis,代碼行數:18,代碼來源:main.py


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