当前位置: 首页>>代码示例>>Python>>正文


Python Field.forTypes方法代码示例

本文整理汇总了Python中eliot.Field.forTypes方法的典型用法代码示例。如果您正苦于以下问题:Python Field.forTypes方法的具体用法?Python Field.forTypes怎么用?Python Field.forTypes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在eliot.Field的用法示例。


在下文中一共展示了Field.forTypes方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: result

# 需要导入模块: from eliot import Field [as 别名]
# 或者: from eliot.Field import forTypes [as 别名]
    :param arguments: A ``list`` of ``bytes``, command-line arguments to
    ``zfs``.

    :return: A :class:`Deferred` firing with the bytes of the result (on
        exit code 0), or errbacking with :class:`CommandFailed` or
        :class:`BadArguments` depending on the exit code (1 or 2).
    """
    endpoint = ProcessEndpoint(reactor, b"zfs", [b"zfs"] + arguments,
                               os.environ)
    d = connectProtocol(endpoint, _AccumulatingProtocol())
    d.addCallback(lambda protocol: protocol._result)
    return d


_ZFS_COMMAND = Field.forTypes(
    "zfs_command", [bytes], u"The command which was run.")
_OUTPUT = Field.forTypes(
    "output", [bytes], u"The output generated by the command.")
_STATUS = Field.forTypes(
    "status", [int], u"The exit status of the command")


ZFS_ERROR = MessageType(
    "filesystem:zfs:error", [_ZFS_COMMAND, _OUTPUT, _STATUS],
    u"The zfs command signaled an error.")


def _sync_command_error_squashed(arguments, logger):
    """
    Synchronously run a command-line tool with the given arguments.
开发者ID:Waynelemars,项目名称:flocker,代码行数:32,代码来源:zfs.py

示例2: _system

# 需要导入模块: from eliot import Field [as 别名]
# 或者: from eliot.Field import forTypes [as 别名]
from zope.interface import Attribute, Interface, implementer, provider
from zope.interface.exceptions import DoesNotImplement

from eliot import Field, ActionType, Logger

from twisted.python.util import FancyStrMixin, FancyEqMixin
from twisted.python.components import proxyForInterface
from twisted.internet.defer import succeed

def _system(suffix):
    return u":".join((u"fsm", suffix))


FSM_IDENTIFIER = Field.forTypes(
    u"fsm_identifier", [unicode],
    u"An unique identifier for the FSM to which the event pertains.")
FSM_STATE = Field.forTypes(
    u"fsm_state", [unicode], u"The state of the FSM prior to the transition.")
FSM_RICH_INPUT = Field.forTypes(
    u"fsm_rich_input", [unicode],
    u"The string representation of the rich input delivered to the FSM.")
FSM_INPUT = Field.forTypes(
    u"fsm_input", [unicode],
    u"The string representation of the input symbol delivered to the FSM.")
FSM_NEXT_STATE = Field.forTypes(
    u"fsm_next_state", [unicode],
    u"The string representation of the state of the FSM after the transition.")
FSM_OUTPUT = Field.forTypes(
    u"fsm_output", [list], # of unicode
    u"A list of the string representations of the outputs produced by the "
开发者ID:glyph,项目名称:machinist,代码行数:32,代码来源:_fsm.py

示例3: Field

# 需要导入模块: from eliot import Field [as 别名]
# 或者: from eliot.Field import forTypes [as 别名]
from eliot import Field, ActionType

__all__ = [
    "JSON_REQUEST",
    "REQUEST",
    ]

LOG_SYSTEM = u"api"

METHOD = Field(u"method", lambda method: method,
               u"The HTTP method of the request.")
REQUEST_PATH = Field(
    u"request_path", lambda path: path,
    u"The absolute path of the resource to which the request was issued.")
JSON = Field.forTypes(
    u"json", [unicode, bytes, dict, list, None, bool, float],
    u"The JSON request body.")
RESPONSE_CODE = Field.forTypes(
    u"code", [int],
    u"The response code for the request.")


# It would be nice if RESPONSE_CODE was in REQUEST instead of
# JSON_REQUEST; see FLOC-1586.
REQUEST = ActionType(
    LOG_SYSTEM + u":request",
    [REQUEST_PATH, METHOD],
    [],
    u"A request was received on the public HTTP interface.")

# NB we deliberately do not log the entire JSON response body because the
开发者ID:DummyOrganizationToTest,项目名称:flocker,代码行数:33,代码来源:_logging.py

示例4: ActionType

# 需要导入模块: from eliot import Field [as 别名]
# 或者: from eliot.Field import forTypes [as 别名]
from twisted.internet.defer import succeed, fail
from twisted.python.filepath import FilePath
from twisted.web.http import CREATED, OK, CONFLICT, NOT_FOUND
from twisted.internet.utils import getProcessOutput

from treq import json_content, content

from ..ca import treq_with_authentication
from ..control import Leases as LeasesModel, LeaseError
from ..common import retry_failure

from .. import __version__

_LOG_HTTP_REQUEST = ActionType(
    "flocker:apiclient:http_request",
    [Field.forTypes("url", [bytes, unicode], "Request URL."),
     Field.forTypes("method", [bytes, unicode], "Request method."),
     Field("request_body", lambda o: o, "Request JSON body.")],
    [Field.forTypes("response_code", [int], "Response code."),
     Field("response_body", lambda o: o, "JSON response body.")],
    "A HTTP request.")


NoneType = type(None)


class Dataset(PClass):
    """
    A dataset in the configuration.

    :attr UUID primary: The node where the dataset should manifest.
开发者ID:stmcginnis,项目名称:flocker,代码行数:33,代码来源:_client.py

示例5: _ascii

# 需要导入模块: from eliot import Field [as 别名]
# 或者: from eliot.Field import forTypes [as 别名]
The goal here is to mostly focus on performance of serialization, in a vaguely
realistic manner. That is, mesages are logged in context of a message with a
small number of fields.
"""

from __future__ import unicode_literals

import time

from eliot import Logger, MessageType, Field, ActionType

def _ascii(s):
    return s.decode("ascii")


F1 = Field.forTypes("integer", [int], "")
F2 = Field("string", _ascii, "")
F3 = Field("string2", _ascii, "")
F4 = Field.forTypes("list", [list], "list of integers")

M = MessageType("system:message", [F1, F2, F3, F4], "description")
A = ActionType("action", [], [], [], "desc")

log = Logger()

N = 100000

def run():
    start = time.time()
    with A(log):
        for i in xrange(N):
开发者ID:adamtheturtle,项目名称:eliot,代码行数:33,代码来源:serialization.py

示例6: Field

# 需要导入模块: from eliot import Field [as 别名]
# 或者: from eliot.Field import forTypes [as 别名]
__all__ = [
    "JSON_REQUEST",
    "REQUEST",
    ]

from eliot import Field, ActionType

LOG_SYSTEM = u"api"

METHOD = Field(u"method", lambda method: method,
               u"The HTTP method of the request.")
REQUEST_PATH = Field(
    u"request_path", lambda path: path,
    u"The absolute path of the resource to which the request was issued.")
JSON = Field.forTypes(
    u"json", [unicode, bytes, dict, list, None, bool, float],
    u"JSON, either request or response depending on context.")
RESPONSE_CODE = Field.forTypes(
    u"code", [int],
    u"The response code for the request.")


# It would be nice if RESPONSE_CODE was in REQUEST instead of
# JSON_REQUEST; see FLOC-1586.
REQUEST = ActionType(
    LOG_SYSTEM + u":request",
    [REQUEST_PATH, METHOD],
    [],
    u"A request was received on the public HTTP interface.")
JSON_REQUEST = ActionType(
    LOG_SYSTEM + u":json_request",
开发者ID:ALSEDLAH,项目名称:flocker,代码行数:33,代码来源:_logging.py

示例7: ActionType

# 需要导入模块: from eliot import Field [as 别名]
# 或者: from eliot.Field import forTypes [as 别名]
# Copyright Hybrid Logic Ltd.  See LICENSE file for details.

"""
This module defines the Eliot log events emitted by the API implementation.
"""

__all__ = [
    "REQUEST_PATH",
    "REQUEST",
    ]

from eliot import Field, ActionType

LOG_SYSTEM = u"api"

REQUEST_PATH = Field.forTypes(
    u"request_path", [unicode],
    u"The absolute path of the resource to which the request was issued.")

REQUEST = ActionType(
    LOG_SYSTEM,
    [REQUEST_PATH],
    [],
    u"A request was received on the public HTTP interface.")
开发者ID:alex-docker,项目名称:flocker,代码行数:26,代码来源:_logging.py

示例8: type

# 需要导入模块: from eliot import Field [as 别名]
# 或者: from eliot.Field import forTypes [as 别名]
                u"target_ip", type(value)))


def serialize_ipv4_address(address):
    return unicode(address)


TARGET_IP = Field(
    key=u"target_ip",
    serializer=serialize_ipv4_address,
    extraValidator=validate_ipv4_address,
    description=u"The IP address which is the target of a proxy.")


TARGET_PORT = Field.forTypes(
    u"target_port", [int],
    u"The port number which is the target of a proxy.")


ARGV = Field.forTypes(
    u"argv", [list],
    u"The argument list of a child process being executed.")


IPTABLES = ActionType(
    _system(u"iptables"),
    [ARGV],
    [],
    u"An iptables command which Flocker is executing against the system.")

开发者ID:ALSEDLAH,项目名称:flocker,代码行数:31,代码来源:_logging.py


注:本文中的eliot.Field.forTypes方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。