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


Python Field.for_types方法代码示例

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


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

示例1: import

# 需要导入模块: from eliot import Field [as 别名]
# 或者: from eliot.Field import for_types [as 别名]
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,代码行数:33,代码来源:_docker.py

示例2: loads

# 需要导入模块: from eliot import Field [as 别名]
# 或者: from eliot.Field import for_types [as 别名]
            dictionary = dictionary.copy()
            dictionary.pop(_CLASS_MARKER)
            return _CONFIG_CLASS_MAP[class_name].create(dictionary)
        else:
            return dictionary

    return loads(data, object_hook=decode)


_DEPLOYMENT_FIELD = Field(u"configuration", repr)
_LOG_STARTUP = MessageType(u"flocker-control:persistence:startup",
                           [_DEPLOYMENT_FIELD])
_LOG_SAVE = ActionType(u"flocker-control:persistence:save",
                       [_DEPLOYMENT_FIELD], [])

_UPGRADE_SOURCE_FIELD = Field.for_types(
    u"source_version", [int], u"Configuration version to upgrade from.")
_UPGRADE_TARGET_FIELD = Field.for_types(
    u"target_version", [int], u"Configuration version to upgrade to.")
_LOG_UPGRADE = ActionType(u"flocker-control:persistence:migrate_configuration",
                          [_DEPLOYMENT_FIELD, _UPGRADE_SOURCE_FIELD,
                           _UPGRADE_TARGET_FIELD, ], [])
_LOG_EXPIRE = MessageType(
    u"flocker-control:persistence:lease-expired",
    [Field(u"dataset_id", unicode), Field(u"node_id", unicode)],
    u"A lease for a dataset has expired.")

_LOG_UNCHANGED_DEPLOYMENT_NOT_SAVED = MessageType(
    u"flocker-control:persistence:unchanged-deployment-not-saved",
    [],
    u"The persistence service was told to save a deployment which is the same "
    u"as the already-saved deployment.  It has optimized this away."
开发者ID:Kaffa-MY,项目名称:flocker,代码行数:34,代码来源:_persistence.py

示例3: import

# 需要导入模块: from eliot import Field [as 别名]
# 或者: from eliot.Field import for_types [as 别名]
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,代码行数:32,代码来源:test_interface.py

示例4: import

# 需要导入模块: from eliot import Field [as 别名]
# 或者: from eliot.Field import for_types [as 别名]
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,代码行数:31,代码来源:eliotutil.py

示例5: isinstance

# 需要导入模块: from eliot import Field [as 别名]
# 或者: from eliot.Field import for_types [as 别名]
        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,代码行数:32,代码来源:eliotutil.py

示例6: import

# 需要导入模块: from eliot import Field [as 别名]
# 或者: from eliot.Field import for_types [as 别名]
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,代码行数:33,代码来源:_conch.py

示例7: ActionType

# 需要导入模块: from eliot import Field [as 别名]
# 或者: from eliot.Field import for_types [as 别名]
from characteristic import attributes
from eliot import MessageType, ActionType, Field
from eliot.twisted import DeferredContext

from twisted.python.failure import Failure
from twisted.internet.error import ProcessTerminated, ProcessDone
from twisted.internet.defer import Deferred
from twisted.internet.protocol import ProcessProtocol

from twisted.protocols.basic import LineOnlyReceiver


RUN_ACTION = ActionType(
    action_type="flocker.common.runner:run",
    startFields=[
        Field.for_types(u"command", [list], u"The command.")
    ],
    successFields=[],
    description="Run a command.",
)
RUN_OUTPUT_MESSAGE = MessageType(
    message_type="flocker.common.runner:run:stdout",
    fields=[
        Field.for_types(u"line", [bytes], u"The output."),
    ],
    description=u"A line of command output.",
)
RUN_ERROR_MESSAGE = MessageType(
    message_type="flocker.common.runner:run:stderr",
    fields=[
        Field.for_types(u"line", [bytes], u"The error."),
开发者ID:332054781,项目名称:flocker,代码行数:33,代码来源:runner.py

示例8: MessageType

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

from eliot import Field, MessageType

CINDER_VOLUME = MessageType(
    u"flocker:functional:cinder:cinder_volume:created",
    [Field.for_types(
        u"id", [bytes, unicode],
        u"The Cinder-assigned unique identifier for the volume that was "
        u"created.",
    )],
)
开发者ID:Kaffa-MY,项目名称:flocker,代码行数:14,代码来源:logging.py

示例9: validateInstanceOf

# 需要导入模块: from eliot import Field [as 别名]
# 或者: from eliot.Field import for_types [as 别名]
    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,代码行数:34,代码来源:magicfolderdb.py

示例10: drivers

# 需要导入模块: from eliot import Field [as 别名]
# 或者: from eliot.Field import for_types [as 别名]
"""
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,代码行数:34,代码来源:_logging.py

示例11: into

# 需要导入模块: from eliot import Field [as 别名]
# 或者: from eliot.Field import for_types [as 别名]
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,代码行数:33,代码来源:_openstack.py

示例12: Field

# 需要导入模块: from eliot import Field [as 别名]
# 或者: from eliot.Field import for_types [as 别名]
    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,代码行数:33,代码来源:inotify.py

示例13: ActionType

# 需要导入模块: from eliot import Field [as 别名]
# 或者: from eliot.Field import for_types [as 别名]
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,代码行数:32,代码来源:logging.py

示例14: fields

# 需要导入模块: from eliot import Field [as 别名]
# 或者: from eliot.Field import for_types [as 别名]
    u'txacme:jws:http:get',
    fields(),
    fields(),
    u'A JWSClient GET request')

LOG_JWS_POST = ActionType(
    u'txacme:jws:http:post',
    fields(),
    fields(),
    u'A JWSClient POST request')

LOG_JWS_REQUEST = ActionType(
    u'txacme:jws:http:request',
    fields(url=unicode),
    fields(Field.for_types(u'content_type',
                           [unicode, None],
                           u'Content-Type header field'),
           code=int),
    u'A JWSClient request')

LOG_JWS_CHECK_RESPONSE = ActionType(
    u'txacme:jws:http:check-response',
    fields(Field.for_types(u'response_content_type',
                           [unicode, None],
                           u'Content-Type header field'),
           expected_content_type=unicode),
    fields(),
    u'Checking a JWSClient response')

LOG_JWS_GET_NONCE = ActionType(
    u'txacme:jws:nonce:get',
开发者ID:habnabit,项目名称:txacme,代码行数:33,代码来源:logging.py


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