• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python _i18n._函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: execute

    def execute(self):
        LOG.info(_LI("Starting purge command"))
        self._objects_map = self.find_objects_to_delete()

        if (self.max_number is not None and
                len(self._objects_map) > self.max_number):
            if self.delete_up_to_max_prompt(self._objects_map):
                self._objects_map = self._get_objects_up_to_limit()
            else:
                return

        _orphans_note = (_(" (orphans excluded)") if self.exclude_orphans
                         else _(" (may include orphans)"))
        if not self.dry_run and self.confirmation_prompt():
            self.do_delete()
            print(_("Purge results summary%s:") % _orphans_note)
            LOG.info(_LI("Purge results summary%s:"), _orphans_note)
        else:
            LOG.debug(self._objects_map)
            print(_("Here below is a table containing the objects "
                    "that can be purged%s:") % _orphans_note)

        LOG.info("\n%s", self._objects_map.get_count_table())
        print(self._objects_map.get_count_table())
        LOG.info(_LI("Purge process completed"))
开发者ID:Jean-Emile,项目名称:watcher,代码行数:25,代码来源:purge.py


示例2: post

    def post(self, audit_p):
        """Create a new audit.

        :param audit_p: a audit within the request body.
        """
        context = pecan.request.context
        policy.enforce(context, 'audit:create',
                       action='audit:create')

        audit = audit_p.as_audit()
        if self.from_audits:
            raise exception.OperationNotPermitted

        if not audit._audit_template_uuid:
            raise exception.Invalid(
                message=_('The audit template UUID or name specified is '
                          'invalid'))

        audit_template = objects.AuditTemplate.get(pecan.request.context,
                                                   audit._audit_template_uuid)
        strategy_id = audit_template.strategy_id
        no_schema = True
        if strategy_id is not None:
            # validate parameter when predefined strategy in audit template
            strategy = objects.Strategy.get(pecan.request.context, strategy_id)
            schema = strategy.parameters_spec
            if schema:
                # validate input parameter with default value feedback
                no_schema = False
                utils.DefaultValidatingDraft4Validator(schema).validate(
                    audit.parameters)

        if no_schema and audit.parameters:
            raise exception.Invalid(_('Specify parameters but no predefined '
                                      'strategy for audit template, or no '
                                      'parameter spec in predefined strategy'))

        audit_dict = audit.as_dict()
        context = pecan.request.context
        new_audit = objects.Audit(context, **audit_dict)
        new_audit.create(context)

        # Set the HTTP Location Header
        pecan.response.location = link.build_url('audits', new_audit.uuid)

        # trigger decision-engine to run the audit

        if new_audit.audit_type == objects.audit.AuditType.ONESHOT.value:
            dc_client = rpcapi.DecisionEngineAPI()
            dc_client.trigger_audit(context, new_audit.uuid)

        return Audit.convert_with_links(new_audit)
开发者ID:Oliverlyn,项目名称:watcher,代码行数:52,代码来源:audit.py


示例3: delete_up_to_max_prompt

    def delete_up_to_max_prompt(self, objects_map):
        print(objects_map.get_count_table())
        print(_("The number of objects (%(num)s) to delete from the database "
                "exceeds the maximum number of objects (%(max_number)s) "
                "specified.") % dict(max_number=self.max_number,
                                     num=len(objects_map)))
        raw_val = input(
            _("Do you want to delete objects up to the specified maximum "
              "number? [y/N]"))

        self._delete_up_to_max = strutils.bool_from_string(raw_val)

        return self._delete_up_to_max
开发者ID:Jean-Emile,项目名称:watcher,代码行数:13,代码来源:purge.py


示例4: select

    def select(self):
        """Selects a strategy

        :raises: :py:class:`~.LoadingError` if it failed to load a strategy
        :returns: A :py:class:`~.BaseStrategy` instance
        """
        strategy_to_load = None
        try:
            if self.strategy_name:
                strategy_to_load = self.strategy_name
            else:
                available_strategies = self.strategy_loader.list_available()
                available_strategies_for_goal = list(
                    key for key, strat in available_strategies.items()
                    if strat.get_goal_name() == self.goal_name)

                if not available_strategies_for_goal:
                    raise exception.NoAvailableStrategyForGoal(
                        goal=self.goal_name)

                # TODO(v-francoise): We should do some more work here to select
                # a strategy out of a given goal instead of just choosing the
                # 1st one
                strategy_to_load = available_strategies_for_goal[0]
            return self.strategy_loader.load(strategy_to_load, osc=self.osc)
        except exception.NoAvailableStrategyForGoal:
            raise
        except Exception as exc:
            LOG.exception(exc)
            raise exception.LoadingError(
                _("Could not load any strategy for goal %(goal)s"),
                goal=self.goal_name)
开发者ID:Oliverlyn,项目名称:watcher,代码行数:32,代码来源:default.py


示例5: update_action_plan

    def update_action_plan(self, action_plan_id, values):
        if 'uuid' in values:
            raise exception.Invalid(
                message=_("Cannot overwrite UUID for an existing "
                          "Action Plan."))

        return self._do_update_action_plan(action_plan_id, values)
开发者ID:j-carpentier,项目名称:watcher,代码行数:7,代码来源:api.py


示例6: get_count_table

 def get_count_table(self):
     headers = list(self.keymap.values())
     headers.append(_("Total"))  # We also add a total count
     counters = [len(cat_vals) for cat_vals in self.values()] + [len(self)]
     table = ptable.PrettyTable(field_names=headers)
     table.add_row(counters)
     return table.get_string()
开发者ID:Jean-Emile,项目名称:watcher,代码行数:7,代码来源:purge.py


示例7: save

    def save(self, context):
        """Save the changed fields back to the store.

        This is optional for subclasses, but is presented here in the base
        class for consistency among those that do.
        """
        raise NotImplementedError(_("Cannot save anything in the base class"))
开发者ID:Jean-Emile,项目名称:watcher,代码行数:7,代码来源:base.py


示例8: validate

 def validate(value):
     try:
         json.dumps(value)
     except TypeError:
         raise exception.Invalid(_('%s is not JSON serializable') % value)
     else:
         return value
开发者ID:Oliverlyn,项目名称:watcher,代码行数:7,代码来源:types.py


示例9: patch

    def patch(self, action_uuid, patch):
        """Update an existing action.

        :param action_uuid: UUID of a action.
        :param patch: a json PATCH document to apply to this action.
        """
        # FIXME: blueprint edit-action-plan-flow
        raise exception.OperationNotPermitted(
            _("Cannot modify an action directly"))

        if self.from_actions:
            raise exception.OperationNotPermitted

        action_to_update = objects.Action.get_by_uuid(pecan.request.context,
                                                      action_uuid)
        try:
            action_dict = action_to_update.as_dict()
            action = Action(**api_utils.apply_jsonpatch(action_dict, patch))
        except api_utils.JSONPATCH_EXCEPTIONS as e:
            raise exception.PatchError(patch=patch, reason=e)

        # Update only the fields that have changed
        for field in objects.Action.fields:
            try:
                patch_val = getattr(action, field)
            except AttributeError:
                # Ignore fields that aren't exposed in the API
                continue
            if patch_val == wtypes.Unset:
                patch_val = None
            if action_to_update[field] != patch_val:
                action_to_update[field] = patch_val

        action_to_update.save()
        return Action.convert_with_links(action_to_update)
开发者ID:j-carpentier,项目名称:watcher,代码行数:35,代码来源:action.py


示例10: post

    def post(self, audit):
        """Create a new audit.

        :param audit: a audit within the request body.
        """
        if self.from_audits:
            raise exception.OperationNotPermitted

        if not audit._audit_template_uuid:
            raise exception.Invalid(
                message=_('The audit template UUID or name specified is '
                          'invalid'))

        audit_dict = audit.as_dict()
        context = pecan.request.context
        new_audit = objects.Audit(context, **audit_dict)
        new_audit.create(context)

        # Set the HTTP Location Header
        pecan.response.location = link.build_url('audits', new_audit.uuid)

        # trigger decision-engine to run the audit

        dc_client = rpcapi.DecisionEngineAPI()
        dc_client.trigger_audit(context, new_audit.uuid)

        return Audit.convert_with_links(new_audit)
开发者ID:XroLLla,项目名称:watcher,代码行数:27,代码来源:audit.py


示例11: confirmation_prompt

    def confirmation_prompt(self):
        print(self._objects_map.get_count_table())
        raw_val = input(
            _("There are %(count)d objects set for deletion. "
              "Continue? [y/N]") % dict(count=len(self._objects_map)))

        return strutils.bool_from_string(raw_val)
开发者ID:Jean-Emile,项目名称:watcher,代码行数:7,代码来源:purge.py


示例12: validate_search_filters

def validate_search_filters(filters, allowed_fields):
    # Very leightweight validation for now
    # todo: improve this (e.g. https://www.parse.com/docs/rest/guide/#queries)
    for filter_name in filters.keys():
        if filter_name not in allowed_fields:
            raise wsme.exc.ClientSideError(
                _("Invalid filter: %s") % filter_name)
开发者ID:Oliverlyn,项目名称:watcher,代码行数:7,代码来源:utils.py


示例13: update_action

    def update_action(self, action_id, values):
        # NOTE(dtantsur): this can lead to very strange errors
        if 'uuid' in values:
            raise exception.Invalid(
                message=_("Cannot overwrite UUID for an existing "
                          "Action."))

        return self._do_update_action(action_id, values)
开发者ID:j-carpentier,项目名称:watcher,代码行数:8,代码来源:api.py


示例14: __init__

 def __init__(self):
     super(MigrationEfficacy, self).__init__(
         name="migration_efficacy",
         description=_("Represents the percentage of released nodes out of "
                       "the total number of migrations."),
         unit="%",
         required=True
     )
开发者ID:j-carpentier,项目名称:watcher,代码行数:8,代码来源:indicators.py


示例15: apply_jsonpatch

def apply_jsonpatch(doc, patch):
    for p in patch:
        if p['op'] == 'add' and p['path'].count('/') == 1:
            if p['path'].lstrip('/') not in doc:
                msg = _('Adding a new attribute (%s) to the root of '
                        ' the resource is not allowed')
                raise wsme.exc.ClientSideError(msg % p['path'])
    return jsonpatch.apply_patch(doc, jsonpatch.JsonPatch(patch))
开发者ID:Oliverlyn,项目名称:watcher,代码行数:8,代码来源:utils.py


示例16: validate

 def validate(patch):
     serialized_patch = {'path': patch.path, 'op': patch.op}
     if patch.path in AuditPatchType.mandatory_attrs():
         msg = _("%(field)s can't be updated.")
         raise exception.PatchError(
             patch=serialized_patch,
             reason=msg % dict(field=patch.path))
     return types.JsonPatchType.validate(patch)
开发者ID:Oliverlyn,项目名称:watcher,代码行数:8,代码来源:audit.py


示例17: obj_load_attr

    def obj_load_attr(self, attrname):
        """Load an additional attribute from the real object.

        This should use self._conductor, and cache any data that might
        be useful for future load operations.
        """
        raise NotImplementedError(
            _("Cannot load '%(attrname)s' in the base class") %
            {'attrname': attrname})
开发者ID:Jean-Emile,项目名称:watcher,代码行数:9,代码来源:base.py


示例18: update_strategy

    def update_strategy(self, strategy_id, values):
        if 'uuid' in values:
            raise exception.Invalid(
                message=_("Cannot overwrite UUID for an existing Strategy."))

        try:
            return self._update(models.Strategy, strategy_id, values)
        except exception.ResourceNotFound:
            raise exception.StrategyNotFound(strategy=strategy_id)
开发者ID:j-carpentier,项目名称:watcher,代码行数:9,代码来源:api.py


示例19: update_goal

    def update_goal(self, goal_id, values):
        if 'uuid' in values:
            raise exception.Invalid(
                message=_("Cannot overwrite UUID for an existing Goal."))

        try:
            return self._update(models.Goal, goal_id, values)
        except exception.ResourceNotFound:
            raise exception.GoalNotFound(goal=goal_id)
开发者ID:j-carpentier,项目名称:watcher,代码行数:9,代码来源:api.py


示例20: update_audit

    def update_audit(self, audit_id, values):
        if 'uuid' in values:
            raise exception.Invalid(
                message=_("Cannot overwrite UUID for an existing "
                          "Audit."))

        try:
            return self._update(models.Audit, audit_id, values)
        except exception.ResourceNotFound:
            raise exception.AuditNotFound(audit=audit_id)
开发者ID:j-carpentier,项目名称:watcher,代码行数:10,代码来源:api.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python _i18n._LI函数代码示例发布时间:2022-05-26
下一篇:
Python platform.is_linux函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap