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

Python i18n._LE函数代码示例

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

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



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

示例1: main

def main():
    test_runner = MuranoTestRunner()
    try:
        if test_runner.args.config_file:
            default_config_files = [test_runner.args.config_file]
        else:
            default_config_files = cfg.find_config_files('murano')
            if not default_config_files:
                murano_conf = os.path.join(os.path.dirname(__file__),
                                           os.pardir,
                                           os.pardir,
                                           'etc', 'murano',
                                           'murano.conf')
                if os.path.exists(murano_conf):
                    default_config_files = [murano_conf]
        sys.argv = [sys.argv[0]]
        config.parse_args(default_config_files=default_config_files)
        logging.setup(CONF, 'murano')
    except RuntimeError as e:
        LOG.exception(_LE("Failed to initialize murano-test-runner: %s") % e)
        sys.exit("ERROR: %s" % e)

    try:
        exit_code = test_runner.run_tests()
        sys.exit(exit_code)
    except Exception as e:
        tb = traceback.format_exc()
        err_msg = _LE("Command failed: {0}\n{1}").format(e, tb)
        LOG.error(err_msg)
        sys.exit(err_msg)
开发者ID:GovardhanSN,项目名称:murano,代码行数:30,代码来源:test_runner.py


示例2: verify_and_get_deployment

def verify_and_get_deployment(db_session, environment_id, deployment_id):
    deployment = db_session.query(models.Task).get(deployment_id)
    if not deployment:
        LOG.error(_LE('Deployment with id {id} not found')
                  .format(id=deployment_id))
        raise exc.HTTPNotFound
    if deployment.environment_id != environment_id:
        LOG.error(_LE('Deployment with id {d_id} not found in environment '
                      '{env_id}').format(d_id=deployment_id,
                                         env_id=environment_id))
        raise exc.HTTPBadRequest

    deployment.description = _patch_description(deployment.description)
    return deployment
开发者ID:hybrid-murano,项目名称:murano-mitaka,代码行数:14,代码来源:deployments.py


示例3: __inner

    def __inner(self, request, env_template_id, *args, **kwargs):
        unit = db_session.get_session()
        template = unit.query(models.EnvironmentTemplate).get(env_template_id)
        if template is None:
            LOG.error(_LE("Environment Template with id '{id}' not found").
                      format(id=env_template_id))
            raise exc.HTTPNotFound()

        if hasattr(request, 'context'):
            if template.tenant_id != request.context.tenant:
                LOG.error(_LE('User is not authorized to access '
                              'this tenant resources'))
                raise exc.HTTPUnauthorized()

        return func(self, request, env_template_id, *args, **kwargs)
开发者ID:tianshangjun,项目名称:murano,代码行数:15,代码来源:utils.py


示例4: _validate_keystone_opts

    def _validate_keystone_opts(self, args):
        ks_opts_to_config = {
            'auth_url': 'auth_uri',
            'username': 'admin_user',
            'password': 'admin_password',
            'project_name': 'admin_tenant_name'}

        ks_opts = {'auth_url': getattr(args, 'os_auth_url', None),
                   'username': getattr(args, 'os_username', None),
                   'password': getattr(args, 'os_password', None),
                   'project_name': getattr(args, 'os_project_name', None)}

        if None in ks_opts.values() and not CONF.default_config_files:
            msg = _LE('Please provide murano config file or credentials for '
                      'authorization: {0}').format(
                ', '.join(['--os-auth-url', '--os-username', '--os-password',
                           '--os-project-name', '--os-tenant-id']))
            LOG.error(msg)
            self.error(msg)
        # Load keystone configuration parameters from config
        importutils.import_module('keystonemiddleware.auth_token')

        for param, value in six.iteritems(ks_opts):
            if not value:
                ks_opts[param] = getattr(CONF.keystone_authtoken,
                                         ks_opts_to_config[param])
            if param == 'auth_url':
                ks_opts[param] = ks_opts[param].replace('v2.0', 'v3')
        return ks_opts
开发者ID:GovardhanSN,项目名称:murano,代码行数:29,代码来源:test_runner.py


示例5: finish

 def finish(self):
     for delegate in self._tear_down_list:
         try:
             delegate()
         except Exception:
             LOG.exception(_LE("Unhandled exception on invocation of " "post-execution hook"))
     self._tear_down_list = []
开发者ID:swevm,项目名称:murano,代码行数:7,代码来源:environment.py


示例6: start

 def start(self):
     for delegate in self._set_up_list:
         try:
             delegate()
         except Exception:
             LOG.exception(_LE("Unhandled exception on invocation of " "pre-execution hook"))
     self._set_up_list = []
开发者ID:swevm,项目名称:murano,代码行数:7,代码来源:environment.py


示例7: _check_enabled

    def _check_enabled(self):
        if CONF.engine.disable_murano_agent:
            LOG.error(_LE("Use of murano-agent is disallowed " "by the server configuration"))

            raise exceptions.PolicyViolationException(
                "Use of murano-agent is disallowed " "by the server configuration"
            )
开发者ID:NeCTAR-RC,项目名称:murano,代码行数:7,代码来源:agent_listener.py


示例8: _migrate_up

    def _migrate_up(self, engine, version, with_data=False):
        """Migrate up to a new version of the db.

        We allow for data insertion and post checks at every
        migration version with special _pre_upgrade_### and
        _check_### functions in the main test.
        """
        # NOTE(sdague): try block is here because it's impossible to debug
        # where a failed data migration happens otherwise
        check_version = version
        try:
            if with_data:
                data = None
                pre_upgrade = getattr(
                    self, "_pre_upgrade_%s" % check_version, None)
                if pre_upgrade:
                    data = pre_upgrade(engine)
            self._migrate(engine, version, 'upgrade')
            self.assertEqual(version, self._get_version_from_db(engine))
            if with_data:
                check = getattr(self, "_check_%s" % check_version, None)
                if check:
                    check(engine, data)
        except Exception:
            LOG.error(_LE("Failed to migrate to version {ver} on engine {eng}")
                      .format(ver=version, eng=engine))
            raise
开发者ID:AleptNamrata,项目名称:murano,代码行数:27,代码来源:test_migrations_base.py


示例9: _validate_change

    def _validate_change(self, change):
        change_path = change['path'][0]
        change_op = change['op']
        allowed_methods = self.allowed_operations.get(change_path)

        if not allowed_methods:
            msg = _("Attribute '{0}' is invalid").format(change_path)
            raise webob.exc.HTTPForbidden(explanation=six.text_type(msg))

        if change_op not in allowed_methods:
            msg = _("Method '{method}' is not allowed for a path with name "
                    "'{name}'. Allowed operations are: "
                    "'{ops}'").format(method=change_op,
                                      name=change_path,
                                      ops=', '.join(allowed_methods))

            raise webob.exc.HTTPForbidden(explanation=six.text_type(msg))

        property_to_update = {change_path: change['value']}

        try:
            jsonschema.validate(property_to_update, schemas.PKG_UPDATE_SCHEMA)
        except jsonschema.ValidationError as e:
            LOG.error(_LE("Schema validation error occured: {error}")
                      .format(error=e))
            raise webob.exc.HTTPBadRequest(explanation=e.message)
开发者ID:Aqsamm,项目名称:murano,代码行数:26,代码来源:wsgi.py


示例10: clone

    def clone(self, request, env_template_id, body):
        """Clones env template from another tenant

        It clones the env template from another env template
        from other tenant.
        :param request: the operation request.
        :param env_template_id: the env template ID.
        :param body: the request body.
        :return: the description of the created template.
        """

        LOG.debug('EnvTemplates:Clone <Env Template {0} for body {1}>'.
                  format(body, env_template_id))
        policy.check('clone_env_template', request.context)

        old_env_template = self._validate_exists(env_template_id)

        if not old_env_template.get('is_public'):
            msg = _LE('User has no access to these resources.')
            LOG.error(msg)
            raise exc.HTTPForbidden(explanation=msg)
        self._validate_body_name(body)
        LOG.debug('ENV TEMP NAME: {0}'.format(body['name']))

        try:
            is_public = body.get('is_public', False)
            template = env_temps.EnvTemplateServices.clone(
                env_template_id, request.context.tenant, body['name'],
                is_public)
        except db_exc.DBDuplicateEntry:
            msg = _('Environment with specified name already exists')
            LOG.error(msg)
            raise exc.HTTPConflict(explanation=msg)

        return template.to_dict()
开发者ID:AleptNamrata,项目名称:murano,代码行数:35,代码来源:templates.py


示例11: execute

    def execute(self, request, environment_id, action_id, body):
        policy.check("execute_action", request.context, {})

        LOG.debug("Action:Execute <ActionId: {0}>".format(action_id))

        unit = db_session.get_session()

        # no new session can be opened if environment has deploying status
        env_status = envs.EnvironmentServices.get_status(environment_id)
        if env_status in (states.EnvironmentStatus.DEPLOYING, states.EnvironmentStatus.DELETING):
            LOG.info(
                _LI(
                    "Could not open session for environment <EnvId: {0}>," "environment has deploying " "status."
                ).format(environment_id)
            )
            raise exc.HTTPForbidden()

        user_id = request.context.user
        session = sessions.SessionServices.create(environment_id, user_id)

        if not sessions.SessionServices.validate(session):
            LOG.error(_LE("Session <SessionId {0}> " "is invalid").format(session.id))
            raise exc.HTTPForbidden()

        task_id = actions.ActionServices.execute(action_id, session, unit, request.context.auth_token, body or {})
        return {"task_id": task_id}
开发者ID:sajuptpm,项目名称:murano,代码行数:26,代码来源:actions.py


示例12: main

def main():
    CONF.register_cli_opt(command_opt)

    try:
        default_config_files = cfg.find_config_files('murano', 'murano')
        CONF(sys.argv[1:], project='murano', prog='murano-manage',
             version=version.version_string,
             default_config_files=default_config_files)
    except RuntimeError as e:
        LOG.error(_LE("failed to initialize murano-manage: %s") % e)
        sys.exit("ERROR: %s" % e)

    try:
        CONF.command.func()
    except Exception as e:
        tb = traceback.format_exc()
        err_msg = _LE("murano-manage command failed: {0}\n{1}").format(e, tb)
        LOG.error(err_msg)
        sys.exit(err_msg)
开发者ID:hybrid-murano,项目名称:hybrid-murano,代码行数:19,代码来源:manage.py


示例13: _validate_request

 def _validate_request(self, request, env_template_id):
     self._validate_exists(env_template_id)
     get_env_template = env_temps.EnvTemplateServices.get_env_template
     env_template = get_env_template(env_template_id)
     if env_template.is_public or request.context.is_admin:
         return
     if env_template.tenant_id != request.context.tenant:
         msg = _LE('User has no access to these resources.')
         LOG.error(msg)
         raise exc.HTTPForbidden(explanation=msg)
开发者ID:AleptNamrata,项目名称:murano,代码行数:10,代码来源:templates.py


示例14: _parse_format_string

 def _parse_format_string(format_string):
     parts = format_string.rsplit('/', 1)
     if len(parts) != 2:
         LOG.error(_LE("Incorrect format name {name}").format(
             name=format_string))
         raise ValueError(format_string)
     return (
         parts[0].strip(),
         semantic_version.Version.coerce(parts[1])
     )
开发者ID:AleptNamrata,项目名称:murano,代码行数:10,代码来源:package_types_loader.py


示例15: execute

    def execute(self, request, body):
        policy.check("execute_action", request.context, {})

        class_name = body.get('className')
        method_name = body.get('methodName')
        if not class_name or not method_name:
            msg = _('Class name and method name must be specified for '
                    'static action')
            LOG.error(msg)
            raise exc.HTTPBadRequest(msg)

        args = body.get('parameters')
        pkg_name = body.get('packageName')
        class_version = body.get('classVersion', '=0')

        LOG.debug('StaticAction:Execute <MethodName: {0}, '
                  'ClassName: {1}>'.format(method_name, class_name))

        credentials = {
            'token': request.context.auth_token,
            'tenant_id': request.context.tenant
        }

        try:
            return static_actions.StaticActionServices.execute(
                method_name, class_name, pkg_name, class_version, args,
                credentials)
        except client.RemoteError as e:
            LOG.error(_LE('Exception during call of the method {method_name}: '
                          '{exc}').format(method_name=method_name, exc=str(e)))
            if e.exc_type in (
                    'NoClassFound', 'NoMethodFound', 'NoPackageFound',
                    'NoPackageForClassFound', 'MethodNotExposed',
                    'NoMatchingMethodException'):
                raise exc.HTTPNotFound(e.value)
            elif e.exc_type == 'ContractViolationException':
                raise exc.HTTPBadRequest(e.value)
            raise exc.HTTPServiceUnavailable(e.value)
        except ValueError as e:
            LOG.error(_LE('Exception during call of the method {method_name}: '
                          '{exc}').format(method_name=method_name, exc=str(e)))
            raise exc.HTTPBadRequest(e.message)
开发者ID:AleptNamrata,项目名称:murano,代码行数:42,代码来源:static_actions.py


示例16: _execute

    def _execute(self, pkg_loader):
        class_loader = package_class_loader.PackageClassLoader(pkg_loader)
        system_objects.register(class_loader, pkg_loader)
        get_plugin_loader().register_in_loader(class_loader)

        exc = executor.MuranoDslExecutor(class_loader, self.environment)
        obj = exc.load(self.model)

        self._validate_model(obj, self.action, class_loader)
        action_result = None
        exception = None
        exception_traceback = None
        try:
            LOG.info(_LI('Invoking pre-execution hooks'))
            self.environment.start()
            # Skip execution of action in case no action is provided.
            # Model will be just loaded, cleaned-up and unloaded.
            # Most of the time this is used for deletion of environments.
            if self.action:
                action_result = self._invoke(exc)
        except Exception as e:
            exception = e
            if isinstance(e, dsl_exception.MuranoPlException):
                LOG.error('\n' + e.format(prefix='  '))
            else:
                exception_traceback = traceback.format_exc()
                LOG.exception(
                    _LE("Exception %(exc)s occured"
                        " during invocation of %(method)s"),
                    {'exc': e, 'method': self.action['method']})
            reporter = status_reporter.StatusReporter()
            reporter.initialize(obj)
            reporter.report_error(obj, str(e))
        finally:
            LOG.info(_LI('Invoking post-execution hooks'))
            self.environment.finish()

        model = serializer.serialize_model(obj, exc)
        model['SystemData'] = self._environment.system_attributes
        result = {
            'model': model,
            'action': {
                'result': None,
                'isException': False
            }
        }
        if exception is not None:
            result['action'] = TaskExecutor.exception_result(
                exception, exception_traceback)
        else:
            result['action']['result'] = serializer.serialize_object(
                action_result)

        return result
开发者ID:finalbro,项目名称:murano,代码行数:54,代码来源:engine.py


示例17: _validate_request

 def _validate_request(self, request, env_template_id):
     env_template_exists = env_temps.EnvTemplateServices.env_template_exist
     if not env_template_exists(env_template_id):
         msg = _('EnvTemplate <TempId {temp_id}> is not found').format(
             temp_id=env_template_id)
         LOG.exception(msg)
         raise exc.HTTPNotFound(explanation=msg)
     get_env_template = env_temps.EnvTemplateServices.get_env_template
     env_template = get_env_template(env_template_id)
     if env_template.tenant_id != request.context.tenant:
         LOG.exception(_LE('User is not authorized to access this tenant '
                           'resources.'))
         raise exc.HTTPUnauthorized
开发者ID:tianshangjun,项目名称:murano,代码行数:13,代码来源:templates.py


示例18: _log_exception

 def _log_exception(e, root, method_name):
     if isinstance(e, dsl_exception.MuranoPlException):
         LOG.error('\n' + e.format(prefix='  '))
         exception_traceback = e.format()
     else:
         exception_traceback = traceback.format_exc()
         LOG.exception(
             _LE("Exception %(exc)s occurred"
                 " during invocation of %(method)s"),
             {'exc': e, 'method': method_name})
     if root is not None:
         reporter = status_reporter.StatusReporter()
         reporter.initialize(root)
         reporter.report_error(root, str(e))
     return exception_traceback
开发者ID:hybrid-murano,项目名称:hybrid-murano,代码行数:15,代码来源:engine.py


示例19: wrap

 def wrap(*args, **kwargs):
     try:
         ts = time.time()
         result = func(*args, **kwargs)
         te = time.time()
         tenant = args[1].context.tenant
         update_count(api, method, te - ts,
                      tenant)
         return result
     except Exception:
         te = time.time()
         tenant = args[1].context.tenant
         LOG.exception(_LE('API {api} method {method} raised an '
                           'exception').format(api=api, method=method))
         update_error_count(api, method, te - te, tenant)
         raise
开发者ID:AleptNamrata,项目名称:murano,代码行数:16,代码来源:request_statistics.py


示例20: _do_import_package

def _do_import_package(_dir, categories, update=False):
    LOG.debug("Going to import Murano package from {source}".format(
        source=_dir))
    pkg = load_utils.load_from_dir(_dir)

    LOG.debug("Checking for existing packages")
    existing = db_catalog_api.package_search(
        {'fqn': pkg.full_name},
        AdminContext())
    if existing:
        existing_pkg = existing[0]
        if update:
            LOG.debug('Deleting existing package {exst_pkg_id}').format(
                exst_pkg_id=existing_pkg.id)
            db_catalog_api.package_delete(existing_pkg.id, AdminContext())
        else:
            LOG.error(_LE("Package '{name}' exists ({pkg_id}). Use --update.")
                      .format(name=pkg.full_name, pkg_id=existing_pkg.id))
            return

    package = {
        'fully_qualified_name': pkg.full_name,
        'type': pkg.package_type,
        'author': pkg.author,
        'supplier': pkg.supplier,
        'name': pkg.display_name,
        'description': pkg.description,
        # note: we explicitly mark all the imported packages as public,
        # until a parameter added to control visibility scope of a package
        'is_public': True,
        'tags': pkg.tags,
        'logo': pkg.logo,
        'supplier_logo': pkg.supplier_logo,
        'ui_definition': pkg.ui,
        'class_definitions': pkg.classes,
        'archive': pkg.blob,
        'categories': categories or []
    }

    # note(ruhe): the second parameter is tenant_id
    # it is a required field in the DB, that's why we pass an empty string
    result = db_catalog_api.package_upload(package, '')

    LOG.info(_LI("Finished import of package {res_id}").format(
        res_id=result.id))
开发者ID:Aqsamm,项目名称:murano,代码行数:45,代码来源:manage.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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