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

Python logger.error函数代码示例

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

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



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

示例1: get_file_content

 def get_file_content(self, path):
     try:
         with open(path, "r") as f:
             return f.read().strip()
     except Exception as e:
         logger.error("Error while reading file: %s. %s",
                      path, six.text_type(e))
开发者ID:openstack,项目名称:fuel-web,代码行数:7,代码来源:settings.py


示例2: update_task_status

    def update_task_status(cls, uuid, status, progress, msg="", result=None):
        # verify_networks - task is expecting to receive result with
        # some data if connectivity_verification fails
        logger.debug("Updating task: %s", uuid)
        task = db().query(Task).filter_by(uuid=uuid).first()
        if not task:
            logger.error("Can't set status='%s', message='%s':no task \
                    with UUID %s found!", status, msg, uuid)
            return
        previous_status = task.status
        data = {'status': status, 'progress': progress,
                'message': msg, 'result': result}
        for key, value in data.iteritems():
            if value is not None:
                setattr(task, key, value)
                logger.info(
                    u"Task {0} ({1}) {2} is set to {3}".format(
                        task.uuid,
                        task.name,
                        key,
                        value
                    )
                )
        db().add(task)
        db().commit()

        if previous_status != status and task.cluster_id:
            logger.debug("Updating cluster status: "
                         "cluster_id: %s status: %s",
                         task.cluster_id, status)
            cls.update_cluster_status(uuid)
        if task.parent:
            logger.debug("Updating parent task: %s.", task.parent.uuid)
            cls.update_parent_task(task.parent.uuid)
开发者ID:loles,项目名称:fuelweb,代码行数:34,代码来源:helpers.py


示例3: stats_user_resp

    def stats_user_resp(cls, **kwargs):
        logger.info("RPC method stats_user_resp received: %s",
                    jsonutils.dumps(kwargs))

        task_uuid = kwargs.get('task_uuid')
        nodes = kwargs.get('nodes', [])
        status = kwargs.get('status')
        error = kwargs.get('error')
        message = kwargs.get('msg')

        task = objects.Task.get_by_uuid(
            task_uuid, fail_if_not_found=True, lock_for_update=True)

        if status not in (consts.TASK_STATUSES.ready,
                          consts.TASK_STATUSES.error):
            logger.debug("Task %s, id: %s in status: %s",
                         task.name, task.id, task.status)
            return

        data = {'status': status, 'progress': 100, 'message': message}
        if status == consts.TASK_STATUSES.error:
            logger.error("Task %s, id: %s failed: %s",
                         task.name, task.id, error)
            data['message'] = error

        objects.Task.update(task, data)
        cls._update_action_log_entry(status, task.name, task_uuid, nodes)
        logger.info("RPC method stats_user_resp processed")
开发者ID:linglong0820,项目名称:fuel-web,代码行数:28,代码来源:receiver.py


示例4: get_network_roles

    def get_network_roles(cls, cluster, merge_policy):
        """Returns the network roles from plugins.

        The roles cluster and plugins will be mixed
        according to merge policy.
        """

        instance_roles = cluster.release.network_roles_metadata
        all_roles = dict((role['id'], role) for role in instance_roles)
        conflict_roles = dict()

        for plugin in cluster.plugins:
            for role in plugin.network_roles_metadata:
                role_id = role['id']
                if role_id in all_roles:
                    try:
                        merge_policy.apply_patch(
                            all_roles[role_id],
                            role
                        )
                    except errors.UnresolvableConflict as e:
                        logger.error("cannot merge plugin {0}: {1}"
                                     .format(plugin.name, e))
                        conflict_roles[role_id] = plugin.name
                else:
                    all_roles[role_id] = role

        if conflict_roles:
            raise errors.NetworkRoleConflict(
                "Cannot override existing network roles: '{0}' in "
                "plugins: '{1}'".format(
                    ', '.join(conflict_roles),
                    ', '.join(set(conflict_roles.values()))))

        return list(all_roles.values())
开发者ID:ymkins,项目名称:fuel-web,代码行数:35,代码来源:manager.py


示例5: update_verify_networks

    def update_verify_networks(cls, uuid, status,
                               progress, msg, result):
        #TODO(dshulyak) move network tests into ostf
        task = db().query(Task).filter_by(uuid=uuid).first()
        if not task:
            logger.error("Can't set status='%s', message='%s': No task \
                    with UUID %s found!", status, msg, uuid)
            return

        previous_status = task.status

        statuses = [sub.status for sub in task.subtasks]
        messages = [sub.message for sub in task.subtasks]
        messages.append(msg)
        statuses.append(status)
        if any(st == 'error' for st in statuses):
            task.status = 'error'
        else:
            task.status = status or task.status
        task.progress = progress or task.progress
        task.result = result or task.result
        # join messages if not None or ""
        task.message = '\n'.join([m for m in messages if m])
        db().commit()
        if previous_status != task.status and task.cluster_id:
            logger.debug("Updating cluster status: "
                         "cluster_id: %s status: %s",
                         task.cluster_id, status)
            cls.update_cluster_status(uuid)
开发者ID:AlexeyKasatkin,项目名称:fuel-web,代码行数:29,代码来源:helpers.py


示例6: send_log_serialized

 def send_log_serialized(self, records, ids):
     if records:
         logger.info("Send %d action logs records", len(records))
         resp = self.send_data_to_url(
             url=self.build_collector_url("COLLECTOR_ACTION_LOGS_URL"),
             data={"action_logs": records}
         )
         resp_dict = resp.json()
         if self.is_status_acceptable(resp.status_code,
                                      resp_dict["status"]):
             records_resp = resp_dict["action_logs"]
             saved_ids = set()
             failed_ids = set()
             for record in records_resp:
                 if record["status"] == \
                         consts.LOG_RECORD_SEND_STATUS.failed:
                     failed_ids.add(record["external_id"])
                 else:
                     saved_ids.add(record["external_id"])
             sent_saved_ids = set(saved_ids) & set(ids)
             logger.info("Action logs records saved: %s, failed: %s",
                         six.text_type(list(sent_saved_ids)),
                         six.text_type(list(failed_ids)))
             db().query(models.ActionLog).filter(
                 models.ActionLog.id.in_(sent_saved_ids)
             ).update(
                 {"is_sent": True}, synchronize_session=False
             )
             db().commit()
         else:
             logger.error("Unexpected collector answer: %s",
                          six.text_type(resp.text))
开发者ID:cxb811201,项目名称:fuel-web,代码行数:32,代码来源:statsenderd.py


示例7: launch_verify

    def launch_verify(self, cluster):
        try:
            data = self.validator.validate_networks_update(web.data())
        except web.webapi.badrequest as exc:
            task = Task(name='check_networks', cluster=cluster)
            db().add(task)
            db().commit()
            TaskHelper.set_error(task.uuid, exc.data)
            logger.error(traceback.format_exc())

            json_task = build_json_response(TaskHandler.render(task))
            raise web.accepted(data=json_task)

        data["networks"] = [
            n for n in data["networks"] if n.get("name") != "fuelweb_admin"
        ]

        vlan_ids = [{
                    'name': n['name'],
                    'vlans': cluster.network_manager.generate_vlan_ids_list(
                        data, cluster, n)
                    } for n in data['networks']]

        task_manager = VerifyNetworksTaskManager(cluster_id=cluster.id)
        try:
            task = task_manager.execute(data, vlan_ids)
        except errors.CantRemoveOldVerificationTask:
            raise web.badrequest("You cannot delete running task manually")
        return TaskHandler.render(task)
开发者ID:tsipa,项目名称:fuel-web,代码行数:29,代码来源:network_configuration.py


示例8: PUT

    def PUT(self, cluster_id):
        cluster = self.get_object_or_404(
            Cluster,
            cluster_id,
            log_404=(
                "warning",
                "Error: there is no cluster "
                "with id '{0}' in DB.".format(cluster_id)
            )
        )

        if not cluster.attributes:
            logger.error('ClusterAttributesDefaultsHandler: no attributes'
                         ' found for cluster_id %s' % cluster_id)
            raise web.internalerror("No attributes found!")

        cluster.attributes.editable = cluster.release.attributes_metadata.get(
            "editable"
        )
        self.db.commit()
        cluster.add_pending_changes("attributes")

        logger.debug('ClusterAttributesDefaultsHandler:'
                     ' editable attributes for cluster_id %s were reset'
                     ' to default' % cluster_id)
        return {"editable": cluster.attributes.editable}
开发者ID:akolinko,项目名称:product,代码行数:26,代码来源:cluster.py


示例9: PUT

    def PUT(self, cluster_id):
        """
        :IMPORTANT: this method should be rewritten to be more RESTful

        :returns: JSONized Task object.
        :http: * 202 (network checking task failed)
               * 200 (network verification task started)
               * 404 (cluster not found in db)
        """
        cluster = self.get_object_or_404(Cluster, cluster_id)

        try:
            data = self.validator.validate_networks_update(web.data())
        except web.webapi.badrequest as exc:
            task = Task(name='check_networks', cluster=cluster)
            db().add(task)
            db().commit()
            TaskHelper.set_error(task.uuid, exc.data)
            logger.error(traceback.format_exc())

            json_task = build_json_response(TaskHandler.render(task))
            raise web.accepted(data=json_task)

        vlan_ids = [{
            'name': n['name'],
            'vlans': NetworkGroup.generate_vlan_ids_list(n)
        } for n in data['networks']]

        task_manager = VerifyNetworksTaskManager(cluster_id=cluster.id)
        task = task_manager.execute(data, vlan_ids)

        return TaskHandler.render(task)
开发者ID:mydaisy2,项目名称:fuelweb,代码行数:32,代码来源:network_configuration.py


示例10: PUT

    def PUT(self, cluster_id):
        """:returns: JSONized Task object.
        :http: * 202 (network checking task created)
               * 404 (cluster not found in db)
        """
        data = jsonutils.loads(web.data())
        if data.get("networks"):
            data["networks"] = [n for n in data["networks"] if n.get("name") != "fuelweb_admin"]

        cluster = self.get_object_or_404(objects.Cluster, cluster_id)
        self.check_net_provider(cluster)

        self.check_if_network_configuration_locked(cluster)

        task_manager = CheckNetworksTaskManager(cluster_id=cluster.id)
        task = task_manager.execute(data)

        if task.status != consts.TASK_STATUSES.error:
            try:
                if "networks" in data:
                    self.validator.validate_networks_update(jsonutils.dumps(data))

                if "dns_nameservers" in data:
                    self.validator.validate_dns_servers_update(jsonutils.dumps(data))

                objects.Cluster.get_network_manager(cluster).update(cluster, data)
            except Exception as exc:
                # set task status to error and update its corresponding data
                data = {"status": consts.TASK_STATUSES.error, "progress": 100, "message": six.text_type(exc)}
                objects.Task.update(task, data)

                logger.error(traceback.format_exc())

        raise self.http(202, objects.Task.to_json(task))
开发者ID:yxh1990,项目名称:fuel-cloudmaster,代码行数:34,代码来源:network_configuration.py


示例11: calculate_fault_tolerance

    def calculate_fault_tolerance(cls, percentage_or_value, total):
        """Calculates actual fault tolerance value.

        :param percentage_or_value: the fault tolerance as percent of nodes
            that can fail or actual number of nodes,
            the negative number means the number of nodes
            which have to deploy successfully.
        :param total: the total number of nodes in group
        :return: the actual number of nodes that can fail
        """
        if percentage_or_value is None:
            # unattainable number
            return total + 1

        if isinstance(percentage_or_value, six.string_types):
            percentage_or_value = percentage_or_value.strip()

        try:
            if (isinstance(percentage_or_value, six.string_types) and
                    percentage_or_value[-1] == '%'):
                value = (int(percentage_or_value[:-1]) * total) // 100
            else:
                value = int(percentage_or_value)

            if value < 0:
                # convert negative value to number of nodes which may fail
                value = max(0, total + value)
            return value
        except ValueError as e:
            logger.error(
                "Failed to handle fault_tolerance: '%s': %s. it is ignored",
                percentage_or_value, e
            )
            # unattainable number
            return total + 1
开发者ID:openstack,项目名称:fuel-web,代码行数:35,代码来源:transaction_serializer.py


示例12: __init__

    def __init__(self):
        settings_files = []
        logger.debug("Looking for settings.yaml package config " "using old style __file__")
        project_path = os.path.dirname(__file__)
        project_settings_file = os.path.join(project_path, "settings.yaml")
        settings_files.append(project_settings_file)
        settings_files.append("/etc/nailgun/settings.yaml")

        version_paths = ["/etc/fuel/version.yaml", "/etc/fuel/nailgun/version.yaml", "/etc/nailgun/version.yaml"]
        for path in version_paths:
            if os.access(path, os.R_OK):
                settings_files.append(path)
                break
        else:
            logger.error("'version.yaml' config file is not found")

        self.config = {}
        for sf in settings_files:
            try:
                logger.debug("Trying to read config file %s" % sf)
                self.update_from_file(sf)
            except Exception as e:
                logger.error("Error while reading config file %s: %s" % (sf, str(e)))

        if int(self.config.get("DEVELOPMENT")):
            logger.info("DEVELOPMENT MODE ON:")
            here = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
            self.config.update(
                {"STATIC_DIR": os.path.join(here, "static"), "TEMPLATE_DIR": os.path.join(here, "static")}
            )
            logger.info("Static dir is %s" % self.config.get("STATIC_DIR"))
            logger.info("Template dir is %s" % self.config.get("TEMPLATE_DIR"))
开发者ID:koder-ua,项目名称:fuel-web,代码行数:32,代码来源:settings.py


示例13: get_metadata

    def get_metadata(self):
        """Get plugin data tree.

        :return: All plugin metadata
        :rtype: dict
        """
        data_tree, report = self.loader.load()

        if report.is_failed():
            logger.error(report.render())
            logger.error('Problem with loading plugin {0}'.format(
                self.plugin_path))
            return data_tree

        for field in data_tree:
            if field in self.attributes_processors:
                data_tree[field] = \
                    self.attributes_processors[field](data_tree.get(field))

        data_tree = {
            k: v
            for k, v in six.iteritems(data_tree)
            if v is not None
        }

        return data_tree
开发者ID:sebrandon1,项目名称:fuel-web,代码行数:26,代码来源:adapters.py


示例14: update_action_log

    def update_action_log(cls, task, al_instance=None):
        from nailgun.objects import ActionLog

        try:
            if not al_instance:
                al_instance = ActionLog.get_by_kwargs(task_uuid=task.uuid,
                                                      action_name=task.name)
            # this is needed as status for check_networks task is not set to
            # "ready" in case of success (it is left in status "running") so
            # we do it here manually, there is no such issue with "error"
            # status though.
            set_to_ready_cond = (
                task.name == consts.TASK_NAMES.check_networks
                and task.status == consts.TASK_STATUSES.running
            )
            task_status = consts.TASK_STATUSES.ready if set_to_ready_cond \
                else task.status

            if al_instance:
                task_cache = cls.get_task_cache(task)
                update_data = {
                    "end_timestamp": datetime.datetime.utcnow(),
                    "additional_info": {
                        "ended_with_status": task_status,
                        "message": "",
                        "output": cls.sanitize_task_output(task_cache,
                                                           al_instance)
                    }
                }
                ActionLog.update(al_instance, update_data)
        except Exception as e:
            logger.error("update_action_log failed: %s", six.text_type(e))
开发者ID:TorstenS73,项目名称:fuel-web,代码行数:32,代码来源:helpers.py


示例15: _success_start_action

 def _success_start_action(cls, task, status, progress):
     # check if all nodes are ready
     if any(map(lambda n: n.status == 'error',
                task.cluster.nodes)):
         cls._error_start_action(task, 'error', 100)
         return
     task_name = task.name.title()
     task_cache=cls.get_task_cache(task)
     try:      
         message = (
             u"The Role {0} of cluster '{1}' is success {2}"
         ).format(
             task_cache["role"],
             task.cluster.name,
             task_cache[task_cache["role"].lower()]["action"]
         )
     except Exception as exc:
         logger.error(": ".join([
             str(exc),
             traceback.format_exc()
         ]))
         message = u"{0} of environment '{1}' is done".format(
             task_name,
             task.cluster.name
         )
             
     notifier.notify(
         "done",
         message,
         task.cluster_id
     )
     data = {'status': status, 'progress': progress, 'message': message,'timestamp':datetime.datetime.now()}
     objects.Task.update(task, data)
开发者ID:zbwzy,项目名称:nailgun,代码行数:33,代码来源:receiver.py


示例16: run

def run():
    logger.info("Starting standalone stats sender...")
    try:
        StatsSender().run()
    except (KeyboardInterrupt, SystemExit) as e:
        logger.error("Stats sender exception: %s", six.text_type(e))
    logger.info("Stopping standalone stats sender...")
开发者ID:cxb811201,项目名称:fuel-web,代码行数:7,代码来源:statsenderd.py


示例17: PUT

    def PUT(self, cluster_id):
        data = json.loads(web.data())
        cluster = self.get_object_or_404(Cluster, cluster_id)

        task_manager = CheckNetworksTaskManager(cluster_id=cluster.id)
        task = task_manager.execute(data)

        if task.status != 'error':
            try:
                if 'networks' in data:
                    network_configuration = self.validator.\
                        validate_networks_update(json.dumps(data))

                NetworkConfiguration.update(cluster, data)
            except web.webapi.badrequest as exc:
                TaskHelper.set_error(task.uuid, exc.data)
                logger.error(traceback.format_exc())
            except Exception as exc:
                TaskHelper.set_error(task.uuid, exc)
                logger.error(traceback.format_exc())

        data = build_json_response(TaskHandler.render(task))
        if task.status == 'error':
            db().rollback()
        else:
            db().commit()
        raise web.accepted(data=data)
开发者ID:99cloud-net,项目名称:fuelweb,代码行数:27,代码来源:network_configuration.py


示例18: send_oswl_serialized

 def send_oswl_serialized(self, rec_data, ids):
     if rec_data:
         resp = self.send_data_to_url(
             url=self.build_collector_url("COLLECTOR_OSWL_INFO_URL"),
             data={"oswl_stats": rec_data}
         )
         resp_dict = resp.json()
         if self.is_status_acceptable(resp.status_code,
                                      resp_dict["status"]):
             records_resp = resp_dict["oswl_stats"]
             status_failed = consts.LOG_RECORD_SEND_STATUS.failed
             saved_ids = set(r["id"] for r in records_resp
                             if r["status"] != status_failed)
             failed_ids = set(r["id"] for r in records_resp
                              if r["status"] == status_failed)
             sent_saved_ids = set(saved_ids) & set(ids)
             logger.info("OSWL info records saved: %s, failed: %s",
                         six.text_type(list(sent_saved_ids)),
                         six.text_type(list(failed_ids)))
             if sent_saved_ids:
                 db().query(models.OpenStackWorkloadStats).filter(
                     models.OpenStackWorkloadStats.id.in_(sent_saved_ids)
                 ).update(
                     {"is_sent": True}, synchronize_session=False
                 )
                 db().commit()
         else:
             logger.error("Unexpected collector answer: %s",
                          six.text_type(resp.text))
开发者ID:naveenzhang,项目名称:fuel-web,代码行数:29,代码来源:statsenderd.py


示例19: _call_silently

    def _call_silently(self, task, instance, *args, **kwargs):
        # create action_log for task
        al = TaskHelper.create_action_log(task)

        method = getattr(instance, kwargs.pop('method_name', 'execute'))
        if task.status == TASK_STATUSES.error:
            TaskHelper.update_action_log(task, al)
            return
        try:
            to_return = method(task, *args, **kwargs)

            # update action_log instance for task
            # for asynchronous task it will be not final update
            # as they also are updated in rpc receiver
            TaskHelper.update_action_log(task, al)

            return to_return
        except Exception as exc:
            err = str(exc)
            if any([
                not hasattr(exc, "log_traceback"),
                hasattr(exc, "log_traceback") and exc.log_traceback
            ]):
                logger.error(traceback.format_exc())

            # update task entity with given data
            data = {'status': 'error',
                    'progress': 100,
                    'message': err}
            objects.Task.update(task, data)

            TaskHelper.update_action_log(task, al)
开发者ID:yxh1990,项目名称:fuel-cloudmaster,代码行数:32,代码来源:manager+-+鍓湰.py


示例20: PUT

    def PUT(self, cluster_id):
        """:returns: JSONized Task object.
        :http: * 200 (task successfully executed)
               * 202 (network checking task scheduled for execution)
               * 400 (data validation failed)
               * 404 (cluster not found in db)
        """
        # TODO(pkaminski): this seems to be synchronous, no task needed here
        data = jsonutils.loads(web.data())
        cluster = self.get_object_or_404(objects.Cluster, cluster_id)
        self.check_net_provider(cluster)

        self.check_if_network_configuration_locked(cluster)

        task_manager = CheckNetworksTaskManager(cluster_id=cluster.id)
        task = task_manager.execute(data)

        if task.status != consts.TASK_STATUSES.error:
            try:
                if "networks" in data:
                    self.validator.validate_networks_update(jsonutils.dumps(data))

                if "networking_parameters" in data:
                    self.validator.validate_neutron_params(jsonutils.dumps(data), cluster_id=cluster_id)

                objects.Cluster.get_network_manager(cluster).update(cluster, data)
            except Exception as exc:
                # set task status to error and update its corresponding data
                data = {"status": "error", "progress": 100, "message": six.text_type(exc)}
                objects.Task.update(task, data)
                logger.error(traceback.format_exc())

        self.raise_task(task)
开发者ID:thefuyang,项目名称:fuel-web,代码行数:33,代码来源:network_configuration.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python logger.exception函数代码示例发布时间:2022-05-27
下一篇:
Python logger.debug函数代码示例发布时间: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