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


Python ClacksErrorHandler.register_codes方法代码示例

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


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

示例1: PosixException

# 需要导入模块: from clacks.common.error import ClacksErrorHandler [as 别名]
# 或者: from clacks.common.error.ClacksErrorHandler import register_codes [as 别名]
#
# License:
#  GPL-2: http://www.gnu.org/licenses/gpl-2.0.html
#
# See the LICENSE file in the project's top-level directory for details.

from clacks.agent.objects.filter import ElementFilter
from clacks.agent.objects.backend.registry import ObjectBackendRegistry
from clacks.common.error import ClacksErrorHandler as C
from clacks.common.utils import N_


# Register the errors handled  by us
C.register_codes(dict(
    PARAMETER_NOT_NUMERIC=N_("Parameter for '%(target)s' have to be numeric"),
    BACKEND_TOO_MANY=N_("Too many backends for %(target)s specified"),
    POSIX_ID_POOL_EMPTY=N_("ID pool for attribute %(target)s is empty [> %(max)s]")
))


class PosixException(Exception):
    pass


class GenerateIDs(ElementFilter):
    """
    Generate gid/uidNumbers on demand
    """
    def __init__(self, obj):
        super(GenerateIDs, self).__init__(obj)
开发者ID:gonicus,项目名称:clacks,代码行数:32,代码来源:filters.py

示例2: __import__

# 需要导入模块: from clacks.common.error import ClacksErrorHandler [as 别名]
# 或者: from clacks.common.error.ClacksErrorHandler import register_codes [as 别名]
# Copyright:
#  (C) 2010-2012 GONICUS GmbH, Germany, http://www.gonicus.de
#
# License:
#  GPL-2: http://www.gnu.org/licenses/gpl-2.0.html
#
# See the LICENSE file in the project's top-level directory for details.

__import__('pkg_resources').declare_namespace(__name__)
import pkg_resources
from clacks.common.utils import N_
from clacks.common.error import ClacksErrorHandler as C


C.register_codes(dict(
    COMPARATOR_NO_INSTANCE=N_("No comparator instance for '%(comparator)s' found")
    ))


def get_comparator(name):
    for entry in pkg_resources.iter_entry_points("object.comparator"):

        module = entry.load()
        if module.__name__ == name:
            return module

    raise KeyError(C.make_error("COMPARATOR_NO_INSTANCE", comparator=name))


class ElementComparator(object):
开发者ID:gonicus,项目名称:clacks,代码行数:32,代码来源:__init__.py

示例3: ObjectBackendRegistry

# 需要导入模块: from clacks.common.error import ClacksErrorHandler [as 别名]
# 或者: from clacks.common.error.ClacksErrorHandler import register_codes [as 别名]
# Copyright:
#  (C) 2010-2012 GONICUS GmbH, Germany, http://www.gonicus.de
#
# License:
#  GPL-2: http://www.gnu.org/licenses/gpl-2.0.html
#
# See the LICENSE file in the project's top-level directory for details.

import pkg_resources
from clacks.common.utils import N_
from clacks.common.error import ClacksErrorHandler as C


# Register the errors handled  by us
C.register_codes(dict(
    BACKEND_NOT_FOUND=N_("Backend '%(topic)s' not found"),
    ))


class ObjectBackendRegistry(object):
    instance = None
    backends = {}
    uuidAttr = "entryUUID"

    def __init__(self):
        # Load available backends
        for entry in pkg_resources.iter_entry_points("object.backend"):
            clazz = entry.load()
            ObjectBackendRegistry.backends[clazz.__name__] = clazz()

    def dn2uuid(self, backend, dn):
开发者ID:gonicus,项目名称:clacks,代码行数:33,代码来源:registry.py

示例4: LDAPHandler

# 需要导入模块: from clacks.common.error import ClacksErrorHandler [as 别名]
# 或者: from clacks.common.error.ClacksErrorHandler import register_codes [as 别名]
------
"""
import ldapurl
import ldap.sasl
import types
import logging
from contextlib import contextmanager
from clacks.common import Environment
from clacks.common.utils import N_
from clacks.common.error import ClacksErrorHandler as C
from clacks.agent.exceptions import LDAPException


C.register_codes(dict(
    NO_SASL_SUPPORT=N_("No SASL support in the installed python-ldap detected"),
    LDAP_NO_CONNECTIONS=N_("No LDAP connection available"),
    ))


class LDAPHandler(object):
    """
    The LDAPHandler provides a connection pool with automatically reconnecting
    LDAP connections and is accessible thru the
    :meth:`clacks.agent.ldap_utils.LDAPHandler.get_instance` method.

    Example::

        >>> from clacks.agent.ldap_utils import LDAPHandler
        >>> from ldap.filter import filter_format
        >>> lh = LDAPHandler.get_instance()
        >>> uuid = 'you-will-not-find-anything'
开发者ID:gonicus,项目名称:clacks,代码行数:33,代码来源:ldap_utils.py

示例5: __import__

# 需要导入模块: from clacks.common.error import ClacksErrorHandler [as 别名]
# 或者: from clacks.common.error.ClacksErrorHandler import register_codes [as 别名]
# Copyright:
#  (C) 2010-2012 GONICUS GmbH, Germany, http://www.gonicus.de
#
# License:
#  GPL-2: http://www.gnu.org/licenses/gpl-2.0.html
#
# See the LICENSE file in the project's top-level directory for details.

__import__('pkg_resources').declare_namespace(__name__)
import pkg_resources
from clacks.common.utils import N_
from clacks.common.error import ClacksErrorHandler as C


C.register_codes(dict(
    FILTER_NO_INSTANCE=N_("No filter instance for '%(filter)s' found")
    ))


def get_filter(name):
    for entry in pkg_resources.iter_entry_points("object.filter"):
        module = entry.load()
        if module.__name__ == name:
            return module

    raise KeyError(C.make_error("FILTER_NO_INSTANCE", name))


class ElementFilter(object):

    def __init__(self, obj):
开发者ID:lhm-limux,项目名称:clacks,代码行数:33,代码来源:__init__.py

示例6: SambaHash

# 需要导入模块: from clacks.common.error import ClacksErrorHandler [as 别名]
# 或者: from clacks.common.error.ClacksErrorHandler import register_codes [as 别名]
# Copyright:
#  (C) 2010-2012 GONICUS GmbH, Germany, http://www.gonicus.de
#
# License:
#  GPL-2: http://www.gnu.org/licenses/gpl-2.0.html
#
# See the LICENSE file in the project's top-level directory for details.

import smbpasswd #@UnresolvedImport
from clacks.agent.objects.filter import ElementFilter
from clacks.common.error import ClacksErrorHandler as C
from clacks.common.utils import N_


# Register the errors handled  by us
C.register_codes(dict(
    TYPE_UNKNOWN=N_("Filter '%(target)s' does not support input type '%(type)s'")))


class SambaHash(ElementFilter):
    """
    An object filter which generates samba NT/LM Password hashes for the incoming value.
    """
    def __init__(self, obj):
        super(SambaHash, self).__init__(obj)

    def process(self, obj, key, valDict):
        if len(valDict[key]['value']) and type(valDict[key]['value'][0]) in [str, unicode]:
            lm, nt = smbpasswd.hash(valDict[key]['value'][0])
            valDict['sambaNTPassword']['value'] = [nt]
            valDict['sambaLMPassword']['value'] = [lm]
        else:
开发者ID:gonicus,项目名称:clacks,代码行数:34,代码来源:hash.py

示例7: HTTPDispatcher

# 需要导入模块: from clacks.common.error import ClacksErrorHandler [as 别名]
# 或者: from clacks.common.error.ClacksErrorHandler import register_codes [as 别名]
import logging
import tornado.wsgi
import tornado.web
from tornado.ioloop import IOLoop
from tornado.httpserver import HTTPServer
from zope.interface import implements
from webob import exc #@UnresolvedImport
from clacks.common import Environment
from clacks.common.handler import IInterfaceHandler
from clacks.common.utils import N_
from clacks.common.error import ClacksErrorHandler as C
from clacks.agent.exceptions import HTTPException


C.register_codes(dict(
    HTTP_PATH_ALREADY_REGISTERED=N_("'%(path)s' has already been registered")
    ))


class HTTPDispatcher(object):
    """
    The *HTTPDispatcher* can be used to register WSGI applications
    to a given path. It will inspect the path of an incoming request
    and decides which registered application it gets.

    Analyzing the path can be configured to detect a *subtree* match
    or an *exact* match. If you need subtree matches, just add the
    class variable ``http_subtree`` to the WSGI class and set it to
    *True*.
    """
开发者ID:gonicus,项目名称:clacks,代码行数:32,代码来源:httpd.py

示例8: GOtoException

# 需要导入模块: from clacks.common.error import ClacksErrorHandler [as 别名]
# 或者: from clacks.common.error.ClacksErrorHandler import register_codes [as 别名]
STATUS_OCCUPIED = "B"
STATUS_LOCKED = "L"
STATUS_BOOTING = "b"
STATUS_NEEDS_INITIAL_CONFIG = "P"
STATUS_NEEDS_REMOVE_CONFIG = "R"
STATUS_NEEDS_CONFIG = "c"
STATUS_NEEDS_INSTALL = "N"


# Register the errors handled  by us
C.register_codes(dict(
    DEVICE_EXISTS=N_("Device with hardware address '%(topic)s' already exists"),
    USER_NOT_UNIQUE=N_("User '%(topic)s' is not unique"),
    CLIENT_NOT_FOUND=N_("Client '%(topic)s' not found"),
    CLIENT_OFFLINE=N_("Client '%(topic)s' is offline"),
    CLIENT_METHOD_NOT_FOUND=N_("Client '%(topic)s' has no method %(method)s"),
    CLIENT_DATA_INVALID=N_("Invalid data '%(entry)s:%(data)s' for client '%(target)s provided'"),
    CLIENT_TYPE_INVALID=N_("Device type '%(type)s' for client '%(target)s' is invalid [terminal, workstation, server, sipphone, switch, router, printer, scanner]"),
    CLIENT_OWNER_NOT_FOUND=N_("Owner '%(owner)s' for client '%(target)s' not found"),
    CLIENT_UUID_INVALID=N_("Invalid client UUID '%(target)s'"),
    CLIENT_STATUS_INVALID=N_("Invalid status '%(status)s' for client '%(target)s'")))


class GOtoException(Exception):
    pass


class ClientService(Plugin):
    """
    Plugin to register clients and expose their functionality
    to the users.
开发者ID:gonicus,项目名称:clacks,代码行数:33,代码来源:client_service.py

示例9: GOsaException

# 需要导入模块: from clacks.common.error import ClacksErrorHandler [as 别名]
# 或者: from clacks.common.error.ClacksErrorHandler import register_codes [as 别名]
from clacks.common.components import Command
from clacks.common.components import Plugin
from clacks.common.utils import N_
from clacks.common.components import PluginRegistry
from clacks.agent.objects import ObjectProxy
from clacks.agent.objects.factory import ObjectFactory
import clacks.agent.objects.renderer
from clacks.common.handler import IInterfaceHandler
from json import loads, dumps
from clacks.common.error import ClacksErrorHandler as C


# Register the errors handled  by us
C.register_codes(dict(
    INVALID_SEARCH_SCOPE=N_("Invalid scope '%(scope)s' [SUB, BASE, ONE, CHILDREN]"),
    INVALID_SEARCH_DATE=N_("Invalid date specification '%(date)s' [hour, day, week, month, year, all]"),
    UNKNOWN_USER=N_("Unknown user '%(target)s'"),
    BACKEND_PARAMETER_MISSING=N_("Backend parameter for '%(extension)s.%(attribute)s' is missing")))


class GOsaException(Exception):
    pass


class GuiMethods(Plugin):
    """
    Key for configuration section **gosa**

    +------------------+------------+-------------------------------------------------------------+
    + Key              | Format     +  Description                                                |
    +==================+============+=============================================================+
开发者ID:gonicus,项目名称:clacks,代码行数:33,代码来源:methods.py

示例10: SambaException

# 需要导入模块: from clacks.common.error import ClacksErrorHandler [as 别名]
# 或者: from clacks.common.error.ClacksErrorHandler import register_codes [as 别名]
#  GPL-2: http://www.gnu.org/licenses/gpl-2.0.html
#
# See the LICENSE file in the project's top-level directory for details.

import re
from clacks.common.utils import N_
from clacks.common import Environment
from clacks.agent.objects.filter import ElementFilter
from clacks.common.components import PluginRegistry
from clacks.agent.objects.comparator import ElementComparator
from clacks.common.error import ClacksErrorHandler as C


# Register the errors handled  by us
C.register_codes(dict(
    SAMBA_DOMAIN_WITHOUT_SID=N_("Domain %(target)s has no SID"),
    SAMBA_NO_SID_TYPE=N_("Invalid type '%(type)s' for SID generator [user, group]")
))


class SambaException(Exception):
    pass


class CheckSambaSIDList(ElementComparator):
    """
    Checks whether the given sambaSIDList can be saved or if it
    will produce recursions.
    """
    def __init__(self, obj):
        super(CheckSambaSIDList, self).__init__()
开发者ID:gonicus,项目名称:clacks,代码行数:33,代码来源:sid.py

示例11: AMQPService

# 需要导入模块: from clacks.common.error import ClacksErrorHandler [as 别名]
# 或者: from clacks.common.error.ClacksErrorHandler import register_codes [as 别名]
from qpid.messaging.message import Disposition
from qpid.messaging.constants import RELEASED
from qpid.messaging.exceptions import NotFound
from clacks.common.gjson import loads, dumps
from clacks.common.components.jsonrpc_utils import ServiceRequestNotTranslatable, BadServiceRequest
from clacks.common.handler import IInterfaceHandler
from clacks.common.components import PluginRegistry, AMQPWorker, ZeroconfService
from clacks.common.utils import parseURL, repr2json, N_
from clacks.common import Environment
from clacks.common.error import ClacksErrorHandler as C
from avahi import dict_to_txt_array


# Register the errors handled  by us
C.register_codes(dict(
    AMQP_MESSAGE_WITHOUT_UID=N_("Incoming message has no user_id field"),
    AMQP_BAD_PARAMETERS=N_("Bad parameters - list or dict expected")
    ))


class AMQPService(object):
    """
    Class to serve all available queues and commands to the AMQP broker. It
    makes use of a couple of configuration flags provided by the clacks
    configurations file ``[amqp]`` section:

    ============== =============
    Key            Description
    ============== =============
    url            AMQP URL to connect to the broker
    id             User name to connect with
    key            Password to connect with
开发者ID:gonicus,项目名称:clacks,代码行数:34,代码来源:amqp_service.py

示例12: JSONRPCService

# 需要导入模块: from clacks.common.error import ClacksErrorHandler [as 别名]
# 或者: from clacks.common.error.ClacksErrorHandler import register_codes [as 别名]
from clacks.common.gjson import loads, dumps
from webob import exc, Request, Response #@UnresolvedImport
from paste.auth.cookie import AuthCookieHandler #@UnresolvedImport
from clacks.common.utils import f_print, N_
from clacks.common.error import ClacksErrorHandler as C
from clacks.common.handler import IInterfaceHandler
from clacks.common import Environment
from clacks.common.components import PluginRegistry, ZeroconfService, JSONRPCException
from clacks.agent import __version__ as VERSION
from avahi import dict_to_txt_array


# Register the errors handled  by us
C.register_codes(dict(
    INVALID_JSON=N_("Invalid JSON string '%(data)s'"),
    JSON_MISSING_PARAMETER=N_("Parameter missing in JSON body"),
    PARAMETER_LIST_OR_DICT=N_("Parameter must be list or dictionary"),
    REGISTRY_NOT_READY=N_("Registry is not ready")
    ))


class JSONRPCService(object):
    """
    This is the JSONRPC clacks agent plugin which is registering an
    instance of :class:`clacks.agent.jsonrpc_service.JsonRpcApp` into the
    :class:`clacks.agent.httpd.HTTPService`.

    It is configured thru the ``[jsonrpc]`` section of your clacks
    configuration:

    =============== ============
    Key             Description
开发者ID:gonicus,项目名称:clacks,代码行数:34,代码来源:jsonrpc_service.py

示例13: PasswordException

# 需要导入模块: from clacks.common.error import ClacksErrorHandler [as 别名]
# 或者: from clacks.common.error.ClacksErrorHandler import register_codes [as 别名]
from clacks.common.utils import N_
from zope.interface import implements
from clacks.common.handler import IInterfaceHandler
from clacks.agent.objects.proxy import ObjectProxy
from clacks.common.components import PluginRegistry
from clacks.common import Environment
from clacks.agent.exceptions import ACLException
from clacks.common.error import ClacksErrorHandler as C


# Register the errors handled  by us
C.register_codes(
    dict(
        PASSWORD_METHOD_UNKNOWN=N_("Cannot detect password method"),
        PASSWORD_UNKNOWN_HASH=N_("No password method to generate hash of type '%(type)s' available"),
        PASSWORD_INVALID_HASH=N_("Invalid hash type for password method '%(method)s'"),
        PASSWORD_NO_ATTRIBUTE=N_("Object has no 'userPassword' attribute"),
        PASSWORD_NOT_AVAILABLE=N_("No password to lock."),
    )
)


class PasswordException(Exception):
    pass


class PasswordManager(Plugin):
    """
    Manager password changes
    """
开发者ID:gonicus,项目名称:clacks,代码行数:32,代码来源:manager.py

示例14: ObjectProxy

# 需要导入模块: from clacks.common.error import ClacksErrorHandler [as 别名]
# 或者: from clacks.common.error.ClacksErrorHandler import register_codes [as 别名]
try:
        from cStringIO import StringIO
except ImportError:
        from StringIO import StringIO


# Register the errors handled  by us
C.register_codes(dict(
    OBJECT_UNKNOWN_TYPE=N_("Unknown object type '%(type)s'"),
    OBJECT_EXTENSION_NOT_ALLOWED=N_("Extension '%(extension)s' not allowed"),
    OBJECT_EXTENSION_DEFINED=N_("Extension '%(extension)s' already there"),
    OBJECT_EXTENSION_DEPENDS=N_("Extension '%(extension)s' depends on '%(missing)s'"),
    PERMISSION_EXTEND=N_("No permission to extend %(target)s with %(extension)s"),
    OBJECT_NO_SUCH_EXTENSION=N_("Extension '%(extension)s' already retracted"),
    OBJECT_EXTENSION_IN_USE=N_("Extension '%(extension)s' is required by '%(origin)s'"),
    PERMISSION_RETRACT=N_("No permission to retract '%(extension)s' from '%(target)s'"),
    PERMISSION_MOVE=N_("No permission to move '%(source)s' to '%(target)s'"),
    OBJECT_HAS_CHILDREN=N_("Object '%(target)s' has children"),
    PERMISSION_REMOVE=N_("No permission to remove '%(target)s'"),
    PERMISSION_CREATE=N_("No permission to create '%(target)s'"),
    PERMISSION_ACCESS=N_("No permission to access '%(topic)s' on '%(target)s'"),
    OBJECT_UUID_MISMATCH=N_("UUID of base (%(b_uuid)s) and extension (%(e_uuid)s) differ")
    ))


class ObjectProxy(object):
    _no_pickle_ = True
    dn = None
    uuid = None
    __env = None
    __log = None
开发者ID:lhm-limux,项目名称:clacks,代码行数:33,代码来源:proxy.py

示例15: JSONRPCObjectMapper

# 需要导入模块: from clacks.common.error import ClacksErrorHandler [as 别名]
# 或者: from clacks.common.error.ClacksErrorHandler import register_codes [as 别名]
import datetime
from types import MethodType
from zope.interface import implements
from clacks.common.utils import N_
from clacks.common import Environment
from clacks.common.error import ClacksErrorHandler as C
from clacks.common.handler import IInterfaceHandler
from clacks.common.components import Command, PluginRegistry, ObjectRegistry, AMQPServiceProxy, Plugin
from clacks.agent.objects import ObjectProxy


# Register the errors handled  by us
C.register_codes(dict(
    REFERENCE_NOT_FOUND=N_("Reference '%(ref)s' not found"),
    PROPERTY_NOT_FOUND=N_("Property '%(property)s' not found"),
    METHOD_NOT_FOUND=N_("Method '%(method)s' not found"),
    OBJECT_LOCKED=N_("Object '%(object)s' has been locked by '%(user)s' on %(when)s"),
    OID_NOT_FOUND=N_("Object OID '%(oid)s' not found"),
    NOT_OBJECT_OWNER=N_("Caller does not own the referenced object")
    ))


class JSONRPCObjectMapper(Plugin):
    """
    The *JSONRPCObjectMapper* is a clacks agent plugin that implements a stack
    which can handle object instances. These can be passed via JSONRPC using
    the *__jsonclass__* helper attribute and allows remote proxies to emulate
    the object on the stack. The stack can hold objects that have been
    retrieved by their *OID* using the :class:`clacks.common.components.objects.ObjectRegistry`.

    Example::
开发者ID:gonicus,项目名称:clacks,代码行数:33,代码来源:jsonrpc_objects.py


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