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


Python eliot.Field类代码示例

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


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

示例1: isinstance

        if not isinstance(v, t):
            raise ValidationError("{} not an instance of {}".format(v, t))
    return validator

def validateSetMembership(s):
    """
    Return an Eliot validator that requires values to be elements of ``s``.
    """
    def validator(v):
        if v not in s:
            raise ValidationError("{} not in {}".format(v, s))
    return validator

RELPATH = Field.for_types(
    u"relpath",
    [unicode],
    u"The relative path of a file in a magic-folder.",
)

VERSION = Field.for_types(
    u"version",
    [int, long],
    u"The version of the file.",
)

LAST_UPLOADED_URI = Field.for_types(
    u"last_uploaded_uri",
    [unicode, bytes, None],
    u"The filecap to which this version of this file was uploaded.",
)
开发者ID:tahoe-lafs,项目名称:tahoe-lafs,代码行数:30,代码来源:eliotutil.py

示例2: import

from twisted.internet.error import ConnectionDone
from twisted.protocols.basic import LineOnlyReceiver
from twisted.python.filepath import FilePath
import os

from ...common import loop_until, timeout
from ._model import (
    Run, Sudo, Put, Comment, RunRemotely, perform_comment, perform_put,
    perform_sudo)

from .._effect import dispatcher as base_dispatcher

RUN_OUTPUT_MESSAGE = MessageType(
    message_type="flocker.provision.ssh:run:output",
    fields=[
        Field.for_types(u"line", [bytes], u"The output."),
    ],
    description=u"A line of command output.",
)


def extReceived(self, type, data):
    from twisted.conch.ssh.connection import EXTENDED_DATA_STDERR
    if type == EXTENDED_DATA_STDERR:
        self.dataReceived(data)


@attributes([
    "deferred",
    "context",
])
开发者ID:wangbinxiang,项目名称:flocker,代码行数:31,代码来源:_conch.py

示例3: ActionType

LOG_START_SERVICE = ActionType(
    u'fusion_index:service:start',
    [_SERVICE_DESCRIPTION],
    [],
    u'Indexing service is starting')


LOG_STOP_SERVICE = ActionType(
    u'fusion_index:service:stop', [], [], u'Indexing service is stopping')


LOG_LOOKUP_GET = ActionType(
    u'fusion_index:lookup:get',
    fields(environment=unicode, indexType=unicode, key=unicode),
    [Field.for_types('value', [bytes, None], u'Value in the index, if any')],
    u'Retrieving a value from the lookup index')


LOG_LOOKUP_PUT = ActionType(
    u'fusion_index:lookup:put',
    fields(environment=unicode, indexType=unicode, key=unicode),
    fields(value=bytes),
    u'Storing a value in the lookup index')


_SEARCH_TYPE = Field.for_types(
    'searchType', [unicode, None], u'The search type')
LOG_SEARCH_GET = ActionType(
    u'fusion_index:search:get',
    fields(
开发者ID:fusionapp,项目名称:fusion-index,代码行数:30,代码来源:logging.py

示例4: _ascii

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,代码行数:31,代码来源:serialization.py

示例5: import

from twisted.internet.defer import succeed, fail
from twisted.internet.threads import deferToThread
from twisted.web.http import NOT_FOUND, INTERNAL_SERVER_ERROR

from ..common import (
    poll_until,
    retry_if, decorate_methods, with_retry, get_default_retry_steps,
)

from ..control._model import (
    RestartNever, RestartAlways, RestartOnFailure, pset_field, pvector_field)


LOG_CACHED_IMAGE = MessageType(
    u"flocker:node:docker:image_from_cache",
    [Field.for_types(u"image", [unicode], "The image ID.")],
    "An image was retrieved from the cache."
)


class AlreadyExists(Exception):
    """A unit with the given name already exists."""


@with_cmp(["address", "apierror"])
class AddressInUse(Exception):
    """
    The listen address for an exposed port was in use and could not be bound.
    """
    def __init__(self, address, apierror):
        """
开发者ID:AlexRRR,项目名称:flocker,代码行数:31,代码来源:_docker.py

示例6: Field

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,代码行数:31,代码来源:_logging.py

示例7: drivers

"""
Helper module to provide macros for logging support
for storage drivers (AWS, Cinder).
See https://clusterhq.atlassian.net/browse/FLOC-2053
for consolidation opportunities.
"""

from eliot import Field, ActionType, MessageType

# Begin: Common structures used by all (AWS, OpenStack)
# storage drivers.

# An OPERATION is a list of:
# IBlockDeviceAPI name, positional arguments, keyword arguments.
OPERATION = Field.for_types(
    u"operation", [list],
    u"The IBlockDeviceAPI operation being executed,"
    u"along with positional and keyword arguments.")

# End: Common structures used by all storage drivers.

# Begin: Helper datastructures to log IBlockDeviceAPI calls
# from AWS storage driver using Eliot.

# ActionType used by AWS storage driver.
AWS_ACTION = ActionType(
    u"flocker:node:agents:blockdevice:aws",
    [OPERATION],
    [],
    u"An IBlockDeviceAPI operation is executing using AWS storage driver.")

# Three fields to gather from EC2 response to Boto.
开发者ID:hackday-profilers,项目名称:flocker,代码行数:32,代码来源:_logging.py

示例8: import

import attr

from eliot import (
    ActionType,
    Field,
)
from eliot.testing import capture_logging

from twisted.internet.defer import (
    maybeDeferred,
)

_NAME = Field.for_types(
    u"name",
    [unicode],
    u"The name of the test.",
)

RUN_TEST = ActionType(
    u"run-test",
    [_NAME],
    [],
    u"A test is run.",
)


def eliot_logged_test(f):
    """
    Decorate a test method to run in a dedicated Eliot action context.
开发者ID:tahoe-lafs,项目名称:tahoe-lafs,代码行数:29,代码来源:eliotutil.py

示例9: Field

__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,代码行数:31,代码来源:_logging.py

示例10: into

OpenStack-related tools.
"""

# After _interface_decorator is public, move this and auto_openstack_logging
# into (or at least nearer) flocker/node/agents/cinder.py.
from eliot import Field, MessageType

from novaclient.exceptions import ClientException as NovaClientException
from keystoneclient.openstack.common.apiclient.exceptions import (
    HttpError as KeystoneHttpError,
)

from ._thread import _interface_decorator


CODE = Field.for_types("code", [int], u"The HTTP response code.")
MESSAGE = Field.for_types(
    "message", [bytes, unicode],
    u"A human-readable error message given by the response.",
)
DETAILS = Field.for_types("details", [dict], u"Extra details about the error.")
REQUEST_ID = Field.for_types(
    "request_id", [bytes, unicode],
    u"The unique identifier assigned by the server for this request.",
)
URL = Field.for_types("url", [bytes, unicode], u"The request URL.")
METHOD = Field.for_types("method", [bytes, unicode], u"The request method.")

NOVA_CLIENT_EXCEPTION = MessageType(
    u"openstack:nova_client_exception", [
        CODE,
开发者ID:runcom,项目名称:flocker,代码行数:31,代码来源:_openstack.py

示例11: ActionType

# 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,代码行数:24,代码来源:_logging.py

示例12: Field

    CALLBACK,
    validateInstanceOf,
)

from . import _watchdog_541

_watchdog_541.patch()

NOT_STARTED = "NOT_STARTED"
STARTED     = "STARTED"
STOPPING    = "STOPPING"
STOPPED     = "STOPPED"

_PATH = Field.for_types(
    u"path",
    [bytes, unicode],
    u"The path an inotify event concerns.",
)

_EVENT = Field(
    u"event",
    lambda e: e.__class__.__name__,
    u"The watchdog event that has taken place.",
    validateInstanceOf(FileSystemEvent),
)

ANY_INOTIFY_EVENT = ActionType(
    u"watchdog:inotify:any-event",
    [_PATH, _EVENT],
    [],
    u"An inotify event is being dispatched.",
开发者ID:tahoe-lafs,项目名称:tahoe-lafs,代码行数:31,代码来源:inotify.py

示例13: type

                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,代码行数:29,代码来源:_logging.py

示例14: import

from twisted.trial.unittest import SynchronousTestCase

from eliot.testing import (
    assertHasMessage, capture_logging
)
from eliot import Field, MessageType

from zope.interface import Interface, implementer

from .. import interface_decorator


# Eliot structures for testing ``interface_decorator``.
METHOD = Field.for_types(
    u"method", [unicode],
    u"The name of the decorated method.")
TEST_MESSAGE = MessageType(u"flocker:common:test:interface:message",
                           [METHOD])
TEST_EXCEPTION = MessageType(u"flocker:common:test:interface:exception",
                             [METHOD])


class IDummy(Interface):
    """
    Dummy interface with two test methods.
    """
    def return_method():
        """
        Return something.
        """
开发者ID:achanda,项目名称:flocker,代码行数:30,代码来源:test_interface.py

示例15: validateInstanceOf

    lambda v: None if v is None else {
        "size": v.size,
        "mtime_ns": v.mtime_ns,
        "ctime_ns": v.ctime_ns,
        "version": v.version,
        "last_uploaded_uri": v.last_uploaded_uri,
        "last_downloaded_uri": v.last_downloaded_uri,
        "last_downloaded_timestamp": v.last_downloaded_timestamp,
    },
    u"The local database state of a file.",
    validateInstanceOf((type(None), PathEntry)),
)

_INSERT_OR_UPDATE = Field.for_types(
    u"insert_or_update",
    [unicode],
    u"An indication of whether the record for this upload was new or an update to a previous entry.",
    validateSetMembership({u"insert", u"update"}),
)

UPDATE_ENTRY = ActionType(
    u"magic-folder-db:update-entry",
    [RELPATH, VERSION, LAST_UPLOADED_URI, LAST_DOWNLOADED_URI, LAST_DOWNLOADED_TIMESTAMP, PATHINFO],
    [_INSERT_OR_UPDATE],
    u"Record some metadata about a relative path in the magic-folder.",
)


# magic-folder db schema version 1
SCHEMA_v1 = """
CREATE TABLE version
(
开发者ID:tahoe-lafs,项目名称:tahoe-lafs,代码行数:32,代码来源:magicfolderdb.py


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