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


Python reflection.get_class_name方法代码示例

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


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

示例1: update_capabilities

# 需要导入模块: from oslo_utils import reflection [as 别名]
# 或者: from oslo_utils.reflection import get_class_name [as 别名]
def update_capabilities(self):
        """
        Update dynamic storage capabilities based on current
        driver configuration and backend status when needed.

        As a hook, the function will be triggered in two cases:
        calling once after store driver get configured, it was
        used to update dynamic storage capabilities based on
        current driver configuration, or calling when the
        capabilities checking of an operation failed every time,
        this was used to refresh dynamic storage capabilities
        based on backend status then.

        This function shouldn't raise any exception out.
        """
        LOG.debug(("Store %s doesn't support updating dynamic "
                   "storage capabilities. Please overwrite "
                   "'update_capabilities' method of the store to "
                   "implement updating logics if needed.") %
                  reflection.get_class_name(self)) 
开发者ID:openstack,项目名称:glance_store,代码行数:22,代码来源:capabilities.py

示例2: validate

# 需要导入模块: from oslo_utils import reflection [as 别名]
# 或者: from oslo_utils.reflection import get_class_name [as 别名]
def validate(cls, data, response):
        if response:
            schema = cls.RESPONSE_SCHEMA
        else:
            schema = cls.SENDER_SCHEMA
        try:
            su.schema_validate(data, schema)
        except su.ValidationError as e:
            cls_name = reflection.get_class_name(cls, fully_qualified=False)
            if response:
                excp.raise_with_cause(excp.InvalidFormat,
                                      "%s message response data not of the"
                                      " expected format: %s" % (cls_name,
                                                                e.message),
                                      cause=e)
            else:
                excp.raise_with_cause(excp.InvalidFormat,
                                      "%s message sender data not of the"
                                      " expected format: %s" % (cls_name,
                                                                e.message),
                                      cause=e) 
开发者ID:openstack,项目名称:taskflow,代码行数:23,代码来源:protocol.py

示例3: to_dict

# 需要导入模块: from oslo_utils import reflection [as 别名]
# 或者: from oslo_utils.reflection import get_class_name [as 别名]
def to_dict(self):
        """Return json-serializable request.

        To convert requests that have failed due to some exception this will
        convert all `failure.Failure` objects into dictionaries (which will
        then be reconstituted by the receiver).
        """
        request = {
            'task_cls': reflection.get_class_name(self.task),
            'task_name': self.task.name,
            'task_version': self.task.version,
            'action': self._action,
            'arguments': self._arguments,
        }
        if self._result is not NO_RESULT:
            result = self._result
            if isinstance(result, ft.Failure):
                request['result'] = ('failure', failure_to_dict(result))
            else:
                request['result'] = ('success', result)
        if self._failures:
            request['failures'] = {}
            for atom_name, failure in six.iteritems(self._failures):
                request['failures'][atom_name] = failure_to_dict(failure)
        return request 
开发者ID:openstack,项目名称:taskflow,代码行数:27,代码来源:protocol.py

示例4: _atomdetail_by_name

# 需要导入模块: from oslo_utils import reflection [as 别名]
# 或者: from oslo_utils.reflection import get_class_name [as 别名]
def _atomdetail_by_name(self, atom_name, expected_type=None, clone=False):
        try:
            ad = self._flowdetail.find(self._atom_name_to_uuid[atom_name])
        except KeyError:
            exceptions.raise_with_cause(exceptions.NotFound,
                                        "Unknown atom name '%s'" % atom_name)
        else:
            # TODO(harlowja): we need to figure out how to get away from doing
            # these kinds of type checks in general (since they likely mean
            # we aren't doing something right).
            if expected_type and not isinstance(ad, expected_type):
                raise TypeError("Atom '%s' is not of the expected type: %s"
                                % (atom_name,
                                   reflection.get_class_name(expected_type)))
            if clone:
                return (ad, ad.copy())
            else:
                return (ad, ad) 
开发者ID:openstack,项目名称:taskflow,代码行数:20,代码来源:storage.py

示例5: prettify_failures

# 需要导入模块: from oslo_utils import reflection [as 别名]
# 或者: from oslo_utils.reflection import get_class_name [as 别名]
def prettify_failures(failures, limit=-1):
    """Prettifies a checked commits failures (ignores sensitive data...)."""
    prettier = []
    for (op, r) in failures:
        pretty_op = reflection.get_class_name(op, fully_qualified=False)
        # Pick off a few attributes that are meaningful (but one that don't
        # show actual data, which might not be desired to show...).
        selected_attrs = [
            "path=%r" % op.path,
        ]
        try:
            if op.version != -1:
                selected_attrs.append("version=%s" % op.version)
        except AttributeError:
            pass
        pretty_op += "(%s)" % (", ".join(selected_attrs))
        pretty_cause = reflection.get_class_name(r, fully_qualified=False)
        prettier.append("%s@%s" % (pretty_cause, pretty_op))
    if limit <= 0 or len(prettier) <= limit:
        return ", ".join(prettier)
    else:
        leftover = prettier[limit:]
        prettier = prettier[0:limit]
        return ", ".join(prettier) + " and %s more..." % len(leftover) 
开发者ID:openstack,项目名称:taskflow,代码行数:26,代码来源:kazoo_utils.py

示例6: check

# 需要导入模块: from oslo_utils import reflection [as 别名]
# 或者: from oslo_utils.reflection import get_class_name [as 别名]
def check(self, *exc_classes):
        """Check if any of ``exc_classes`` caused the failure.

        Arguments of this method can be exception types or type
        names (stings). If captured exception is instance of
        exception of given type, the corresponding argument is
        returned. Else, None is returned.
        """
        for cls in exc_classes:
            if isinstance(cls, type):
                err = reflection.get_class_name(cls)
            else:
                err = cls
            if err in self._exc_type_names:
                return cls
        return None 
开发者ID:openstack,项目名称:taskflow,代码行数:18,代码来源:failure.py

示例7: handle_error

# 需要导入模块: from oslo_utils import reflection [as 别名]
# 或者: from oslo_utils.reflection import get_class_name [as 别名]
def handle_error(exception_context):
    """Handle SQLAlchemy errors"""
    exception_class_name = reflection.get_class_name(
        exception_context.original_exception)
    original_exception = str(exception_context.original_exception)
    chained_exception = str(exception_context.chained_exception)

    info = {
        "etype": exception_class_name,
        "message": original_exception,
        "db": {
            "original_exception": original_exception,
            "chained_exception": chained_exception
        }
    }
    profiler.stop(info=info)
    LOG.debug("OSProfiler has handled SQLAlchemy error: %s",
              original_exception) 
开发者ID:openstack,项目名称:osprofiler,代码行数:20,代码来源:sqlalchemy.py

示例8: __repr__

# 需要导入模块: from oslo_utils import reflection [as 别名]
# 或者: from oslo_utils.reflection import get_class_name [as 别名]
def __repr__(self):
        reprkeys = sorted(k
                          for k in self.__dict__.keys()
                          if k[0] != '_' and k != 'manager')
        info = ", ".join("%s=%s" % (k, getattr(self, k)) for k in reprkeys)
        class_name = reflection.get_class_name(self, fully_qualified=False)
        return "<%s %s>" % (class_name, info) 
开发者ID:nttcom,项目名称:eclcli,代码行数:9,代码来源:base.py

示例9: __str__

# 需要导入模块: from oslo_utils import reflection [as 别名]
# 或者: from oslo_utils.reflection import get_class_name [as 别名]
def __str__(self):
        self.details = _("Requested version of Heat API is not"
                         "available.")
        return (_("%(name)s (HTTP %(code)s) %(details)s") %
                {
                'name': reflection.get_class_name(self, fully_qualified=False),
                'code': self.code,
                'details': self.details}) 
开发者ID:nttcom,项目名称:eclcli,代码行数:10,代码来源:exc.py

示例10: run_periodic_tasks

# 需要导入模块: from oslo_utils import reflection [as 别名]
# 或者: from oslo_utils.reflection import get_class_name [as 别名]
def run_periodic_tasks(self, context, raise_on_error=False):
        """Tasks to be run at a periodic interval."""
        idle_for = DEFAULT_INTERVAL
        for task_name, task in self._periodic_tasks:
            if (task._periodic_external_ok and not
               self.conf.run_external_periodic_tasks):
                continue
            cls_name = reflection.get_class_name(self, fully_qualified=False)
            full_task_name = '.'.join([cls_name, task_name])

            spacing = self._periodic_spacing[task_name]
            last_run = self._periodic_last_run[task_name]

            # Check if due, if not skip
            idle_for = min(idle_for, spacing)
            if last_run is not None:
                delta = last_run + spacing - now()
                if delta > 0:
                    idle_for = min(idle_for, delta)
                    continue

            LOG.debug("Running periodic task %(full_task_name)s",
                      {"full_task_name": full_task_name})
            self._periodic_last_run[task_name] = _nearest_boundary(
                last_run, spacing)

            try:
                task(self, context)
            except BaseException:
                if raise_on_error:
                    raise
                LOG.exception("Error during %(full_task_name)s",
                              {"full_task_name": full_task_name})
            time.sleep(0)

        return idle_for 
开发者ID:openstack,项目名称:oslo.service,代码行数:38,代码来源:periodic_task.py

示例11: _make_json_response

# 需要导入模块: from oslo_utils import reflection [as 别名]
# 或者: from oslo_utils.reflection import get_class_name [as 别名]
def _make_json_response(self, results, healthy):
        if self._show_details:
            body = {
                'detailed': True,
                'python_version': sys.version,
                'now': str(timeutils.utcnow()),
                'platform': platform.platform(),
                'gc': {
                    'counts': gc.get_count(),
                    'threshold': gc.get_threshold(),
                },
            }
            reasons = []
            for result in results:
                reasons.append({
                    'reason': result.reason,
                    'details': result.details or '',
                    'class': reflection.get_class_name(result,
                                                       fully_qualified=False),
                })
            body['reasons'] = reasons
            body['greenthreads'] = self._get_greenstacks()
            body['threads'] = self._get_threadstacks()
        else:
            body = {
                'reasons': [result.reason for result in results],
                'detailed': False,
            }
        return (self._pretty_json_dumps(body), 'application/json') 
开发者ID:openstack,项目名称:oslo.middleware,代码行数:31,代码来源:__init__.py

示例12: _make_html_response

# 需要导入模块: from oslo_utils import reflection [as 别名]
# 或者: from oslo_utils.reflection import get_class_name [as 别名]
def _make_html_response(self, results, healthy):
        try:
            hostname = socket.gethostname()
        except socket.error:
            hostname = None
        translated_results = []
        for result in results:
            translated_results.append({
                'details': result.details or '',
                'reason': result.reason,
                'class': reflection.get_class_name(result,
                                                   fully_qualified=False),
            })
        params = {
            'healthy': healthy,
            'hostname': hostname,
            'results': translated_results,
            'detailed': self._show_details,
            'now': str(timeutils.utcnow()),
            'python_version': sys.version,
            'platform': platform.platform(),
            'gc': {
                'counts': gc.get_count(),
                'threshold': gc.get_threshold(),
             },
             'threads': self._get_threadstacks(),
             'greenthreads': self._get_threadstacks(),
        }
        body = _expand_template(self.HTML_RESPONSE_TEMPLATE, params)
        return (body.strip(), 'text/html') 
开发者ID:openstack,项目名称:oslo.middleware,代码行数:32,代码来源:__init__.py

示例13: __str__

# 需要导入模块: from oslo_utils import reflection [as 别名]
# 或者: from oslo_utils.reflection import get_class_name [as 别名]
def __str__(self):
        base = reflection.get_class_name(self, fully_qualified=False)
        if self.strategy is not None:
            strategy_name = self.strategy.name
        else:
            strategy_name = "???"
        return base + "(strategy=%s)" % (strategy_name) 
开发者ID:openstack,项目名称:taskflow,代码行数:9,代码来源:completer.py

示例14: banner

# 需要导入模块: from oslo_utils import reflection [as 别名]
# 或者: from oslo_utils.reflection import get_class_name [as 别名]
def banner(self):
        """A banner that can be useful to display before running."""
        connection_details = self._server.connection_details
        transport = connection_details.transport
        if transport.driver_version:
            transport_driver = "%s v%s" % (transport.driver_name,
                                           transport.driver_version)
        else:
            transport_driver = transport.driver_name
        try:
            hostname = socket.getfqdn()
        except socket.error:
            hostname = "???"
        try:
            pid = os.getpid()
        except OSError:
            pid = "???"
        chapters = {
            'Connection details': {
                'Driver': transport_driver,
                'Exchange': self._exchange,
                'Topic': self._topic,
                'Transport': transport.driver_type,
                'Uri': connection_details.uri,
            },
            'Powered by': {
                'Executor': reflection.get_class_name(self._executor),
                'Thread count': getattr(self._executor, 'max_workers', "???"),
            },
            'Supported endpoints': [str(ep) for ep in self._endpoints],
            'System details': {
                'Hostname': hostname,
                'Pid': pid,
                'Platform': platform.platform(),
                'Python': sys.version.split("\n", 1)[0].strip(),
                'Thread id': tu.get_ident(),
            },
        }
        return banner.make_banner('WBE worker', chapters) 
开发者ID:openstack,项目名称:taskflow,代码行数:41,代码来源:worker.py

示例15: __init__

# 需要导入模块: from oslo_utils import reflection [as 别名]
# 或者: from oslo_utils.reflection import get_class_name [as 别名]
def __init__(self, task_cls):
        self._task_cls = task_cls
        self._task_cls_name = reflection.get_class_name(task_cls)
        self._executor = executor.SerialTaskExecutor() 
开发者ID:openstack,项目名称:taskflow,代码行数:6,代码来源:endpoint.py


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