當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。