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

Python log.is_debug函数代码示例

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

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



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

示例1: setup

    def setup(self):
        """This method is called before the task start."""
        try:
            for user in self.context['users']:
                osclient = osclients.Clients(user['credential'])
                keystone = osclient.keystone()
                creds = keystone.ec2.list(user['id'])
                if not creds:
                    creds = keystone.ec2.create(user['id'], user['tenant_id'])
                else:
                    creds = creds[0]
                url = keystone.service_catalog.url_for(service_type='ec2')
                user['ec2args'] = {
                    'region': 'RegionOne',
                    'url': url,
                    'access': creds.access,
                    'secret': creds.secret
                }

            if self.net_wrapper.SERVICE_IMPL == consts.Service.NEUTRON:
                for user, tenant_id in rutils.iterate_per_tenants(
                        self.context["users"]):
                    body = {"quota": {"router": -1, "floatingip": -1}}
                    self.net_wrapper.client.update_quota(tenant_id, body)
                    network = self.net_wrapper.create_network(
                        tenant_id, add_router=True, subnets_num=1)
                    self.context["tenants"][tenant_id]["network"] = network

        except Exception as e:
            msg = "Can't prepare ec2 client: %s" % e.message
            if logging.is_debug():
                LOG.exception(msg)
            else:
                LOG.warning(msg)
开发者ID:hayderimran7,项目名称:ec2-api,代码行数:34,代码来源:context_plugin_ec2_creds.py


示例2: _run_scenario_once

def _run_scenario_once(args):
    iteration, cls, method_name, context, kwargs = args

    LOG.info("Task %(task)s | ITER: %(iteration)s START" %
             {"task": context["task"]["uuid"], "iteration": iteration})

    context["iteration"] = iteration
    scenario = cls(
        context=context,
        admin_clients=osclients.Clients(context["admin"]["endpoint"]),
        clients=osclients.Clients(context["user"]["endpoint"]))

    error = []
    scenario_output = {"errors": "", "data": {}}
    try:
        with rutils.Timer() as timer:
            scenario_output = getattr(scenario,
                                      method_name)(**kwargs) or scenario_output
    except Exception as e:
        error = utils.format_exc(e)
        if logging.is_debug():
            LOG.exception(e)
    finally:
        status = "Error %s: %s" % tuple(error[0:2]) if error else "OK"
        LOG.info("Task %(task)s | ITER: %(iteration)s END: %(status)s" %
                 {"task": context["task"]["uuid"], "iteration": iteration,
                  "status": status})

        return {"duration": timer.duration() - scenario.idle_duration(),
                "timestamp": timer.timestamp(),
                "idle_duration": scenario.idle_duration(),
                "error": error,
                "scenario_output": scenario_output,
                "atomic_actions": scenario.atomic_actions()}
开发者ID:aarefiev22,项目名称:rally,代码行数:34,代码来源:base.py


示例3: _consumer

def _consumer(consume, queue, is_published):
    """Infinity worker that consumes tasks from queue.

    This finishes it's work only in case if is_published.isSet().

    :param consume: method that consumes an object removed from the queue
    :param queue: deque object to popleft() objects from
    :param is_published: threading.Event that is used to stop the consumer
                         when the queue is empty
    """
    cache = {}
    while True:
        if not queue:
            if is_published.isSet():
                break
            time.sleep(0.1)
            continue
        else:
            try:
                args = queue.popleft()
            except IndexError:
                # consumed by other thread
                continue
        try:
            consume(cache, args)
        except Exception as e:
            LOG.warning(_("Failed to consume a task from the queue: %s") % e)
            if logging.is_debug():
                LOG.exception(e)
开发者ID:NeCTAR-RC,项目名称:rally,代码行数:29,代码来源:broker.py


示例4: create

    def create(cls, config, name):
        """Create a deployment.

        :param config: a dict with deployment configuration
        :param name: a str represents a name of the deployment
        :returns: Deployment object
        """

        try:
            deployment = objects.Deployment(name=name, config=config)
        except exceptions.DeploymentNameExists as e:
            if logging.is_debug():
                LOG.exception(e)
            raise

        deployer = deploy_engine.Engine.get_engine(
            deployment["config"]["type"], deployment)
        try:
            deployer.validate()
        except jsonschema.ValidationError:
            LOG.error(_("Deployment %s: Schema validation error.") %
                      deployment["uuid"])
            deployment.update_status(consts.DeployStatus.DEPLOY_FAILED)
            raise

        with deployer:
            endpoints = deployer.make_deploy()
            deployment.update_endpoints(endpoints)
            return deployment
开发者ID:radar92,项目名称:rally,代码行数:29,代码来源:api.py


示例5: _consumer

def _consumer(consume, queue, is_published):
    """Infinity worker that consumes tasks from queue.

    This finishes it's work only in case if is_published.isSet().

    :param consume: method that consumes an object removed from the queue
    :param queue: deque object to popleft() objects from
    :param is_published: threading.Event that is used to stop the consumer
                         when the queue is empty
    """
    cache = {}
    while True:
        if queue:
            try:
                consume(cache, queue.popleft())
            except IndexError:
                # NOTE(boris-42): queue is accessed from multiple threads so
                #                 it's quite possible to have 2 queue accessing
                #                 at the same point queue with only 1 element
                pass
            except Exception as e:
                LOG.warning(_("Failed to consume a task from the queue: "
                              "%s") % e)
                if logging.is_debug():
                    LOG.exception(e)
        elif is_published.isSet():
            break
        else:
            time.sleep(0.1)
开发者ID:esikachev,项目名称:rally,代码行数:29,代码来源:broker.py


示例6: _delete_single_resource

    def _delete_single_resource(self, resource):
        """Safe resource deletion with retries and timeouts.

        Send request to delete resource, in case of failures repeat it few
        times. After that pull status of resource until it's deleted.

        Writes in LOG warning with UUID of resource that wasn't deleted

        :param resource: instance of resource manager initiated with resource
                         that should be deleted.
        """

        msg_kw = {
            "uuid": resource.id(),
            "service": resource._service,
            "resource": resource._resource
        }

        LOG.debug("Deleting %(service)s %(resource)s object %(uuid)s" %
                  msg_kw)

        try:
            rutils.retry(resource._max_attempts, resource.delete)
        except Exception as e:
            msg_kw["reason"] = e
            LOG.warning(
                _("Resource deletion failed, max retries exceeded for "
                  "%(service)s.%(resource)s: %(uuid)s. Reason: %(reason)s")
                % msg_kw)
            if logging.is_debug():
                LOG.exception(e)
        else:
            started = time.time()
            failures_count = 0
            while time.time() - started < resource._timeout:
                try:
                    if resource.is_deleted():
                        return
                except Exception as e:
                    LOG.warning(
                        _("Seems like %s.%s.is_deleted(self) method is broken "
                          "It shouldn't raise any exceptions.")
                        % (resource.__module__, type(resource).__name__))
                    LOG.exception(e)

                    # NOTE(boris-42): Avoid LOG spamming in case of bad
                    #                 is_deleted() method
                    failures_count += 1
                    if failures_count > resource._max_attempts:
                        break

                finally:
                    time.sleep(resource._interval)

            LOG.warning(_("Resource deletion failed, timeout occurred for "
                          "%(service)s.%(resource)s: %(uuid)s.")
                        % msg_kw)
开发者ID:rvbaz,项目名称:rally,代码行数:57,代码来源:manager.py


示例7: load_plugins

def load_plugins(dir_or_file):
    if os.path.isdir(dir_or_file):
        directory = dir_or_file
        LOG.info(_("Loading plugins from directories %s/*") %
                 directory.rstrip("/"))

        to_load = []
        for root, dirs, files in os.walk(directory, followlinks=True):
            to_load.extend((plugin[:-3], root)
                           for plugin in files if plugin.endswith(".py"))
        for plugin, directory in to_load:
            if directory not in sys.path:
                sys.path.append(directory)

            fullpath = os.path.join(directory, plugin)
            try:
                fp, pathname, descr = imp.find_module(plugin, [directory])
                imp.load_module(plugin, fp, pathname, descr)
                fp.close()
                LOG.info(_("\t Loaded module with plugins: %s.py") % fullpath)
            except Exception as e:
                LOG.warning(
                    "\t Failed to load module with plugins %(path)s.py: %(e)s"
                    % {"path": fullpath, "e": e})
                if logging.is_debug():
                    LOG.exception(e)
    elif os.path.isfile(dir_or_file):
        plugin_file = dir_or_file
        LOG.info(_("Loading plugins from file %s") % plugin_file)
        if plugin_file not in sys.path:
            sys.path.append(plugin_file)
        try:
            plugin_name = os.path.splitext(plugin_file.split("/")[-1])[0]
            imp.load_source(plugin_name, plugin_file)
            LOG.info(_("\t Loaded module with plugins: %s.py") % plugin_name)
        except Exception as e:
            LOG.warning(_(
                "\t Failed to load module with plugins %(path)s: %(e)s")
                % {"path": plugin_file, "e": e})
            if logging.is_debug():
                LOG.exception(e)
开发者ID:group-policy,项目名称:rally,代码行数:41,代码来源:discover.py


示例8: cleanup

 def cleanup(self):
     """This method is called after the task finish."""
     try:
         nova = osclients.Clients(self.context["admin"]["endpoint"]).nova()
         nova.flavors.delete(self.context["flavor"]["id"])
         LOG.debug("Flavor '%s' deleted" % self.context["flavor"]["id"])
     except Exception as e:
         msg = "Can't delete flavor: %s" % e.message
         if logging.is_debug():
             LOG.exception(msg)
         else:
             LOG.warning(msg)
开发者ID:sckevmit,项目名称:rally,代码行数:12,代码来源:context_plugin.py


示例9: _publisher

def _publisher(publish, queue):
    """Calls a publish method that fills queue with jobs.

    :param publish: method that fills the queue
    :param queue: deque object to be filled by the publish() method
    """
    try:
        publish(queue)
    except Exception as e:
        LOG.warning(_("Failed to publish a task to the queue: %s") % e)
        if logging.is_debug():
            LOG.exception(e)
开发者ID:group-policy,项目名称:rally,代码行数:12,代码来源:broker.py


示例10: cleanup

 def cleanup(self):
     try:
         if self.net_wrapper.SERVICE_IMPL == consts.Service.NEUTRON:
             for user, tenant_id in rutils.iterate_per_tenants(
                     self.context["users"]):
                 network = self.context["tenants"][tenant_id]["network"]
                 self.net_wrapper.delete_network(network)
     except Exception as e:
         msg = "Can't cleanup ec2 client: %s" % e.message
         if logging.is_debug():
             LOG.exception(msg)
         else:
             LOG.warning(msg)
开发者ID:hayderimran7,项目名称:ec2-api,代码行数:13,代码来源:context_plugin_ec2_creds.py


示例11: nova

 def nova(self, version="2"):
     """Return nova client."""
     from novaclient import client as nova
     kc = self.keystone()
     compute_api_url = kc.service_catalog.url_for(
         service_type="compute",
         endpoint_type=self.endpoint.endpoint_type,
         region_name=self.endpoint.region_name)
     client = nova.Client(version,
                          auth_token=kc.auth_token,
                          http_log_debug=logging.is_debug(),
                          timeout=CONF.openstack_client_http_timeout,
                          insecure=self.endpoint.insecure,
                          cacert=self.endpoint.cacert,
                          **self._get_auth_info(password_key="api_key"))
     client.set_management_url(compute_api_url)
     return client
开发者ID:srhrkrishna,项目名称:rally,代码行数:17,代码来源:osclients.py


示例12: cinder

 def cinder(self, version="1"):
     """Return cinder client."""
     from cinderclient import client as cinder
     client = cinder.Client(version,
                            http_log_debug=logging.is_debug(),
                            timeout=CONF.openstack_client_http_timeout,
                            insecure=self.endpoint.insecure,
                            cacert=self.endpoint.cacert,
                            **self._get_auth_info(password_key="api_key"))
     kc = self.keystone()
     volume_api_url = kc.service_catalog.url_for(
         service_type="volume",
         endpoint_type=self.endpoint.endpoint_type,
         region_name=self.endpoint.region_name)
     client.client.management_url = volume_api_url
     client.client.auth_token = kc.auth_token
     return client
开发者ID:srhrkrishna,项目名称:rally,代码行数:17,代码来源:osclients.py


示例13: _publisher

def _publisher(publish, queue, is_published):
    """Calls a publish method that fills queue with jobs.

    After running publish method it sets is_published variable, that is used to
    stop workers (consumers).

    :param publish: method that fills the queue
    :param queue: deque object to be filled by the publish() method
    :param is_published: threading.Event that is used to stop consumers and
                         finish task
    """
    try:
        publish(queue)
    except Exception as e:
        LOG.warning(_("Failed to publish a task to the queue: %s") % e)
        if logging.is_debug():
            LOG.exception(e)
    finally:
        is_published.set()
开发者ID:NeCTAR-RC,项目名称:rally,代码行数:19,代码来源:broker.py


示例14: setup

 def setup(self):
     """This method is called before the task start."""
     try:
         # use rally.osclients to get necessary client instance
         nova = osclients.Clients(self.context["admin"]["endpoint"]).nova()
         # and than do what you need with this client
         self.context["flavor"] = nova.flavors.create(
             # context settings are stored in self.config
             name=self.config.get("flavor_name", "rally_test_flavor"),
             ram=self.config.get("ram", 1),
             vcpus=self.config.get("vcpus", 1),
             disk=self.config.get("disk", 1)).to_dict()
         LOG.debug("Flavor with id '%s'" % self.context["flavor"]["id"])
     except Exception as e:
         msg = "Can't create flavor: %s" % e.message
         if logging.is_debug():
             LOG.exception(msg)
         else:
             LOG.warning(msg)
开发者ID:sckevmit,项目名称:rally,代码行数:19,代码来源:context_plugin.py


示例15: manila

 def manila(self, version="1"):
     """Return manila client."""
     from manilaclient import client as manila
     manila_client = manila.Client(
         version,
         region_name=self.endpoint.region_name,
         http_log_debug=logging.is_debug(),
         timeout=CONF.openstack_client_http_timeout,
         insecure=self.endpoint.insecure,
         cacert=self.endpoint.cacert,
         **self._get_auth_info(password_key="api_key",
                               project_name_key="project_name"))
     kc = self.keystone()
     manila_client.client.management_url = kc.service_catalog.url_for(
         service_type="share",
         endpoint_type=self.endpoint.endpoint_type,
         region_name=self.endpoint.region_name)
     manila_client.client.auth_token = kc.auth_token
     return manila_client
开发者ID:srhrkrishna,项目名称:rally,代码行数:19,代码来源:osclients.py


示例16: create_client

    def create_client(self, version=None):
        """Return nova client."""
        from novaclient import client as nova
        kc = self.keystone()
        compute_api_url = kc.service_catalog.url_for(
            service_type=self.get_service_type(),
            endpoint_type=self.endpoint.endpoint_type,
            region_name=self.endpoint.region_name)
	#TBD VISHNU KUMAR acess key or ?
        client = nova.Client(self.choose_version(version),
                             auth_token=kc.auth_token,
                             http_log_debug=logging.is_debug(),
                             timeout=CONF.openstack_client_http_timeout,
                             insecure=self.endpoint.insecure,
                             cacert=self.endpoint.cacert,
                             **self._get_auth_info(password_key="api_key"))
        enforce_boot_from_volume(client)
        client.set_management_url(compute_api_url)
        return client
开发者ID:vishnu-kumar,项目名称:PeformanceFramework,代码行数:19,代码来源:osclients.py


示例17: load_plugins

def load_plugins(directory):
    if os.path.exists(directory):
        LOG.info("Loading plugins from directories %s/*" % directory)

        to_load = []
        for root, dirs, files in os.walk(directory):
            to_load.extend((plugin[:-3], root)
                           for plugin in files if plugin.endswith(".py"))
        for plugin, directory in to_load:
            fullpath = os.path.join(directory, plugin)
            try:
                fp, pathname, descr = imp.find_module(plugin, [directory])
                imp.load_module(plugin, fp, pathname, descr)
                fp.close()
                LOG.info("\t Loaded module with plugins: %s.py" % fullpath)
            except Exception as e:
                LOG.warning(
                    "\t Failed to load module with plugins %(path)s.py: %(e)s"
                    % {"path": fullpath, "e": e})
                if logging.is_debug():
                    LOG.exception(e)
开发者ID:auroaj,项目名称:rally,代码行数:21,代码来源:utils.py


示例18: _print_task_info

        def _print_task_info(task):
            print()
            print("-" * 80)
            print(_("Task %(task_id)s: %(status)s")
                  % {"task_id": task_id, "status": task["status"]})

            if task["status"] == consts.TaskStatus.FAILED:
                print("-" * 80)
                verification = yaml.safe_load(task["verification_log"])

                if not logging.is_debug():
                    print(verification[0])
                    print(verification[1])
                    print()
                    print(_("For more details run:\n"
                            "rally -vd task detailed %s")
                          % task["uuid"])
                else:
                    print(yaml.safe_load(verification[2]))
                return False
            return True
开发者ID:group-policy,项目名称:rally,代码行数:21,代码来源:task.py


示例19: _consumer

def _consumer(consume, queue):
    """Infinity worker that consumes tasks from queue.

    :param consume: method that consumes an object removed from the queue
    :param queue: deque object to popleft() objects from
    """
    cache = {}
    while True:
        if not queue:
            break
        else:
            try:
                args = queue.popleft()
            except IndexError:
                # consumed by other thread
                continue
        try:
            consume(cache, args)
        except Exception as e:
            LOG.warning(_("Failed to consume a task from the queue: %s") % e)
            if logging.is_debug():
                LOG.exception(e)
开发者ID:group-policy,项目名称:rally,代码行数:22,代码来源:broker.py


示例20: setup

    def setup(self):
        """Create list of flavors."""
        self.context["flavors"] = {}

        clients = osclients.Clients(self.context["admin"]["endpoint"])
        for flavor_config in self.config:

            extra_specs = flavor_config.get("extra_specs")

            flavor_config = FlavorConfig(**flavor_config)
            try:
                flavor = clients.nova().flavors.create(**flavor_config)
            except nova_exceptions.Conflict as e:
                LOG.warning("Using already existing flavor %s" %
                            flavor_config["name"])
                if logging.is_debug():
                    LOG.exception(e)
                continue

            if extra_specs:
                flavor.set_keys(extra_specs)

            self.context["flavors"][flavor_config["name"]] = flavor.to_dict()
            LOG.debug("Created flavor with id '%s'" % flavor.id)
开发者ID:Vaidyanath,项目名称:rally,代码行数:24,代码来源:flavors.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python logging.getLogger函数代码示例发布时间:2022-05-26
下一篇:
Python log.getLogger函数代码示例发布时间: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